Exemplo n.º 1
0
    def _GeneratePayloads(self, tempdir):
        """Generate the update payloads we require.

    Args:
      tempdir: Temporary Directory to store the generated payloads.
    """
        dev_server_wrapper.GetUpdatePayloadsFromLocalPath(
            self.options.image, tempdir, static_dir=flash.DEVSERVER_STATIC_DIR)
        rootfs_payload = os.path.join(tempdir,
                                      dev_server_wrapper.ROOTFS_FILENAME)
        # Devservers will look for a file named *_full_*.
        shutil.move(rootfs_payload, os.path.join(tempdir,
                                                 'update_full_dev.bin'))
Exemplo n.º 2
0
    def GetPayloadDir(self, device):
        """Get directory of payload for update.

    This method is used to obtain the directory of payload for cros-flash. The
    given path 'self.image' is passed in when initializing RemoteDeviceUpdater.

    If self.image is a directory, we directly use the provided update payload(s)
    in this directory.

    If self.image is an image, let devserver access it and generate payloads.

    If not in the above cases, let devserver first obtain the image path. Then
    devserver will access the image and generate payloads.

    Args:
      device: A ChromiumOSDevice object.

    Returns:
      A string payload_dir, that represents the payload directory.
    """
        payload_dir = self.tempdir

        if os.path.isdir(self.image):
            # The given path is a directory.
            payload_dir = self.image
            logging.info('Using provided payloads in %s', payload_dir)
        elif os.path.isfile(self.image):
            # The given path is an image.
            logging.info('Using image %s', self.image)
            ds_wrapper.GetUpdatePayloadsFromLocalPath(
                self.image,
                payload_dir,
                src_image_to_delta=self.src_image_to_delta,
                static_dir=DEVSERVER_STATIC_DIR)
        else:
            self.board = cros_build_lib.GetBoard(device_board=device.board,
                                                 override_board=self.board,
                                                 force=self.yes)
            if not self.board:
                raise FlashError('No board identified')

            if not self.force and self.board != device.board:
                # If a board was specified, it must be compatible with the device.
                raise FlashError('Device (%s) is incompatible with board %s' %
                                 (device.board, self.board))

            logging.info('Board is %s', self.board)

            # Translate the xbuddy path to get the exact image to use.
            translated_path, resolved_path = ds_wrapper.GetImagePathWithXbuddy(
                self.image,
                self.board,
                static_dir=DEVSERVER_STATIC_DIR,
                lookup_only=True)
            logging.info('Using image %s', translated_path)
            # Convert the translated path to be used in the update request.
            image_path = ds_wrapper.ConvertTranslatedPath(
                resolved_path, translated_path)

            # Launch a local devserver to generate/serve update payloads.
            ds_wrapper.GetUpdatePayloads(
                image_path,
                payload_dir,
                board=self.board,
                src_image_to_delta=self.src_image_to_delta,
                static_dir=DEVSERVER_STATIC_DIR)

        return payload_dir