Esempio n. 1
0
 def make_syslinux(self):
     """
     Create symlink of the important syslinux bootloader files in case they are available on the system.
     """
     if not utils.command_existing("syslinux"):
         self.logger.info(
             "syslinux command not available. Bailing out of syslinux setup!"
         )
         return
     # Make modules
     symlink(self.syslinux_folder.joinpath("menu.c32"),
             self.bootloaders_dir.joinpath("menu.c32"),
             skip_existing=True)
     if get_syslinux_version() < 5:
         # This file is only required for Syslinux 5 and newer.
         # Source: https://wiki.syslinux.org/wiki/index.php?title=Library_modules
         self.logger.info(
             'syslinux version 4 detected! Skip making symlink of "ldlinux.c32" file!'
         )
     else:
         symlink(self.syslinux_folder.joinpath("ldlinux.c32"),
                 self.bootloaders_dir.joinpath("ldlinux.c32"),
                 skip_existing=True)
     # Make memdisk
     symlink(self.syslinux_memdisk_folder.joinpath("memdisk"),
             self.bootloaders_dir.joinpath("memdisk"),
             skip_existing=True)
     # Make pxelinux.0
     symlink(self.syslinux_pxelinux_folder.joinpath("pxelinux.0"),
             self.bootloaders_dir.joinpath("pxelinux.0"),
             skip_existing=True)
Esempio n. 2
0
 def make_shim(self):
     """
     Create symlink of the shim bootloader in case it is available on the system.
     """
     if not utils.command_existing("shim-install"):
         self.logger.info("shim-install missing. This means we are probably also missing the file we require. "
                          "Bailing out of linking the shim!")
         return
     symlink(
         pathlib.Path("/usr/share/efi/x86_64/shim.efi"),
         self.bootloaders_dir.joinpath(pathlib.Path("grub/shim.efi")),
         skip_existing=True
     )
Esempio n. 3
0
 def make_syslinux(self):
     """
     Create symlink of the important syslinux bootloader files in case they are available on the system.
     """
     if not utils.command_existing("syslinux"):
         self.logger.info("syslinux command not available. Bailing out of syslinux setup!")
         return
     for target, link in self.syslinux_links.items():
         if link.name == "ldlinux.c32" and get_syslinux_version() < 5:
             # This file is only required for Syslinux 5 and newer.
             # Source: https://wiki.syslinux.org/wiki/index.php?title=Library_modules
             self.logger.info('syslinux version 4 detected! Skip making symlink of "ldlinux.c32" file!')
             continue
         symlink(target, link, skip_existing=True)
Esempio n. 4
0
    def make_grub(self):
        """
        Create symlink of the GRUB 2 bootloader in case it is available on the system. Additionally build the loaders
        for other architectures if the modules to do so are available.
        """
        symlink(
            pathlib.Path("/usr/share/efi/x86_64/grub.efi"),
            self.bootloaders_dir.joinpath(pathlib.Path("grub/grub.efi")),
            skip_existing=True
        )

        if not utils.command_existing("grub2-mkimage"):
            self.logger.info("grub2-mkimage command not available. Bailing out of GRUB2 generation!")
            return

        for image_format, options in self.boot_loaders_formats.items():
            bl_mod_dir = options.get("mod_dir", image_format)
            mod_dir = self.grub2_mod_dir.joinpath(bl_mod_dir)
            if not mod_dir.exists():
                self.logger.info(
                    'GRUB2 modules directory for arch "%s" did no exist. Skipping GRUB2 creation',
                    image_format
                )
                continue
            try:
                mkimage(
                    image_format,
                    self.bootloaders_dir.joinpath("grub", options["binary_name"]),
                    self.modules + options.get("extra_modules", []),
                )
            except subprocess.CalledProcessError:
                self.logger.info('grub2-mkimage failed for arch "%s"! Maybe you did forget to install the grub modules '
                                 'for the architecture?', image_format)
                utils.log_exc()
                # don't create module symlinks if grub2-mkimage is unsuccessful
                continue
            self.logger.info('Successfully built bootloader for arch "%s"!', image_format)

            # Create a symlink for GRUB 2 modules
            # assumes a single GRUB can be used to boot all kinds of distros
            # if this assumption turns out incorrect, individual "grub" subdirectories are needed
            symlink(
                mod_dir,
                self.bootloaders_dir.joinpath("grub", bl_mod_dir),
                skip_existing=True
            )
Esempio n. 5
0
def test_command_existing(input_cmd, expected_result):
    # Arrange & Act
    result = utils.command_existing(input_cmd)

    # Assert
    assert result == expected_result