def _generate_boot_cmd(board: Board) -> None: with Console("Generating /boot/boot.scr"): Utils.install('/boot/boot.cmd') # The FIT image is always located in /boot directory. # If there is such defined partition retrieve it's number. Do the same for / parts = { 'boot': 1, 'root': 1 } if board.soc == "stm32mp1xx": parts = { 'boot': 4, 'root': 4 } # for i in range(len(partitions)): # partition = partitions[i] # if partition.fstab.mount == '/': # parts['root'] = i + 1 # elif partition.fstab.mount == '/boot': # parts['boot'] = i + 1 # Generate template bootargs={ 'console': 'ttyS0,115200', 'panic': 10, 'loglevel': 4, } if board.soc == "stm32mp1xx": bootargs={ 'console': 'ttySTM0,115200', 'panic': 10, 'loglevel': 10, } Utils.template.install( env.paths['build'] + '/boot/boot.cmd', board=board, bootargs=bootargs, fit={ 'file': 'kernel.itb', 'load': board.loading.fit, }, partitions=parts, stamp={ 'date': str(datetime.datetime.now()), 'uuid': str(uuid.uuid4()), }, uenv={ 'file': 'uEnv.txt', 'load': board.loading.uenv, }, ) # Generate boot.scr Utils.shell.run( "mkimage -C none -A arm -T script -d {build}/boot/boot.cmd {build}/boot/boot.scr".format( build=env.paths['build']), shell=True )
def configure(self): # Copy resolv.conf with Console("Copying /etc/resolv.conf"): Utils.shell.run('rm -vf {}/etc/resolv.conf'.format( self._build_dir), ignore_fail=True) Utils.shell.run( 'cp -vf /etc/resolv.conf {}/etc/resolv.conf'.format( self._build_dir)) # Install packages self._install_packages() # Configure blueman with Console("Configuring blueman"): Setup.blueman() # Enabling auto-login with Console("Enabling auto-login"): Utils.install('/etc/lightdm/lightdm.conf') # Set default displaymanager with Console("Setting default display-manager"): Setup.displaymanager("lightdm")
def setup(self, partitions: Partitions, path: str) -> None: """ Set hostname to etc/hosts and etc/hostname :param partitions: Partitions table :param path: Path to install files :return: None """ file = '/etc/fstab' Utils.install(file, path=path) # Generate template Utils.template.install( path + file, partitions=[ { 'uuid': '{:36}'.format(part.fstab.uuid), 'mount': '{:15}'.format(part.fstab.mount), 'type': '{:7}'.format(part.fstab.type), 'options': '{:8}'.format(part.fstab.options), 'dump': '{:7}'.format(part.fstab.dump), 'pass': '******'.format(part.fstab.passno) } for part in partitions ] )
def setup(self, keymap: str, layout: str): # Configure console with Console("Generating console configuration"): Utils.shell.chroot('bash -c \'\ echo "console-setup console-setup/charmap47 select UTF-8" | debconf-set-selections -v; \ echo "console-setup console-setup/codeset47 select Guess optimal character set\" | debconf-set-selections -v; \ echo "console-setup console-setup/fontface47 select Do not change the boot/kernel font" | debconf-set-selections -v\ \'') # Configure keyboard with Console( "Generating keyboard configuration: \'{}\'".format(keymap)): Utils.shell.chroot('bash -c \'\ echo "keyboard-configuration keyboard-configuration/altgr select The default for the keyboard layout" | debconf-set-selections -v; \ echo "keyboard-configuration keyboard-configuration/model select Generic 105-key (Intl) PC" | debconf-set-selections -v; \ echo "keyboard-configuration keyboard-configuration/xkb-keymap select {}" | debconf-set-selections -v; \ echo "keyboard-configuration keyboard-configuration/compose select No compose key" | debconf-set-selections -v; \ echo "keyboard-configuration keyboard-configuration/ctrl_alt_bksp boolean true" | debconf-set-selections -v; \ echo "keyboard-configuration keyboard-configuration/variant select {}" | debconf-set-selections -v\ \''.format(keymap, layout)) # Install package with Console("Installing packages"): Utils.shell.chroot('apt-get install -y {}'.format(' '.join( self.packages))) # Run configuration with Console("Running setup"): Utils.install('/etc/default/console-setup') Utils.shell.chroot('setupcon --force --save-only -v')
def setup(self, timezone: str): file = '/etc/timezone' Utils.install(file) Utils.template.install(env.paths['build'] + file, timezone=timezone) # Reconfigure Utils.shell.chroot('dpkg-reconfigure -f noninteractive tzdata')
def enable(host: str, port: int) -> None: file = '/etc/apt/apt.conf.d/01cache' # Install the file Utils.install(file) # Generate template Utils.template.install(env.paths['build'] + file, host=host, port=port)
def configure(self): # Copy resolv.conf with Console("Copying /etc/resolv.conf"): Utils.shell.run('rm -vf {}/etc/resolv.conf'.format( self._build_dir), ignore_fail=True) Utils.shell.run( 'cp -vf /etc/resolv.conf {}/etc/resolv.conf'.format( self._build_dir)) # Install packages self._install_packages() # Configure blueman with Console("Configuring blueman"): Setup.blueman() # Enabling auto-login with Console("Enabling auto-login"): Utils.install('/etc/lightdm/lightdm.conf') # Set default displaymanager with Console("Setting default display-manager"): Setup.displaymanager("lightdm") # post-install with Console("Post-install tasks"): Utils.shell.chroot( "/bin/bash -c 'echo -en > /etc/modules-load.d/cups-filters.conf'", ignore_fail=True) # meh broken light-locker in focal Utils.shell.chroot('apt-get -y --purge remove light-locker', log_error=False) # xfce panel defaults Utils.install('/etc/X11/Xsession.d/99olimex') # set xfce background Utils.shell.run( 'dpkg-divert --rename --add --divert /usr/share/backgrounds/xfce/xfce-stripes.png.real /usr/share/backgrounds/xfce/xfce-stripes.png' ) Utils.shell.run( 'dpkg-divert --rename --add --divert /usr/share/backgrounds/xfce/xfce-blue.jpg.real /usr/share/backgrounds/xfce/xfce-blue.jpg' ) Utils.install('/usr/share/backgrounds/xfce/xfce-stripes.png') Utils.install('/usr/share/backgrounds/xfce/xfce-blue.jpg') Utils.install('/usr/share/backgrounds/xfce/xfce-red.jpg') # restore resolv.conf with Console("Restore /etc/resolv.conf"): Utils.shell.run('rm -vf {}/etc/resolv.conf'.format( self._build_dir), ignore_fail=True) Utils.shell.run( 'ln -nsf ../run/resolvconf/resolv.conf {}/etc/resolv.conf'. format(self._build_dir))
def enable() -> None: with Console('Installing: \'[email protected]/noclear.conf\''): Utils.install('/etc/systemd/system/[email protected]/noclear.conf') with Console('Enabling: \'[email protected]\''): # Install and enable service Utils.shell.chroot('mkdir -p /etc/systemd/system/[email protected]') Utils.shell.chroot('systemctl --no-reload enable [email protected]') # Configure ttyGS0 Utils.shell.chroot('/bin/bash -c "echo \'\n# USB-ACM tty serial console\nttyGS0\n\' >> /etc/securetty"')
def enable() -> None: with Console('Installing: \'[email protected]/noclear.conf\''): Utils.install( '/etc/systemd/system/[email protected]/noclear.conf') with Console('Enabling: \'[email protected]\''): # Install and enable service Utils.shell.chroot( 'mkdir -p /etc/systemd/system/[email protected]') Utils.shell.chroot( 'systemctl --no-reload enable [email protected]')
def _generate_fit(board): with Console("Generating /usr/lib/olinuxino/kernel.its"): Utils.install('/etc/kernel/postinst.d/uboot-fit', mode='755') Utils.install('/usr/lib/olinuxino/kernel.its') # Generate fdts and overlay data fdts = [] overlays = [] for model in board.models: if model.fdt not in fdts: fdts.append(model.fdt) for overlay in model.overlays: file = env.paths['build'] + '/usr/lib/olinuxino-overlays/{}/{}'.format(board.soc, overlay) if overlay not in overlays and os.path.exists(file): overlays.append(overlay) # Remap board fdt and overlays models = [] for model in board.models: dtbo = [] for overlay in model.overlays: if overlay in overlays: dtbo.append(overlays.index(overlay) + 1) models.append({ 'name': str(model), 'fdt': fdts.index(model.fdt) + 1, 'id': model.id, 'overlays': dtbo, 'compatible': 'olimex,{}'.format(str(model).lower()) }) # Generate load addresses for overlays addr = int(board.loading.overlays, 16) temp = [] for overlay in overlays: temp.append({overlay: {'load': '0x{:08X}'.format(addr)}}) addr += 0x10000 overlays = temp Utils.template.install( env.paths['build'] + '/usr/lib/olinuxino/kernel.its', arch='arm' if board.arch == 'armhf' else board.arch, board=board, fdts=fdts, overlays=overlays, stamp={ 'date': str(datetime.datetime.now()), 'uuid': str(uuid.uuid4()), }, models=models, )
def setup(self, hostname: str) -> None: """ Set hostname to etc/hosts and etc/hostname :param hostname: Desired hostname :return: None """ files = ['/etc/hostname', '/etc/hosts'] for file in files: Utils.install(file) Utils.template.install(env.paths['build'] + file, hostname=hostname)
def setup(self): for interface in NetworkParser().interfaces: interface: Interface with Console('Installing: \'/etc/network/interfaces\''): Utils.install('/etc/network/interfaces') with Console("Configuring interface: \'{}\'".format(str(interface))): file = '/etc/network/interfaces.d/{}'.format(str(interface)) source = env.paths['overlay'] + '/etc/network/interfaces.d/default' destination = env.paths['build'] + file # Install source list Utils.shell.run("install -m 644 {} {}".format(source, destination)) Utils.template.install(destination, interface=interface)
def configure(self): # Copy resolv.conf with Console("Copying /etc/resolv.conf"): Utils.shell.run('rm -vf {}/etc/resolv.conf'.format( self._build_dir), ignore_fail=True) Utils.shell.run( 'cp -vf /etc/resolv.conf {}/etc/resolv.conf'.format( self._build_dir)) # Install packages self._install_packages() # Configure blueman with Console("Configuring blueman"): Setup.blueman() # Enabling auto-login with Console("Enabling auto-login"): Utils.install('/etc/lightdm/lightdm.conf') # Set default displaymanager with Console("Setting default display-manager"): Setup.displaymanager("lightdm") # post-install with Console("Post-install tasks"): Utils.shell.chroot( "/bin/bash -c 'echo -en > /etc/modules-load.d/cups-filters.conf'", ignore_fail=True) # meh broken light-locker in focal Utils.shell.chroot('apt-get -y --purge remove light-locker', log_error=False) # restore resolv.conf with Console("Restore /etc/resolv.conf"): Utils.shell.run('rm -vf {}/etc/resolv.conf'.format( self._build_dir), ignore_fail=True) Utils.shell.run( 'ln -nsf ../run/resolvconf/resolv.conf {}/etc/resolv.conf'. format(self._build_dir))
def _generate_uboot_env(board: Board, configs: dict = None) -> None: with Console("Generating /boot/uEnv.txt"): Utils.install('/boot/uEnv.txt') Utils.template.install( env.paths['build'] + '/boot/uEnv.txt', configs=configs, stamp={ 'date': str(datetime.datetime.now()), 'uuid': str(uuid.uuid4()), } ) with Console("Installing /etc/fw_env.config"): Utils.install('/etc/fw_env.config') with Console("Installing /uboot.env"): src = env.paths['build'] + "/usr/lib/u-boot-olinuxino/{}/uboot.env".format(board.name.lower()) dest = env.paths['build'] + "/uboot.env" Utils.shell.run('install -D -v -m {} {} {}'.format(644, src, dest))
def setup(self, release: str): with Console("Installing packages"): Utils.shell.chroot('apt-get install -y {}'.format(' '.join( self.packages))) for repo in Repositories(): repo: Repository if repo.testing and env.options['releaseimage']: continue with Console("Adding: \'{}\'".format(repo.url)): file = '/etc/apt/sources.list.d/{}.list'.format(str(repo)) source = env.paths[ 'overlay'] + '/etc/apt/sources.list.d/default.list' destination = env.paths['build'] + file # # Install source list Utils.shell.run("install -m 644 {} {}".format( source, destination)) Utils.template.install(destination, repo=repo, release=release) if repo.key and repo.keyserver: # Import gpg key Utils.shell.chroot( 'apt-key adv --keyserver {} --recv-keys {}'.format( repo.keyserver, repo.key)) elif repo.keyfile: # Import keyfile Utils.install(repo.keyfile) Utils.shell.chroot('apt-key add {}'.format(repo.keyfile)) # Update sources # It's possible for some repository to have missing release files, so # for now ignore error upon update with Console("Updating"): Utils.shell.chroot('apt-get update', ignore_fail=True)
def setup(self): Utils.install('/etc/skel/.config/xfce4/xfconf/xfce-perchannel-xml/xfce4-power-manager.xml') Utils.install('/etc/modprobe.d/rtl8192cu.conf') Utils.install('/etc/modprobe.d/rtl8723bs.conf') Utils.shell.run('sed -i "s/^#DefaultTimeoutStopSec.*/DefaultTimeoutStopSec=15s/g" {}/etc/systemd/system.conf'.format(env.paths['build'])) Utils.shell.run('sed -i "s/^#Storage=.*/Storage=volatile/g" {}/etc/systemd/journald.conf'.format(env.paths['build'])) Utils.shell.run('sed -i "s/^#SystemMaxUse=.*/SystemMaxUse=64M/g" {}/etc/systemd/journald.conf'.format(env.paths['build'])) Utils.shell.run('sed -i "s/^#RuntimeMaxUse=.*/RuntimeMaxUse=64M/g" {}/etc/systemd/journald.conf'.format(env.paths['build']))
def setup(self): Utils.install('/etc/modprobe.d/rtl8192cu.conf') Utils.install('/etc/modprobe.d/rtl8723bs.conf')
def setup(self): Utils.install( '/etc/skel/.config/xfce4/xfconf/xfce-perchannel-xml/xfce4-power-manager.xml' ) Utils.install('/etc/modprobe.d/rtl8192cu.conf') Utils.install('/etc/modprobe.d/rtl8723bs.conf')