Beispiel #1
0
def Emerge(packages,
           sysroot,
           with_deps=True,
           rebuild_deps=True,
           use_binary=True,
           jobs=None,
           debug_output=False):
    """Emerge the specified |packages|.

  Args:
    packages: List of packages to emerge.
    sysroot: Path to the sysroot in which to emerge.
    with_deps: Whether to include dependencies.
    rebuild_deps: Whether to rebuild dependencies.
    use_binary: Whether to use binary packages.
    jobs: Number of jobs to run in parallel.
    debug_output: Emit debug level output.

  Raises:
    cros_build_lib.RunCommandError: If emerge returns an error.
  """
    cros_build_lib.AssertInsideChroot()
    if not packages:
        raise ValueError('No packages provided')

    cmd = GetEmergeCommand(sysroot)
    cmd.append('-uNv')

    modified_packages = workon.ListModifiedWorkonPackages(
        sysroot_lib.Sysroot(sysroot))
    if modified_packages:
        mod_pkg_list = ' '.join(modified_packages)
        cmd += [
            '--reinstall-atoms=' + mod_pkg_list,
            '--usepkg-exclude=' + mod_pkg_list
        ]

    cmd.append('--deep' if with_deps else '--nodeps')
    if use_binary:
        cmd += ['-g', '--with-bdeps=y']
        if sysroot == '/':
            # Only update toolchains in the chroot when binpkgs are available. The
            # toolchain rollout process only takes place when the chromiumos sdk
            # builder finishes a successful build and pushes out binpkgs.
            cmd += ['--useoldpkg-atoms=%s' % ' '.join(_GetToolchainPackages())]

    if rebuild_deps:
        cmd.append('--rebuild-if-unbuilt')
    if jobs:
        cmd.append('--jobs=%d' % jobs)
    if debug_output:
        cmd.append('--show-output')

    cros_build_lib.SudoRunCommand(cmd + packages)
Beispiel #2
0
    def testListModifiedWorkonPackages(self):
        """Test that no ebuild breaks cros_list_modified_packages"""

        # A hook to set the "all_opt" parameter when calling ListWorkonPackages
        _ListWorkonPackagesPatch = \
          functools.partial(cros_list_modified_packages.ListWorkonPackages,
                            all_opt=True)

        with self.PatchObject(cros_list_modified_packages,
                              'ListWorkonPackages',
                              side_effect=_ListWorkonPackagesPatch):
            # ListModifiedWorkonPackages returns a generator object and doesn't
            # actually do any work automatically. We have to extract the elements
            # from it to get it to exercise the code, and we can do that by turning
            # it into a list.
            list(
                cros_list_modified_packages.ListModifiedWorkonPackages(
                    sysroot=sysroot_lib.Sysroot('/')))
Beispiel #3
0
 def _ListModifiedPackages(self, board):
     return list(workon.ListModifiedWorkonPackages(board, board is None))