Exemple #1
0
    def __init__(self, meta_build_path, config_dir_obj, sign_id_list=[]):
        assert isinstance(meta_build_path, str)
        assert isinstance(config_dir_obj, ConfigDir)

        # Initialize the BaseStager
        BaseStager.__init__(self)

        self.config_dir_obj = config_dir_obj

        # Create internal attributes
        self._meta_build_path = meta_build_path

        # Validate that the meta_build path exists
        meta_build_path = c_path.normalize(meta_build_path)
        if not c_path.validate_dir(meta_build_path):
            raise RuntimeError('No read access to the meta build path: ' + meta_build_path)

        # Get the meta lib module from the metabuild
        meta_info = self.get_meta_info(meta_build_path)

        # Create the image info list based on the meta data
        for sign_id, chipset, image_src_path, image_dest_path in self.get_image_info_from_meta(meta_info):
            # Filer on the sign id
            if sign_id_list:
                if sign_id not in sign_id_list:
                    continue

            try:
                img_config_parser = self.get_image_config_parser(chipset)

                # Validate the sign_id
                sign_id = self._get_sign_id(img_config_parser,
                                            os.path.basename(image_src_path.image_path),
                                            sign_id)

                # Get the config block for the sign id
                img_config_block = img_config_parser.get_config_for_sign_id(sign_id)

                # Create the one image info object
                image_info = ImageInfo('', sign_id, img_config_block,
                                       img_config_parser)

                # Set the src path
                image_info.src_image = image_src_path
                image_info.image_under_operation = image_info.src_image.image_path

                # Set the dest path
                image_info.dest_image = image_dest_path

                # Put the image info object into the list
                self._image_info_list.append(image_info)

            except Exception as e:
                logger.error(str(e))

        if not self._image_info_list:
            raise RuntimeError('No images found from the meta build.')
Exemple #2
0
    def _create_imageinfo(self,
                          img_config_parser,
                          parsegen_config,
                          sign_id,
                          image_path,
                          gen_multi_image,
                          src_image=None,
                          dest_image=None):

        if not gen_multi_image and sign_id not in MULTI_IMAGE_SIGN_ID.values():
            # Validate the sign_id
            sign_id = self._get_sign_id(img_config_parser,
                                        os.path.basename(image_path), sign_id)
            # Get the config block for the sign id
            img_config_block = img_config_parser.get_config_for_sign_id(
                sign_id)
        else:
            try:
                # Get the config block for the Multi-Image Sign & Integrity image
                img_config_block = img_config_parser.get_config_for_sign_id(
                    sign_id)
            except:
                raise RuntimeError(multi_image_string() +
                                   " images are not supported for chipset {0}".
                                   format(img_config_parser.chipset))

        # Create the image info object
        image_info = ImageInfo(image_path,
                               sign_id,
                               img_config_block,
                               img_config_parser,
                               parsegen_config,
                               gen_multi_image=gen_multi_image,
                               authority=self.authority)
        image_info.dest_image.image_name = image_info.src_image.image_name

        # Set src_image
        if src_image is not None:
            image_info.src_image = src_image
            image_info.image_under_operation = image_info.src_image.image_path

        # Set dest_image
        if dest_image is not None:
            image_info.dest_image = dest_image

        # Check if the dest image name should be overridden
        if img_config_block.output_file_name is not None:
            image_info.dest_image.image_name = img_config_block.output_file_name

        return image_info
    def _create_imageinfo(self,
                          img_config_parser,
                          parsegen_config,
                          sign_id,
                          image_path,
                          src_image=None,
                          dest_image=None):

        # Validate the sign_id
        sign_id = self._get_sign_id(img_config_parser,
                                    os.path.basename(image_path), sign_id)
        # Get the config block for the sign id
        img_config_block = img_config_parser.get_config_for_sign_id(sign_id)

        # Create the image info object
        image_info = ImageInfo(image_path,
                               sign_id,
                               img_config_block,
                               img_config_parser,
                               parsegen_config,
                               authority=self.authority)
        image_info.dest_image.image_name = image_info.src_image.image_name

        # Set src_image
        if src_image is not None:
            image_info.src_image = src_image
            image_info.image_under_operation = image_info.src_image.image_path

        # Set dest_image
        if dest_image is not None:
            image_info.dest_image = dest_image

        # Check if the dest image name should be overridden
        if img_config_block.output_file_name is not None:
            image_info.dest_image.image_name = img_config_block.output_file_name

        return image_info
    def __init__(self,
                 meta_build_path,
                 config_dir_obj,
                 parsegen_config,
                 sign_id_list=[]):
        from sectools.features.isc.parsegen.config.parser import ParsegenCfgParser
        assert isinstance(meta_build_path, str)
        assert isinstance(config_dir_obj, ConfigDir)
        assert isinstance(parsegen_config, ParsegenCfgParser)

        # Initialize the BaseStager
        BaseStager.__init__(self)

        self.config_dir_obj = config_dir_obj

        # Create internal attributes
        self._meta_build_path = meta_build_path

        # Validate that the meta_build path exists
        meta_build_path = c_path.normalize(meta_build_path)
        if not c_path.validate_dir(meta_build_path):
            raise RuntimeError('No read access to the meta build path: ' +
                               meta_build_path)

        # Get the meta lib module from the metabuild
        meta_info = self.get_meta_info(meta_build_path)

        # List of sign ids searched
        sign_ids_searched = []

        # Create the image info list based on the meta data
        for sign_id, chipset, image_src_path, image_dest_path, err_code in self.get_image_info_from_meta(
                meta_info):

            # Filer on the sign id
            if sign_id_list and sign_id not in sign_id_list:
                continue
            else:
                sign_ids_searched.append(sign_id)

            # If there is an error, continue
            if err_code is not None:
                continue

            try:
                img_config_parser = self.get_image_config_parser(chipset)

                # Validate the sign_id
                sign_id = self._get_sign_id(
                    img_config_parser,
                    os.path.basename(image_src_path.image_path), sign_id)

                # Get the config block for the sign id
                img_config_block = img_config_parser.get_config_for_sign_id(
                    sign_id)

                # Create the one image info object
                image_info = ImageInfo('', sign_id, img_config_block,
                                       img_config_parser, parsegen_config)

                # Set the src path
                image_info.src_image = image_src_path
                image_info.image_under_operation = image_info.src_image.image_path

                # Set the dest path
                image_info.dest_image = image_dest_path

                # Check if the dest image name should be overriden
                if img_config_block.output_file_name is not None:
                    image_info.dest_image.image_name = img_config_block.output_file_name

                # Put the image info object into the list
                self._image_info_list.append(image_info)

            except Exception as e:
                logger.error(str(e))

        if sign_id_list and set(sign_id_list) != set(sign_ids_searched):
            raise RuntimeError(
                'Unknown sign id provided: ' +
                ', '.join(set(sign_id_list) - set(sign_ids_searched)))

        if not self._image_info_list:
            raise RuntimeError('No images found from the meta build.')
    def __init__(self, meta_build_path, config_dir_obj, sign_id_list=[]):
        assert isinstance(meta_build_path, str)
        assert isinstance(config_dir_obj, ConfigDir)

        # Initialize the BaseStager
        BaseStager.__init__(self)

        self.config_dir_obj = config_dir_obj

        # Create internal attributes
        self._meta_build_path = meta_build_path

        # Validate that the meta_build path exists
        meta_build_path = c_path.normalize(meta_build_path)
        if not c_path.validate_dir(meta_build_path):
            raise RuntimeError('No read access to the meta build path: ' + meta_build_path)

        # Get the meta lib module from the metabuild
        meta_info = self.get_meta_info(meta_build_path)

        # Create the image info list based on the meta data
        for sign_id, chipset, image_src_path, image_dest_path in self.get_image_info_from_meta(meta_info):
            # Filer on the sign id
            if sign_id_list:
                if sign_id not in sign_id_list:
                    continue

            try:
                img_config_parser = self.get_image_config_parser(chipset)

                # Validate the sign_id
                sign_id = self._get_sign_id(img_config_parser,
                                            os.path.basename(image_src_path.image_path),
                                            sign_id)

                # Get the config block for the sign id
                img_config_block = img_config_parser.get_config_for_sign_id(sign_id)

                # Create the one image info object
                image_info = ImageInfo('', sign_id, img_config_block,
                                       img_config_parser)

                # Set the src path
                image_info.src_image = image_src_path
                image_info.image_under_operation = image_info.src_image.image_path

                # Set the dest path
                image_info.dest_image = image_dest_path

                # Check if the dest image name should be overriden
                if img_config_block.output_file_name is not None:
                    image_info.dest_image.image_name = img_config_block.output_file_name

                # Put the image info object into the list
                self._image_info_list.append(image_info)

            except Exception as e:
                logger.error(str(e))

        if not self._image_info_list:
            raise RuntimeError('No images found from the meta build.')