Example #1
0
def main(argv):
    opts = ParseArgs(argv)
    if not cros_build_lib.IsInsideChroot():
        raise commandline.ChrootRequiredError()

    if os.geteuid() != 0:
        cros_build_lib.SudoRunCommand(sys.argv, print_cmd=False)
        return

    output = sys.stdout
    if opts.out_file:
        output = open(opts.out_file, 'w')

    sysroot = sysroot_lib.Sysroot(opts.sysroot)
    if opts.command == 'create-wrappers':
        sysroot.CreateAllWrappers(opts.friendlyname)
    elif opts.command == 'generate-config':
        config = sysroot.GenerateBoardConfig(opts.board)

        output.write('\n' + config)
    elif opts.command == 'generate-make-conf':
        output.write('\n' + sysroot.GenerateMakeConf(opts.accepted_licenses))
    elif opts.command == 'generate-binhosts':
        output.write(
            '\n' +
            sysroot.GenerateBinhostConf(opts.chrome_only, opts.local_only))
def main(argv):
  options = ParseArgs(argv)

  if not cros_build_lib.IsInsideChroot():
    raise commandline.ChrootRequiredError()

  if os.geteuid() != 0:
    cros_build_lib.SudoRunCommand(sys.argv)
    return

  # sysroot must have a trailing / as the tree dictionary produced by
  # create_trees in indexed with a trailing /.
  sysroot = cros_build_lib.GetSysroot(options.board) + '/'
  trees = create_trees(target_root=sysroot, config_root=sysroot)

  vartree = trees[sysroot]['vartree']

  cache_dir = os.path.join(path_util.FindCacheDir(),
                           'cros_install_debug_syms-v' + CACHE_VERSION)

  if options.clearcache:
    osutils.RmDir(cache_dir, ignore_missing=True)

  binhost_cache = None
  if options.cachebinhost:
    binhost_cache = cache.DiskCache(cache_dir)

  boto_file = vartree.settings['BOTO_CONFIG']
  if boto_file:
    os.environ['BOTO_CONFIG'] = boto_file

  gs_context = gs.GSContext()
  symbols_mapping = RemoteSymbols(vartree, binhost_cache)

  if options.all:
    to_install = vartree.dbapi.cpv_all()
  else:
    to_install = [GetMatchingCPV(p, vartree.dbapi) for p in options.packages]

  to_install = [p for p in to_install
                if ShouldGetSymbols(p, vartree.dbapi, symbols_mapping)]

  if not to_install:
    logging.info('nothing to do, exit')
    return

  with DebugSymbolsInstaller(vartree, gs_context, sysroot,
                             not options.debug) as installer:
    args = [(p, symbols_mapping[p]) for p in to_install]
    parallel.RunTasksInProcessPool(installer.Install, args,
                                   processes=options.jobs)

  logging.debug('installation done, updating packages index file')
  packages_dir = os.path.join(sysroot, 'packages')
  packages_file = os.path.join(packages_dir, 'Packages')
  # binpkg will set DEBUG_SYMBOLS automatically if it detects the debug symbols
  # in the packages dir.
  pkgindex = binpkg.GrabLocalPackageIndex(packages_dir)
  with open(packages_file, 'w') as p:
    pkgindex.Write(p)
Example #3
0
def main(argv):
    if not cros_build_lib.IsInsideChroot():
        raise commandline.ChrootRequiredError(argv)

    cmd = [
        os.path.join(constants.CHROMITE_BIN_DIR, 'cros_install_debug_syms')
    ] + argv
    if os.geteuid() != 0:
        cros_build_lib.sudo_run(cmd)
        return

    options = ParseArgs(argv)

    # sysroot must have a trailing / as the tree dictionary produced by
    # create_trees in indexed with a trailing /.
    sysroot = cros_build_lib.GetSysroot(options.board) + '/'

    if options.list:
        ListInstallArgs(options, sysroot)
        return

    args = GetInstallArgsList(cmd)

    if not args:
        logging.info('No packages found needing debug symbols.')
        return

    # Partial to simplify the arguments to parallel since the first two are the
    # same for every call.
    partial_install = functools.partial(_InstallOne, sysroot, options.debug)
    pool = multiprocessing.Pool(processes=options.jobs)
    pool.map(partial_install, args)

    logging.debug('installation done, updating packages index file')
    packages_dir = os.path.join(sysroot, 'packages')
    packages_file = os.path.join(packages_dir, 'Packages')
    # binpkg will set DEBUG_SYMBOLS automatically if it detects the debug symbols
    # in the packages dir.
    pkgindex = binpkg.GrabLocalPackageIndex(packages_dir)
    with open(packages_file, 'w') as p:
        pkgindex.Write(p)
Example #4
0
 def raiseChrootRequiredError(_args):
     raise commandline.ChrootRequiredError(self.CMD_ARGS,
                                           self.CHROOT_ARGS)
Example #5
0
 def raiseChrootRequiredError(args):
     raise commandline.ChrootRequiredError(args)