Fix bug 10466: parallel_emerge use flag calculation favors local binhost.

When we merge a package, we need to keep track of the use flags associated with
the package, so that we don't merge a package with the wrong use flags.

In some cases, there might be two copies of the same binary package: One local
copy, and one remote copy. Our current logic for grabbing the use flags favors
the local copy. But Portage itself favors the remote copy. To reconcile this
difference, we just reuse the logic from Portage here.

BUG=chromium-os:10466
TEST=
  1. Run build_packages with a correct binhost
  2. Switch to a binhost with different use flags for some of the packages, but the same version number and package name.
  3. Run EXTRA_BOARD_FLAGS=--emptytree build_packages
  4. Run build_image

Also test #3 with --oldchromebinary.

Change-Id: I9b917d8b8d902e0581d5a5d23ad20940930b114a

Review URL: http://codereview.chromium.org/6055004
This commit is contained in:
David James 2011-01-04 15:15:02 -08:00
parent 50744ba57c
commit 999e09f5c4

View File

@ -1192,41 +1192,23 @@ class DepGraphGenerator(object):
"""Update packages that can use prebuilts to do so.""" """Update packages that can use prebuilts to do so."""
start = time.time() start = time.time()
# The bintree is the database of binary packages. By default, it's
# empty.
bintree = emerge.trees[root]["bintree"]
bindb = bintree.dbapi
root_config = emerge.root_config
pkgsettings = emerge.depgraph._frozen_config.pkgsettings[root]
prebuilt_pkgs = {}
# Populate the DB with packages
bintree.populate("--getbinpkg" in emerge.opts,
"--getbinpkgonly" in emerge.opts)
# Build list of prebuilt packages # Build list of prebuilt packages
prebuilt_pkgs = {}
for pkg, info in deps_map.iteritems(): for pkg, info in deps_map.iteritems():
if info and info["action"] == "merge": if info and info["action"] == "merge":
if (not info["force_remote_binary"] and info["mandatory_source"] or if (not info["force_remote_binary"] and info["mandatory_source"] or
"--usepkgonly" not in emerge.opts and pkg not in remote_pkgs): "--usepkgonly" not in emerge.opts and pkg not in remote_pkgs):
continue continue
db_keys = list(bindb._aux_cache_keys) db_pkg = emerge.depgraph._pkg(pkg, "binary", emerge.root_config)
try: if info["force_remote_binary"]:
db_vals = bindb.aux_get(pkg, db_keys + ["MTIME"]) # Undo our earlier hacks to the use flags so that the use flags
except KeyError: # display correctly.
# No binary package db_pkg.use.enabled = db_pkg.metadata["USE"].split()
continue
mtime = int(db_vals.pop() or 0)
metadata = zip(db_keys, db_vals)
db_pkg = Package(built=True, cpv=pkg, installed=False,
metadata=metadata, onlydeps=False, mtime=mtime,
operation="merge", root_config=root_config,
type_name="binary")
prebuilt_pkgs[pkg] = db_pkg prebuilt_pkgs[pkg] = db_pkg
# Calculate what packages need to be rebuilt due to changes in use flags. # Calculate what packages need to be rebuilt due to changes in use flags.
pkgsettings = emerge.depgraph._frozen_config.pkgsettings[root]
for pkg, db_pkg in prebuilt_pkgs.iteritems(): for pkg, db_pkg in prebuilt_pkgs.iteritems():
if not self.CheckUseFlags(pkgsettings, db_pkg, self.package_db[pkg]): if not self.CheckUseFlags(pkgsettings, db_pkg, self.package_db[pkg]):
MergeChildren(pkg, "mandatory_source") MergeChildren(pkg, "mandatory_source")