Fix --onlydeps flag.

When --onlydeps is specified, we don't want to merge packages that were
specified on the command-line. Previously, it threw an exception in this
case because it couldn't find the command-line packages in the list of
installed packages.

TEST=Run ./parallel_emerge --onlydeps autotest, and make sure it
     doesn't crash.
     Run ./parallel_emerge --board=x86-generic  -po chromeos power_manager and make sure it does emerge power_manager, and doesn't crash.
BUG=none

Review URL: http://codereview.chromium.org/2868094
This commit is contained in:
David James 2010-08-04 17:21:12 -07:00
parent 1365cf79ba
commit 56e08b2424

View File

@ -664,16 +664,35 @@ class DepGraphGenerator(object):
def RemoveInstalledPackages():
"""Remove installed packages, propagating dependencies."""
# If we're not in selective mode, the packages on the command line are
# not optional.
# If we're in non-selective mode, the packages specified on the command
# line are generally mandatory.
#
# There are a few exceptions to this rule:
# 1. If the package isn't getting installed because it's in
# package.provided, it's not mandatory.
# 2. If the package isn't getting installed because we're in --onlydeps
# mode, it's not mandatory either.
if "--selective" in emerge.opts:
selective = emerge.opts["--selective"] != "n"
else:
selective = "--noreplace" in emerge.opts or "--update" in emerge.opts
onlydeps = "--onlydeps" in emerge.opts
if not selective:
for pkg in emerge.cmdline_packages:
# If the package specified on the command-line is in our install
# list, mark it as non-optional.
found = False
for db_pkg in final_db.match_pkgs(pkg):
deps_info[db_pkg.cpv]["optional"] = False
this_pkg = deps_info.get(db_pkg.cpv)
if this_pkg:
found = True
this_pkg["optional"] = False
# We didn't find the package in our final db. If we're not in
# --onlydeps mode, this likely means that the package was specified
# in package.provided.
if not found and not onlydeps and "--verbose" in emerge.opts:
print "Skipping %s (is it in package.provided?)" % pkg
# Schedule packages that aren't on the install list for removal
rm_pkgs = set(deps_map.keys()) - set(deps_info.keys())