def _GetImageParams(image): """Returns the parameters of a single DLC image. Args: image: The input image. Returns: Same values as _GetDlcImageParams() """ mount_point = os.path.join(self.work_dir, 'mount-point') osutils.MountDir(image, mount_point, mount_opts=('ro', )) try: lsb_release = utils.ReadLsbRelease(mount_point) finally: osutils.UmountDir(mount_point) dlc_id = lsb_release[build_dlc.DLC_ID_KEY] dlc_package = lsb_release[build_dlc.DLC_PACKAGE_KEY] appid = lsb_release[build_dlc.DLC_APPID_KEY] if gspaths.IsDLCImage(image): if dlc_id != image.dlc_id: raise Error( 'The DLC ID (%s) inferred from the file path does not ' 'match the one (%s) from the lsb-release.' % (image.dlc_id, dlc_id)) if dlc_package != image.dlc_package: raise Error( 'The DLC package (%s) inferred from the file path ' 'does not match the one (%s) from the lsb-release.' % (image.dlc_package, dlc_package)) return dlc_id, dlc_package, appid
def _ShouldSign(self, image): """Whether to sign the image. Args: image: an image object. Returns: True if to sign the image, false if not to sign the image. """ return gspaths.IsImage(image) or gspaths.IsDLCImage(image)
def _DefaultPayloadUri(payload, random_str=None): """Compute the default output URI for a payload. For a glob that matches all potential URIs for this payload, pass in a random_str of '*'. Args: payload: gspaths.Payload instance. random_str: A hook to force a specific random_str. None means generate it. Returns: Default URI for the payload. """ src_version = None if payload.src_image: src_version = payload.src_image.build.version if gspaths.IsDLCImage(payload.tgt_image): # Signed DLC payload. return gspaths.ChromeosReleases.DLCPayloadUri( payload.build, random_str=random_str, dlc_id=payload.tgt_image.dlc_id, dlc_package=payload.tgt_image.dlc_package, image_channel=payload.tgt_image.image_channel, image_version=payload.tgt_image.image_version, src_version=src_version) elif gspaths.IsImage(payload.tgt_image): # Signed payload. return gspaths.ChromeosReleases.PayloadUri( payload.build, random_str=random_str, key=payload.tgt_image.key, image_channel=payload.tgt_image.image_channel, image_version=payload.tgt_image.image_version, src_version=src_version) elif gspaths.IsUnsignedImageArchive(payload.tgt_image): # Unsigned test payload. return gspaths.ChromeosReleases.PayloadUri(payload.build, random_str=random_str, src_version=src_version) else: raise Error('Unknown image type %s' % type(payload.tgt_image))