From d9c3209d449b1ba1c46930e30440b77161b21eff Mon Sep 17 00:00:00 2001 From: Zac Medico Date: Fri, 28 Mar 2008 11:11:12 +0000 Subject: [PATCH] Bug #211554 - Replace references to config["USE"] with references to config["PORTAGE_USE"] (which is filtered for intersection with IUSE) so that dependency calculations at installation time are consistent with those at depclean time. (trunk r9391:9393) svn path=/main/branches/2.1.2/; revision=9540 --- bin/emerge | 19 ++++---- pym/portage.py | 123 +++++++++++++++++++++++++------------------------ 2 files changed, 73 insertions(+), 69 deletions(-) diff --git a/bin/emerge b/bin/emerge index a7c843b95..e1c181aa9 100755 --- a/bin/emerge +++ b/bin/emerge @@ -1218,7 +1218,7 @@ def get_mask_info(root_config, cpv, pkgsettings, metadata = None if metadata and not built: pkgsettings.setcpv(cpv, mydb=metadata) - metadata["USE"] = pkgsettings.get("USE", "") + metadata["USE"] = pkgsettings["PORTAGE_USE"] if metadata is None: mreasons = ["corruption"] else: @@ -1667,7 +1667,7 @@ class depgraph: mydbapi.aux_get(mykey, self._mydbapi_keys))) if mytype == "ebuild": pkgsettings.setcpv(mykey, mydb=portdb) - metadata["USE"] = pkgsettings["USE"] + metadata["USE"] = pkgsettings["PORTAGE_USE"] myuse = metadata["USE"].split() if not arg and myroot == self.target_root: @@ -2413,7 +2413,7 @@ class depgraph: pkgsettings.setcpv(myeb, mydb=mydb) else: pkgsettings.setcpv(myeb_pkg, mydb=mydb) - now_use = pkgsettings["USE"].split() + now_use = pkgsettings["PORTAGE_USE"].split() forced_flags = set() forced_flags.update(pkgsettings.useforce) forced_flags.update(pkgsettings.usemask) @@ -2434,7 +2434,7 @@ class depgraph: metadata = dict(izip(self._mydbapi_keys, portdb.aux_get(myeb, self._mydbapi_keys))) pkgsettings.setcpv(myeb, mydb=portdb) - metadata["USE"] = pkgsettings["USE"] + metadata["USE"] = pkgsettings["PORTAGE_USE"] matched_packages.append( (["ebuild", myroot, myeb], metadata)) @@ -3367,7 +3367,7 @@ class depgraph: repo_path_real = os.path.dirname(os.path.dirname( os.path.dirname(ebuild_path))) pkgsettings.setcpv(pkg_key, mydb=mydbapi) - metadata["USE"] = pkgsettings["USE"] + metadata["USE"] = pkgsettings["PORTAGE_USE"] else: repo_path_real = portdb.getRepositoryPath(repo_name) pkg_use = metadata["USE"].split() @@ -3914,7 +3914,8 @@ class depgraph: if pkg_type == "ebuild": pkgsettings = self.pkgsettings[myroot] pkgsettings.setcpv(pkg_key, mydb=fakedb[myroot]) - fakedb[myroot].aux_update(pkg_key, {"USE":pkgsettings["USE"]}) + fakedb[myroot].aux_update(pkg_key, + {"USE":pkgsettings["PORTAGE_USE"]}) self.spinner.update() class RepoDisplay(object): @@ -4202,7 +4203,7 @@ class MergeTask(object): metadata.update(izip(metadata_keys, mydbapi.aux_get(pkg_key, metadata_keys))) pkgsettings.setcpv(pkg_key, mydb=mydbapi) - metadata["USE"] = pkgsettings["USE"] + metadata["USE"] = pkgsettings["PORTAGE_USE"] else: if pkg_type == "binary": mydbapi = bindb @@ -5864,8 +5865,8 @@ def action_info(settings, trees, myopts, myfiles): if portdb.cpv_exists(pkg): mydb = portdb pkgsettings.setcpv(pkg, mydb=mydb) - if valuesmap["IUSE"].intersection(pkgsettings["USE"].split()) != \ - valuesmap["USE"]: + if valuesmap["IUSE"].intersection( + pkgsettings["PORTAGE_USE"].split()) != valuesmap["USE"]: diff_values["USE"] = valuesmap["USE"] # If a difference was found, print the info for # this package. diff --git a/pym/portage.py b/pym/portage.py index 4b3df78eb..ab4b2eb4d 100644 --- a/pym/portage.py +++ b/pym/portage.py @@ -1429,7 +1429,7 @@ class config: # Blacklist vars that could interfere with portage internals. for blacklisted in "CATEGORY", "PKGUSE", "PORTAGE_CONFIGROOT", \ - "ROOT": + "PORTAGE_IUSE", "PORTAGE_USE", "ROOT": for cfg in self.lookuplist: cfg.pop(blacklisted, None) del blacklisted, cfg @@ -1874,6 +1874,7 @@ class config: self.modifying() if self.mycpv == mycpv: return + ebuild_phase = self.get("EBUILD_PHASE") has_changed = False self.mycpv = mycpv cp = dep_getkey(mycpv) @@ -1950,7 +1951,7 @@ class config: if "test" in self.features: test_use_changed = \ bool(re.search(r'(^|\s)[-+]?test(\s|$)', iuse)) != \ - ("test" in self.get("PORTAGE_USE","").split()) + ("test" in self["USE"].split()) if self.get("EBUILD_PHASE") or \ self._use_wildcards or \ test_use_changed: @@ -1962,6 +1963,63 @@ class config: if has_changed: self.reset(keeping_pkg=1,use_cache=use_cache) + # Filter out USE flags that aren't part of IUSE. This has to + # be done for every setcpv() call since practically every + # package has different IUSE. Some flags are considered to + # be implicit members of IUSE: + # + # * Flags derived from ARCH + # * Flags derived from USE_EXPAND_HIDDEN variables + # * Masked flags, such as those from {,package}use.mask + # * Forced flags, such as those from {,package}use.force + # * build and bootstrap flags used by bootstrap.sh + + usesplit = self["USE"].split() + iuse_implicit = set(x.lstrip("+-") for x in iuse.split()) + + # Flags derived from ARCH. + arch = self.configdict["defaults"].get("ARCH") + if arch: + iuse_implicit.add(arch) + iuse_implicit.update(self.get("PORTAGE_ARCHLIST", "").split()) + + # Flags derived from USE_EXPAND_HIDDEN variables + # such as ELIBC, KERNEL, and USERLAND. + use_expand_hidden = self.get("USE_EXPAND_HIDDEN", "").split() + use_expand_hidden_raw = use_expand_hidden + if use_expand_hidden: + use_expand_hidden = re.compile("^(%s)_.*" % \ + ("|".join(x.lower() for x in use_expand_hidden))) + for x in usesplit: + if use_expand_hidden.match(x): + iuse_implicit.add(x) + + # Flags that have been masked or forced. + iuse_implicit.update(self.usemask) + iuse_implicit.update(self.useforce) + + # build and bootstrap flags used by bootstrap.sh + iuse_implicit.add("build") + iuse_implicit.add("bootstrap") + + if ebuild_phase: + iuse_grep = iuse_implicit.copy() + if use_expand_hidden_raw: + for x in use_expand_hidden_raw: + iuse_grep.add(x.lower() + "_.*") + if iuse_grep: + iuse_grep = "^(%s)$" % "|".join(sorted(iuse_grep)) + else: + iuse_grep = "" + self.configdict["pkg"]["PORTAGE_IUSE"] = iuse_grep + + # Filtered for the ebuild environment. Store this in a separate + # attribute since we still want to be able to see global USE + # settings for things like emerge --info. + self.configdict["pkg"]["PORTAGE_USE"] = " ".join(sorted( + x for x in usesplit if \ + x in iuse_implicit)) + def _getMaskAtom(self, cpv, metadata): """ Take a package and return a matching package.mask atom, or None if no @@ -2109,7 +2167,7 @@ class config: return if isinstance(mydbapi, portdbapi): self.setcpv(mycpv, mydb=mydbapi) - myuse = self["USE"] + myuse = self["PORTAGE_USE"] elif isinstance(mydbapi, dict): myuse = mydbapi["USE"] else: @@ -2395,64 +2453,9 @@ class config: if arch and arch not in usesplit: usesplit.append(arch) - # Filter out USE flags that aren't part of IUSE. Some - # flags are considered to be implicit members of IUSE: - # - # * Flags derived from ARCH - # * Flags derived from USE_EXPAND_HIDDEN variables - # * Masked flags, such as those from {,package}use.mask - # * Forced flags, such as those from {,package}use.force - # * build and bootstrap flags used by bootstrap.sh - - # Do this even when there's no package since setcpv() can - # optimize away regenerate() calls. - iuse_implicit = set(iuse) - - # Flags derived from ARCH. - if arch: - iuse_implicit.add(arch) - iuse_implicit.update(self.get("PORTAGE_ARCHLIST", "").split()) - - # Flags derived from USE_EXPAND_HIDDEN variables - # such as ELIBC, KERNEL, and USERLAND. - use_expand_hidden = self.get("USE_EXPAND_HIDDEN", "").split() - use_expand_hidden_raw = use_expand_hidden - if use_expand_hidden: - use_expand_hidden = re.compile("^(%s)_.*" % \ - ("|".join(x.lower() for x in use_expand_hidden))) - for x in usesplit: - if use_expand_hidden.match(x): - iuse_implicit.add(x) - - # Flags that have been masked or forced. - iuse_implicit.update(self.usemask) - iuse_implicit.update(self.useforce) - - # build and bootstrap flags used by bootstrap.sh - iuse_implicit.add("build") - iuse_implicit.add("bootstrap") - - iuse_grep = iuse_implicit.copy() - if use_expand_hidden_raw: - for x in use_expand_hidden_raw: - iuse_grep.add(x.lower() + "_.*") - if iuse_grep: - iuse_grep = "^(%s)$" % "|".join(sorted(iuse_grep)) - else: - iuse_grep = "" - self["PORTAGE_IUSE"] = iuse_grep - usesplit = [x for x in usesplit if \ x not in self.usemask] - # Filtered for the ebuild environment. Store this in a separate - # attribute since we still want to be able to see global USE - # settings for things like emerge --info. - self["PORTAGE_USE"] = " ".join(sorted( - x for x in usesplit if \ - x in iuse_implicit)) - self.backup_changes("PORTAGE_USE") - usesplit.sort() self.configlist[-1]["USE"]= " ".join(usesplit) @@ -2654,7 +2657,7 @@ class config: mydict[k] = v # Filtered by IUSE and implicit IUSE. - mydict["USE"] = self["PORTAGE_USE"] + mydict["USE"] = self.get("PORTAGE_USE", "") # sandbox's bashrc sources /etc/profile which unsets ROOTPATH, # so we have to back it up and restore it. @@ -5372,7 +5375,7 @@ def dep_check(depstring, mydbapi, mysettings, use="yes", mode=None, myuse=None, if use=="yes": if myuse is None: #default behavior - myusesplit = mysettings["USE"].split() + myusesplit = mysettings["PORTAGE_USE"].split() else: myusesplit = myuse # We've been given useflags to use. -- 2.26.2