Beispiel #1
0
def _is_part_skipped(part_name, tinfoil):
    return (
        tutil.get_bitbake_conf_var(
            "MBL_{}_SKIP".format(part_name), tinfoil, missing_ok=True
        )
        == "1"
    )
    def __init__(self, deploy_dir, tinfoil):
        """
        Create a _WksBootloaderSlotImageBase object.

        Args:
        * deploy_dir Path: path to the directory containing build artifacts.
        * tinfoil Tinfoil: BitBake Tinfoil object.

        """
        filename_var_name = "MBL_{}_FILENAME".format(self.image_base_type)
        filename = tutil.get_bitbake_conf_var(filename_var_name, tinfoil)
        self._path = deploy_dir / filename
Beispiel #3
0
    def __init__(self, bootloader_slot_name, deploy_dir, tinfoil):
        """
        Create a WksBootloaderSlotImage object.

        Args:
        * bootloader_slot_name str: name of the bootloader slot/partition.
        * deploy_dir Path: path to the directory containing build artifacts.
        * tinfoil Tinfoil: BitBake Tinfoil object.

        """
        self._bootloader_slot_name = bootloader_slot_name
        filename_var_name = "MBL_{}_FILENAME".format(bootloader_slot_name)
        filename = tutil.get_bitbake_conf_var(filename_var_name, tinfoil)
        self._archived_file_spec = uutil.ArchivedFileSpec(
            deploy_dir / filename, "{}.xz".format(self.image_type))
Beispiel #4
0
    def __init__(self, image_name, deploy_dir, tinfoil):
        """
        Create a RootfsImage object.

        Args:
        * image_name str: name of the BitBake image recipe that was used to
          create the rootfs image.
        * deploy_dir Path: path to the directory containing build artifacts.
        * tinfoil Tinfoil: BitBake Tinfoil object.

        """
        machine = tutil.get_bitbake_conf_var("MACHINE", tinfoil)
        rootfs_filename = "{}-{}.tar.xz".format(image_name, machine)
        self._archived_file_spec = uutil.ArchivedFileSpec(
            deploy_dir / rootfs_filename, "{}.tar.xz".format(self.image_type))
Beispiel #5
0
def _get_archived_file_specs(deploy_dir, tinfoil):
    """
    Get ArchivedFileSpecs for the boot partition (or BLFS).

    :param deploy_dir Path: path to DEPLOY_DIR_IMAGE.
    :param tinfoil Tinfoil: BitBake tinfoil object.
    """
    boot_file_entries = tutil.get_bitbake_conf_var("IMAGE_BOOT_FILES",
                                                   tinfoil).split()
    boot_files = list(
        itertools.chain.from_iterable(
            _img_boot_files_val_to_archived_file_specs(elem, deploy_dir)
            for elem in boot_file_entries))
    if not boot_files:
        bb.fatal("Failed to convert IMAGE_BOOT_FILES value into list of files")
    return boot_files
Beispiel #6
0
    def __init__(self, payload_format_version, tinfoil):
        """
        Construct a PayloadBuilder object.

        Args:
        * payload_format_version int: payload format version for which the
        * tinfoil Tinfoil: BitBake Tinfoil object.

        """
        self._tinfoil = tinfoil
        self._deploy_dir = pathlib.Path(
            tutil.get_bitbake_conf_var("DEPLOY_DIR_IMAGE", tinfoil))
        if payload_format_version not in self._payload_format_specs:
            bb.fatal('Unsupported payload format version "{}".'.format(
                payload_format_version))
        self._format_spec = self._payload_format_specs[payload_format_version]
        self._payload_format_version = payload_format_version
Beispiel #7
0
    def __init__(
        self,
        tinfoil,
        bootloader_components=[],
        kernel=False,
        rootfs=False,
        apps=[],
    ):
        """
        Create an UpdatePayload object.

        Args:
        * tinfoil Tinfoil: BitBake Tinfoil object.
        * bootloader_components list<str>: names of bootloader components to
          add to the payload. I.e. a sublist of ["1", "2"].
        * kernel bool: True if the kernel component should be added to the
          payload.
        * rootfs bool: True if the rootfs component should be added to the
          payload.
        * apps list<str|Path>: list of apps (ipk files) to add to the payload.

        """
        deploy_dir = pathlib.Path(
            tutil.get_bitbake_conf_var("DEPLOY_DIR_IMAGE", tinfoil)
        )
        self.images = []
        if bootloader_components:
            bootloader_components_copy = bootloader_components.copy()
            if _bootloader_one_with_kernel(bootloader_components, tinfoil):
                if not kernel:
                    logging.warning(
                        "On this target the bootloader 1 component and kernel "
                        "must be updated together. "
                        "Adding kernel to payload..."
                    )
                    images.append(bootimage.BootImageV3(deploy_dir, tinfoil))

                bootloader_components_copy.remove("1")

            for bootloader_slot_number in bootloader_components_copy:
                slot_name = "WKS_BOOTLOADER{}".format(bootloader_slot_number)
                self.images.append(
                    wksbootloaderslotimage.WksBootloaderSlotImageV3(
                        slot_name, deploy_dir, tinfoil
                    )
                )

        if kernel:
            if _kernel_with_bootloader_one(bootloader_components, tinfoil):
                if "1" not in bootloader_components:
                    bb.warn(
                        "On this target the bootloader 1 component and kernel "
                        "must be updated together. "
                        "Adding bootloader 1 component to payload..."
                    )
            self.images.append(bootimage.BootImageV3(deploy_dir, tinfoil))

        if apps is not None:
            self.images.append(appsimage.AppsImageV3(apps))

        if rootfs is not None:
            self.images.append(
                rootfsimage.RootfsImageV3(rootfs, deploy_dir, tinfoil)
            )