diff options
-rwxr-xr-x | bin/ebuild.sh | 4 | ||||
-rw-r--r-- | pym/portage/package/ebuild/_config/special_env_vars.py | 2 | ||||
-rw-r--r-- | pym/portage/package/ebuild/_ipc/QueryCommand.py | 11 | ||||
-rw-r--r-- | pym/portage/package/ebuild/config.py | 15 |
4 files changed, 23 insertions, 9 deletions
diff --git a/bin/ebuild.sh b/bin/ebuild.sh index 1428ac8d2..b3b23aabb 100755 --- a/bin/ebuild.sh +++ b/bin/ebuild.sh @@ -166,7 +166,7 @@ has_version() { fi if [[ -n $PORTAGE_IPC_DAEMON ]] ; then - "$PORTAGE_BIN_PATH"/ebuild-ipc has_version "$ROOT" "$1" "$USE" + "$PORTAGE_BIN_PATH"/ebuild-ipc has_version "$ROOT" "$1" return $? fi @@ -209,7 +209,7 @@ best_version() { fi if [[ -n $PORTAGE_IPC_DAEMON ]] ; then - "$PORTAGE_BIN_PATH"/ebuild-ipc best_version "$ROOT" "$1" "$USE" + "$PORTAGE_BIN_PATH"/ebuild-ipc best_version "$ROOT" "$1" return $? fi diff --git a/pym/portage/package/ebuild/_config/special_env_vars.py b/pym/portage/package/ebuild/_config/special_env_vars.py index 4a29b1446..4ad4a0e9a 100644 --- a/pym/portage/package/ebuild/_config/special_env_vars.py +++ b/pym/portage/package/ebuild/_config/special_env_vars.py @@ -13,7 +13,7 @@ env_blacklist = frozenset(( "EBUILD_PHASE", "ED", "EMERGE_FROM", "EPREFIX", "EROOT", "HOMEPAGE", "INHERITED", "IUSE", "KEYWORDS", "LICENSE", "PDEPEND", "PF", "PKGUSE", - "PORTAGE_CONFIGROOT", "PORTAGE_IUSE", + "PORTAGE_BUILT_USE", "PORTAGE_CONFIGROOT", "PORTAGE_IUSE", "PORTAGE_NONFATAL", "PORTAGE_REPO_NAME", "PORTAGE_USE", "PROPERTIES", "PROVIDE", "RDEPEND", "RESTRICT", "ROOT", "SLOT", "SRC_URI" diff --git a/pym/portage/package/ebuild/_ipc/QueryCommand.py b/pym/portage/package/ebuild/_ipc/QueryCommand.py index ec52e400f..1afe886aa 100644 --- a/pym/portage/package/ebuild/_ipc/QueryCommand.py +++ b/pym/portage/package/ebuild/_ipc/QueryCommand.py @@ -24,18 +24,17 @@ class QueryCommand(IpcCommand): @returns: tuple of (stdout, stderr, returncode) """ - # Note that $USE is passed via IPC in order to ensure that - # we have the correct value for built/installed packages, - # since the config class doesn't currently provide a way - # to access built/installed $USE that would work in all - # possible scenarios. - cmd, root, atom, use = argv + cmd, root, atom = argv try: atom = Atom(atom) except InvalidAtom: return ('', 'invalid atom: %s\n' % atom, 2) + use = self.settings.get('PORTAGE_BUILT_USE') + if use is None: + use = self.settings['PORTAGE_USE'] + use = frozenset(use.split()) atom = atom.evaluate_conditionals(use) diff --git a/pym/portage/package/ebuild/config.py b/pym/portage/package/ebuild/config.py index cf2586f6c..443a735eb 100644 --- a/pym/portage/package/ebuild/config.py +++ b/pym/portage/package/ebuild/config.py @@ -1147,8 +1147,20 @@ class config(object): pkg_configdict.addLazySingleton(k, mydb.__getitem__, k) else: + # When calling dbapi.aux_get(), grab USE for built/installed + # packages since we want to save it PORTAGE_BUILT_USE for + # evaluating conditional USE deps in atoms passed via IPC to + # helpers like has_version and best_version. + aux_keys = list(aux_keys) + aux_keys.append('USE') for k, v in zip(aux_keys, mydb.aux_get(self.mycpv, aux_keys)): pkg_configdict[k] = v + built_use = frozenset(pkg_configdict.pop('USE').split()) + if not built_use: + # Empty USE means this dbapi instance does not contain + # built packages. + built_use = None + repository = pkg_configdict.pop("repository", None) if repository is not None: pkg_configdict["PORTAGE_REPO_NAME"] = repository @@ -1258,6 +1270,9 @@ class config(object): env_configdict.addLazySingleton('PORTAGE_RESTRICT', lazy_vars.__getitem__, 'PORTAGE_RESTRICT') + if built_use is not None: + pkg_configdict['PORTAGE_BUILT_USE'] = ' '.join(built_use) + # If reset() has not been called, it's safe to return # early if IUSE has not changed. if not has_changed and previous_iuse == iuse: |