예제 #1
0
    def _DeployCopyPaths(self, host_src_dir, remote_target_dir, copy_paths):
        """Deploy files in copy_paths to device.

    Args:
      host_src_dir: Source dir on the host that files in |copy_paths| are
                    relative to.
      remote_target_dir: Target dir on the remote device that the files in
                         |copy_paths| are copied to.
      copy_paths: A list of chrome_utils.Path of files to be copied.
    """
        with osutils.TempDir(set_global=True) as tempdir:
            self.staging_dir = tempdir
            strip_bin = None
            chrome_util.StageChromeFromBuildDir(self.staging_dir,
                                                host_src_dir,
                                                strip_bin,
                                                copy_paths=copy_paths)

            if self._device.remote.HasRsync():
                self._device.remote.CopyToDevice(
                    '%s/' % os.path.abspath(self.staging_dir),
                    remote_target_dir,
                    mode='rsync',
                    inplace=True,
                    compress=True,
                    debug_level=logging.INFO)
            else:
                self._device.remote.CopyToDevice(
                    '%s/' % os.path.abspath(self.staging_dir),
                    remote_target_dir,
                    mode='scp',
                    debug_level=logging.INFO)
예제 #2
0
def _PrepareStagingDir(options,
                       tempdir,
                       staging_dir,
                       copy_paths=None,
                       chrome_dir=None):
    """Place the necessary files in the staging directory.

  The staging directory is the directory used to rsync the build artifacts over
  to the device.  Only the necessary Chrome build artifacts are put into the
  staging directory.
  """
    if chrome_dir is None:
        chrome_dir = LACROS_DIR if options.lacros else _CHROME_DIR
    osutils.SafeMakedirs(staging_dir)
    os.chmod(staging_dir, 0o755)
    if options.build_dir:
        with _StripBinContext(options) as strip_bin:
            strip_flags = (None if options.strip_flags is None else
                           shlex.split(options.strip_flags))
            chrome_util.StageChromeFromBuildDir(
                staging_dir,
                options.build_dir,
                strip_bin,
                sloppy=options.sloppy,
                gn_args=options.gn_args,
                staging_flags=options.staging_flags,
                strip_flags=strip_flags,
                copy_paths=copy_paths)
    else:
        pkg_path = options.local_pkg_path
        if options.gs_path:
            pkg_path = _FetchChromePackage(options.cache_dir, tempdir,
                                           options.gs_path)

        assert pkg_path
        logging.info('Extracting %s...', pkg_path)
        # Extract only the ./opt/google/chrome contents, directly into the staging
        # dir, collapsing the directory hierarchy.
        if pkg_path[-4:] == '.zip':
            cros_build_lib.dbg_run([
                'unzip', '-X', pkg_path, _ANDROID_DIR_EXTRACT_PATH, '-d',
                staging_dir
            ])
            for filename in glob.glob(
                    os.path.join(staging_dir, 'system/chrome/*')):
                shutil.move(filename, staging_dir)
            osutils.RmDir(os.path.join(staging_dir, 'system'),
                          ignore_missing=True)
        else:
            cros_build_lib.dbg_run([
                'tar', '--strip-components', '4', '--extract',
                '--preserve-permissions', '--file', pkg_path,
                '.%s' % chrome_dir
            ],
                                   cwd=staging_dir)
예제 #3
0
def _PrepareStagingDir(options, tempdir, staging_dir):
    """Place the necessary files in the staging directory.

  The staging directory is the directory used to rsync the build artifacts over
  to the device.  Only the necessary Chrome build artifacts are put into the
  staging directory.
  """
    osutils.SafeMakedirs(staging_dir)
    os.chmod(staging_dir, 0755)
    if options.build_dir:
        with _StripBinContext(options) as strip_bin:
            strip_flags = (None if options.strip_flags is None else
                           shlex.split(options.strip_flags))
            chrome_util.StageChromeFromBuildDir(
                staging_dir,
                options.build_dir,
                strip_bin,
                strict=options.strict,
                sloppy=options.sloppy,
                gyp_defines=options.gyp_defines,
                staging_flags=options.staging_flags,
                strip_flags=strip_flags)
    else:
        pkg_path = options.local_pkg_path
        if options.gs_path:
            pkg_path = _FetchChromePackage(options.cache_dir, tempdir,
                                           options.gs_path)

        assert pkg_path
        logging.info('Extracting %s...', pkg_path)
        # Extract only the ./opt/google/chrome contents, directly into the staging
        # dir, collapsing the directory hierarchy.
        cros_build_lib.DebugRunCommand([
            'tar', '--strip-components', '4', '--extract',
            '--preserve-permissions', '--file', pkg_path,
            '.%s' % _CHROME_DIR
        ],
                                       cwd=staging_dir)
예제 #4
0
def _PrepareStagingDir(options, tempdir, staging_dir):
    """Place the necessary files in the staging directory.

  The staging directory is the directory used to rsync the build artifacts over
  to the device.  Only the necessary Chrome build artifacts are put into the
  staging directory.
  """
    if options.build_dir:
        sdk = cros_chrome_sdk.SDKFetcher(options.cache_dir, options.board)
        components = (sdk.TARGET_TOOLCHAIN_KEY, constants.CHROME_ENV_TAR)
        with sdk.Prepare(components=components) as ctx:
            env_path = os.path.join(ctx.key_map[constants.CHROME_ENV_TAR].path,
                                    constants.CHROME_ENV_FILE)
            strip_bin = osutils.SourceEnvironment(env_path, ['STRIP'])['STRIP']
            strip_bin = os.path.join(
                ctx.key_map[sdk.TARGET_TOOLCHAIN_KEY].path, 'bin',
                os.path.basename(strip_bin))
            chrome_util.StageChromeFromBuildDir(
                staging_dir,
                options.build_dir,
                strip_bin,
                strict=options.strict,
                sloppy=options.sloppy,
                gyp_defines=options.gyp_defines,
                staging_flags=options.staging_flags)
    else:
        pkg_path = options.local_pkg_path
        if options.gs_path:
            pkg_path = _FetchChromePackage(options.cache_dir, tempdir,
                                           options.gs_path)

        assert pkg_path
        logging.info('Extracting %s...', pkg_path)
        osutils.SafeMakedirs(staging_dir)
        cros_build_lib.DebugRunCommand(['tar', '-xpf', pkg_path],
                                       cwd=staging_dir)