Linux Archive

Linux Archive (http://www.linux-archive.org/)
-   Gentoo Portage Developer (http://www.linux-archive.org/gentoo-portage-developer/)
-   -   Implement host dependencies and targetroot USE flag (http://www.linux-archive.org/gentoo-portage-developer/706808-implement-host-dependencies-targetroot-use-flag.html)

Ambroz Bizjak 09-24-2012 01:38 AM

Implement host dependencies and targetroot USE flag
 
This patch implements host dependencies (HDEPEND) and dependencies only in affect when ROOT != / (targetroot USE flag).

See: https://bugs.gentoo.org/show_bug.cgi?id=317337
See: http://thread.gmane.org/gmane.linux.gentoo.devel/80315

This fuctionality is only enabled for EAPI=5-hdepend and should not affect other EAPIs. Changes:

1. HDEPEND dependencies. These are build-time dependencies which have to be installed on the build machine (host, ROOT=/).

2. DEPEND dependencies now always refer to packages in ROOT (target); destination of DEPEND is no longer determined by --root-deps.

3. targetroot USE flag. This is a special USE flag which is automatically enabled when the ROOT for a package is different than /. The primary use case for this is to make a package depend on itself in order to cross-compile. The dependency needs to be conditional otherwise the package may not be installable for ROOT=/.

The flag still needs to be added to IUSE to work. Example:

EAPI=5-hdepend
IUSE="... targetroot ..."
HDEPEND="....
targetroot? ( ~${CATEGORY}/${P} )"

Also, the flag is implemented such that it is not considered by --newuse, which makes sure that emerge from within the target system will not attempt to rebuild every cross-compiled package.

I've tested this patch with packages in my cross-compile overlay which contains some packages using the new support:
http://code.google.com/p/ambro-cross-overlay/


bin/ebuild.sh | 30 +++++++++++++++-----
pym/_emerge/depgraph.py | 55 +++++++++++++++++++++---------------
pym/_emerge/main.py | 1 -
pym/portage/__init__.py | 4 +--
pym/portage/dbapi/bintree.py | 6 ++--
pym/portage/dbapi/porttree.py | 2 +-
pym/portage/dbapi/vartree.py | 1 +
pym/portage/eapi.py | 3 +-
pym/portage/package/ebuild/config.py | 11 +++++++-
9 files changed, 76 insertions(+), 37 deletions(-)

Ambroz Bizjak 09-24-2012 01:38 AM

Implement host dependencies and targetroot USE flag
 
---
bin/ebuild.sh | 30 +++++++++++++++-----
pym/_emerge/depgraph.py | 55 +++++++++++++++++++++---------------
pym/_emerge/main.py | 1 -
pym/portage/__init__.py | 4 +--
pym/portage/dbapi/bintree.py | 6 ++--
pym/portage/dbapi/porttree.py | 2 +-
pym/portage/dbapi/vartree.py | 1 +
pym/portage/eapi.py | 3 +-
pym/portage/package/ebuild/config.py | 11 +++++++-
9 files changed, 76 insertions(+), 37 deletions(-)

diff --git a/bin/ebuild.sh b/bin/ebuild.sh
index 79da2b5..a376d2f 100755
--- a/bin/ebuild.sh
+++ b/bin/ebuild.sh
@@ -215,6 +215,7 @@ inherit() {
local B_DEPEND
local B_RDEPEND
local B_PDEPEND
+ local B_HDEPEND
while [ "$1" ]; do
location="${ECLASSDIR}/${1}.eclass"
olocation=""
@@ -257,20 +258,21 @@ inherit() {
EBUILD_OVERLAY_ECLASSES="${EBUILD_OVERLAY_ECLASSES } ${location}"
fi

- #We need to back up the value of DEPEND and RDEPEND to B_DEPEND and B_RDEPEND
+ #We need to back up the values of *DEPEND to B_*DEPEND
#(if set).. and then restore them after the inherit call.

#turn off glob expansion
set -f

# Retain the old data and restore it later.
- unset B_IUSE B_REQUIRED_USE B_DEPEND B_RDEPEND B_PDEPEND
+ unset B_IUSE B_REQUIRED_USE B_DEPEND B_RDEPEND B_PDEPEND B_HDEPEND
[ "${IUSE+set}" = set ] && B_IUSE="${IUSE}"
[ "${REQUIRED_USE+set}" = set ] && B_REQUIRED_USE="${REQUIRED_USE}"
[ "${DEPEND+set}" = set ] && B_DEPEND="${DEPEND}"
[ "${RDEPEND+set}" = set ] && B_RDEPEND="${RDEPEND}"
[ "${PDEPEND+set}" = set ] && B_PDEPEND="${PDEPEND}"
- unset IUSE REQUIRED_USE DEPEND RDEPEND PDEPEND
+ [ "${HDEPEND+set}" = set ] && B_HDEPEND="${HDEPEND}"
+ unset IUSE REQUIRED_USE DEPEND RDEPEND PDEPEND HDEPEND
#turn on glob expansion
set +f

@@ -286,6 +288,7 @@ inherit() {
[ "${DEPEND+set}" = set ] && E_DEPEND+="${E_DEPEND:+ }${DEPEND}"
[ "${RDEPEND+set}" = set ] && E_RDEPEND+="${E_RDEPEND:+ }${RDEPEND}"
[ "${PDEPEND+set}" = set ] && E_PDEPEND+="${E_PDEPEND:+ }${PDEPEND}"
+ [ "${HDEPEND+set}" = set ] && E_HDEPEND+="${E_HDEPEND:+ }${HDEPEND}"

[ "${B_IUSE+set}" = set ] && IUSE="${B_IUSE}"
[ "${B_IUSE+set}" = set ] || unset IUSE
@@ -302,6 +305,9 @@ inherit() {
[ "${B_PDEPEND+set}" = set ] && PDEPEND="${B_PDEPEND}"
[ "${B_PDEPEND+set}" = set ] || unset PDEPEND

+ [ "${B_HDEPEND+set}" = set ] && HDEPEND="${B_HDEPEND}"
+ [ "${B_HDEPEND+set}" = set ] || unset HDEPEND
+
#turn on glob expansion
set +f

@@ -528,8 +534,9 @@ if ! has "$EBUILD_PHASE" clean cleanrm ; then
# In order to ensure correct interaction between ebuilds and
# eclasses, they need to be unset before this process of
# interaction begins.
- unset EAPI DEPEND RDEPEND PDEPEND INHERITED IUSE REQUIRED_USE
- ECLASS E_IUSE E_REQUIRED_USE E_DEPEND E_RDEPEND E_PDEPEND
+ unset EAPI DEPEND RDEPEND PDEPEND HDEPEND INHERITED IUSE REQUIRED_USE
+ ECLASS E_IUSE E_REQUIRED_USE E_DEPEND E_RDEPEND E_PDEPEND
+ E_HDEPEND

if [[ $PORTAGE_DEBUG != 1 || ${-/x/} != $- ]] ; then
source "$EBUILD" || die "error sourcing ebuild"
@@ -560,9 +567,10 @@ if ! has "$EBUILD_PHASE" clean cleanrm ; then
DEPEND+="${DEPEND:+ }${E_DEPEND}"
RDEPEND+="${RDEPEND:+ }${E_RDEPEND}"
PDEPEND+="${PDEPEND:+ }${E_PDEPEND}"
+ HDEPEND+="${HDEPEND:+ }${E_HDEPEND}"
REQUIRED_USE+="${REQUIRED_USE:+ }${E_REQUIRED_USE}"

- unset ECLASS E_IUSE E_REQUIRED_USE E_DEPEND E_RDEPEND E_PDEPEND
+ unset ECLASS E_IUSE E_REQUIRED_USE E_DEPEND E_RDEPEND E_PDEPEND E_HDEPEND
__INHERITED_QA_CACHE

# alphabetically ordered by $EBUILD_PHASE value
@@ -664,9 +672,17 @@ if [[ $EBUILD_PHASE = depend ]] ; then

auxdbkeys="DEPEND RDEPEND SLOT SRC_URI RESTRICT HOMEPAGE LICENSE
DESCRIPTION KEYWORDS INHERITED IUSE REQUIRED_USE PDEPEND PROVIDE EAPI
- PROPERTIES DEFINED_PHASES UNUSED_05 UNUSED_04
+ PROPERTIES DEFINED_PHASES HDEPEND UNUSED_04
UNUSED_03 UNUSED_02 UNUSED_01"

+ case "$EAPI" in
+ 5-hdepend)
+ ;;
+ *)
+ unset HDEPEND
+ ;;
+ esac
+
# The extra $(echo) commands remove newlines.
if [ -n "${dbkey}" ] ; then
> "${dbkey}"
diff --git a/pym/_emerge/depgraph.py b/pym/_emerge/depgraph.py
index 9da202c..5407077 100644
--- a/pym/_emerge/depgraph.py
+++ b/pym/_emerge/depgraph.py
@@ -504,7 +504,7 @@ class depgraph(object):

pkg_tree_map = RootConfig.pkg_tree_map

- _dep_keys = ["DEPEND", "RDEPEND", "PDEPEND"]
+ _dep_keys = ["DEPEND", "RDEPEND", "PDEPEND", "HDEPEND"]

def __init__(self, settings, trees, myopts, myparams, spinner,
frozen_config=None, backtrack_parameters=BacktrackParameter(), allow_backtracking=False):
@@ -537,10 +537,6 @@ class depgraph(object):
preload_installed_pkgs =
"--nodeps" not in self._frozen_config.myopts

- if self._frozen_config.myopts.get("--root-deps") is not None and
- myroot != self._frozen_config.target_root:
- continue
-
fake_vartree = self._frozen_config.trees[myroot]["vartree"]
if not fake_vartree.dbapi:
# This needs to be called for the first depgraph, but not for
@@ -1685,7 +1681,7 @@ class depgraph(object):
removal_action = "remove" in self._dynamic_config.myparams

edepend={}
- depkeys = ["DEPEND","RDEPEND","PDEPEND"]
+ depkeys = ["DEPEND","RDEPEND","PDEPEND","HDEPEND"]
for k in depkeys:
edepend[k] = metadata[k]

@@ -1713,31 +1709,44 @@ class depgraph(object):
# Removal actions never traverse ignored buildtime
# dependencies, so it's safe to discard them early.
edepend["DEPEND"] = ""
+ edepend["HDEPEND"] = ""
ignore_build_time_deps = True

+ ignore_depend_deps = ignore_build_time_deps
+ ignore_hdepend_deps = ignore_build_time_deps
+
if removal_action:
depend_root = myroot
else:
- depend_root = self._frozen_config._running_root.root
- root_deps = self._frozen_config.myopts.get("--root-deps")
- if root_deps is not None:
- if root_deps is True:
- depend_root = myroot
- elif root_deps == "rdeps":
- ignore_build_time_deps = True
+ if pkg.metadata['EAPI'] == "5-hdepend":
+ depend_root = myroot
+ else:
+ depend_root = self._frozen_config._running_root.root
+ root_deps = self._frozen_config.myopts.get("--root-deps")
+ if root_deps is not None:
+ if root_deps is True:
+ depend_root = myroot
+ elif root_deps == "rdeps":
+ ignore_depend_deps = True

# If rebuild mode is not enabled, it's safe to discard ignored
# build-time dependencies. If you want these deps to be traversed
# in "complete" mode then you need to specify --with-bdeps=y.
- if ignore_build_time_deps and
- not self._rebuild.rebuild:
- edepend["DEPEND"] = ""
-
+ if not self._rebuild.rebuild:
+ if ignore_depend_deps:
+ edepend["DEPEND"] = ""
+ if ignore_hdepend_deps:
+ edepend["HDEPEND"] = ""
+
deps = (
(depend_root, edepend["DEPEND"],
self._priority(buildtime=True,
- optional=(pkg.built or ignore_build_time_deps),
- ignored=ignore_build_time_deps)),
+ optional=(pkg.built or ignore_depend_deps),
+ ignored=ignore_depend_deps)),
+ (self._frozen_config._running_root.root, edepend["HDEPEND"],
+ self._priority(buildtime=True,
+ optional=(pkg.built or ignore_hdepend_deps),
+ ignored=ignore_hdepend_deps)),
(myroot, edepend["RDEPEND"],
self._priority(runtime=True)),
(myroot, edepend["PDEPEND"],
@@ -2838,7 +2847,7 @@ class depgraph(object):
return [pkg.slot_atom for pkg in greedy_pkgs]

blockers = {}
- blocker_dep_keys = ["DEPEND", "PDEPEND", "RDEPEND"]
+ blocker_dep_keys = ["DEPEND", "PDEPEND", "RDEPEND", "HDEPEND"]
for pkg in greedy_pkgs + [highest_pkg]:
dep_str = " ".join(pkg.metadata[k] for k in blocker_dep_keys)
try:
@@ -3099,7 +3108,7 @@ class depgraph(object):

if target_atom is not None and isinstance(node, Package):
affecting_use = set()
- for dep_str in "DEPEND", "RDEPEND", "PDEPEND":
+ for dep_str in "DEPEND", "RDEPEND", "PDEPEND", "HDEPEND":
try:
affecting_use.update(extract_affecting_use(
node.metadata[dep_str], target_atom,
@@ -3183,10 +3192,12 @@ class depgraph(object):
dep_strings.add(node.metadata["DEPEND"])
dep_strings.add(node.metadata["RDEPEND"])
dep_strings.add(node.metadata["PDEPEND"])
+ dep_strings.add(node.metadata["HDEPEND"])
else:
for priority in priorities:
if priority.buildtime:
dep_strings.add(node.metadata["DEPEND"])
+ dep_strings.add(node.metadata["HDEPEND"])
if priority.runtime:
dep_strings.add(node.metadata["RDEPEND"])
if priority.runtime_post:
@@ -4129,7 +4140,7 @@ class depgraph(object):
if pkg not in self._dynamic_config.digraph.nodes:
return False

- for key in "DEPEND", "RDEPEND", "PDEPEND", "LICENSE":
+ for key in "DEPEND", "RDEPEND", "PDEPEND", "HDEPEND", "LICENSE":
dep = pkg.metadata[key]
old_val = set(portage.dep.use_reduce(dep, pkg.use.enabled, is_valid_flag=pkg.iuse.is_valid_flag, flat=True))
new_val = set(portage.dep.use_reduce(dep, new_use, is_valid_flag=pkg.iuse.is_valid_flag, flat=True))
diff --git a/pym/_emerge/main.py b/pym/_emerge/main.py
index d19b795..c3e9646 100644
--- a/pym/_emerge/main.py
+++ b/pym/_emerge/main.py
@@ -977,7 +977,6 @@ def parse_opts(tmpcmdline, silent=False):
"type" : "choice",
"choices" : true_y_or_n
},
-
}

from optparse import OptionParser
diff --git a/pym/portage/__init__.py b/pym/portage/__init__.py
index 30c7e72..695f1ea 100644
--- a/pym/portage/__init__.py
+++ b/pym/portage/__init__.py
@@ -414,7 +414,7 @@ def abssymlink(symlink, target=None):

_doebuild_manifest_exempt_depend = 0

-_testing_eapis = frozenset(["4-python", "4-slot-abi", "5-progress"])
+_testing_eapis = frozenset(["4-python", "4-slot-abi", "5-progress", "5-hdepend"])
_deprecated_eapis = frozenset(["4_pre1", "3_pre2", "3_pre1", "5_pre1", "5_pre2"])

def _eapi_is_deprecated(eapi):
@@ -472,7 +472,7 @@ auxdbkeys = (
'RESTRICT', 'HOMEPAGE', 'LICENSE', 'DESCRIPTION',
'KEYWORDS', 'INHERITED', 'IUSE', 'REQUIRED_USE',
'PDEPEND', 'PROVIDE', 'EAPI',
- 'PROPERTIES', 'DEFINED_PHASES', 'UNUSED_05', 'UNUSED_04',
+ 'PROPERTIES', 'DEFINED_PHASES', 'HDEPEND', 'UNUSED_04',
'UNUSED_03', 'UNUSED_02', 'UNUSED_01',
)
auxdbkeylen=len(auxdbkeys)
diff --git a/pym/portage/dbapi/bintree.py b/pym/portage/dbapi/bintree.py
index 7f09436..921f51d 100644
--- a/pym/portage/dbapi/bintree.py
+++ b/pym/portage/dbapi/bintree.py
@@ -75,6 +75,7 @@ class bindbapi(fakedbapi):
["BUILD_TIME", "CHOST", "DEPEND", "EAPI", "IUSE", "KEYWORDS",
"LICENSE", "PDEPEND", "PROPERTIES", "PROVIDE",
"RDEPEND", "repository", "RESTRICT", "SLOT", "USE", "DEFINED_PHASES",
+ "HDEPEND",
])
self._aux_cache_slot_dict = slot_dict_class(self._aux_cache_keys)
self._aux_cache = {}
@@ -304,11 +305,11 @@ class binarytree(object):
["BUILD_TIME", "CHOST", "DEPEND", "DESCRIPTION", "EAPI",
"IUSE", "KEYWORDS", "LICENSE", "PDEPEND", "PROPERTIES",
"PROVIDE", "RDEPEND", "repository", "SLOT", "USE", "DEFINED_PHASES",
- "BASE_URI"]
+ "BASE_URI", "HDEPEND"]
self._pkgindex_aux_keys = list(self._pkgindex_aux_keys)
self._pkgindex_use_evaluated_keys =
("LICENSE", "RDEPEND", "DEPEND",
- "PDEPEND", "PROPERTIES", "PROVIDE")
+ "PDEPEND", "PROPERTIES", "PROVIDE", "HDEPEND")
self._pkgindex_header_keys = set([
"ACCEPT_KEYWORDS", "ACCEPT_LICENSE",
"ACCEPT_PROPERTIES", "CBUILD",
@@ -330,6 +331,7 @@ class binarytree(object):
"SLOT" : "0",
"USE" : "",
"DEFINED_PHASES" : "",
+ "HDEPEND" : "",
}
self._pkgindex_inherited_keys = ["CHOST", "repository"]

diff --git a/pym/portage/dbapi/porttree.py b/pym/portage/dbapi/porttree.py
index 0cb290f..b6b3d00 100644
--- a/pym/portage/dbapi/porttree.py
+++ b/pym/portage/dbapi/porttree.py
@@ -189,7 +189,7 @@ class portdbapi(dbapi):
self._aux_cache_keys = set(
["DEPEND", "EAPI", "INHERITED", "IUSE", "KEYWORDS", "LICENSE",
"PDEPEND", "PROPERTIES", "PROVIDE", "RDEPEND", "repository",
- "RESTRICT", "SLOT", "DEFINED_PHASES", "REQUIRED_USE"])
+ "RESTRICT", "SLOT", "DEFINED_PHASES", "REQUIRED_USE", "HDEPEND"])

self._aux_cache = {}
self._broken_ebuilds = set()
diff --git a/pym/portage/dbapi/vartree.py b/pym/portage/dbapi/vartree.py
index 7d6d6a8..0822883 100644
--- a/pym/portage/dbapi/vartree.py
+++ b/pym/portage/dbapi/vartree.py
@@ -164,6 +164,7 @@ class vardbapi(dbapi):
"EAPI", "HOMEPAGE", "IUSE", "KEYWORDS",
"LICENSE", "PDEPEND", "PROPERTIES", "PROVIDE", "RDEPEND",
"repository", "RESTRICT" , "SLOT", "USE", "DEFINED_PHASES",
+ "HDEPEND",
])
self._aux_cache_obj = None
self._aux_cache_filename = os.path.join(self._eroot,
diff --git a/pym/portage/eapi.py b/pym/portage/eapi.py
index b12d81d..9452bd2 100644
--- a/pym/portage/eapi.py
+++ b/pym/portage/eapi.py
@@ -85,7 +85,7 @@ def eapi_allows_directories_on_profile_level_and_repos itory_level(eapi):

_eapi_attrs = collections.namedtuple('_eapi_attrs',
'dots_in_PN dots_in_use_flags exports_EBUILD_PHASE_FUNC '
- 'feature_flag_test iuse_defaults iuse_effective '
+ 'feature_flag_test feature_flag_targetroot iuse_defaults iuse_effective '
'repo_deps required_use required_use_at_most_one_of slot_operator slot_deps '
'src_uri_arrows strong_blocks use_deps use_dep_defaults')

@@ -112,6 +112,7 @@ def _get_eapi_attrs(eapi):
dots_in_use_flags = (eapi is None or eapi_allows_dots_in_use_flags(eapi)),
exports_EBUILD_PHASE_FUNC = (eapi is None or eapi_exports_EBUILD_PHASE_FUNC(eapi)),
feature_flag_test = True,
+ feature_flag_targetroot = eapi in ("5-hdepend",),
iuse_defaults = (eapi is None or eapi_has_iuse_defaults(eapi)),
iuse_effective = (eapi is not None and eapi_has_iuse_effective(eapi)),
repo_deps = (eapi is None or eapi_has_repo_deps(eapi)),
diff --git a/pym/portage/package/ebuild/config.py b/pym/portage/package/ebuild/config.py
index 894d14c..f7399bb 100644
--- a/pym/portage/package/ebuild/config.py
+++ b/pym/portage/package/ebuild/config.py
@@ -63,7 +63,7 @@ if sys.hexversion >= 0x3000000:
_feature_flags_cache = {}

def _get_feature_flags(eapi_attrs):
- cache_key = (eapi_attrs.feature_flag_test,)
+ cache_key = (eapi_attrs.feature_flag_test, eapi_attrs.feature_flag_targetroot)
flags = _feature_flags_cache.get(cache_key)
if flags is not None:
return flags
@@ -71,6 +71,8 @@ def _get_feature_flags(eapi_attrs):
flags = []
if eapi_attrs.feature_flag_test:
flags.append("test")
+ if eapi_attrs.feature_flag_targetroot:
+ flags.append("targetroot")

flags = frozenset(flags)
_feature_flags_cache[cache_key] = flags
@@ -1503,6 +1505,13 @@ class config(object):
self.usemask =
frozenset(x for x in self.usemask if x != "test")

+ if ("targetroot" in explicit_iuse or iuse_implicit_match("targetroot")) and
+ eapi == "5-hdepend":
+ if self["ROOT"] != "/":
+ use.add("targetroot")
+ else:
+ use.discard("targetroot")
+
# Allow _* flags from USE_EXPAND wildcards to pass through here.
use.difference_update([x for x in use
if (x not in explicit_iuse and
--
1.7.12

Ambroz Bizjak 09-24-2012 02:06 AM

Implement host dependencies and targetroot USE flag
 
Update: added eapi_has_hdepend() and eapi_has_targetroot() to pym/portage/eapi.py to reduce the number of times "5-hdepend" appears in the code.

bin/ebuild.sh | 30 ++++++++++++++-----
pym/_emerge/depgraph.py | 57 +++++++++++++++++++++---------------
pym/_emerge/main.py | 1 -
pym/portage/__init__.py | 4 +--
pym/portage/dbapi/bintree.py | 6 ++--
pym/portage/dbapi/porttree.py | 2 +-
pym/portage/dbapi/vartree.py | 1 +
pym/portage/eapi.py | 9 +++++-
pym/portage/package/ebuild/config.py | 14 +++++++--
9 files changed, 85 insertions(+), 39 deletions(-)

Ambroz Bizjak 09-24-2012 10:11 AM

Implement host dependencies and targetroot USE flag
 
> case ${EAPI} in
But then, there are two other places in ebuild.sh using "case EAPI" and they both look exactly like mine. Updated patch changes all of them.

Ambroz Bizjak 09-24-2012 10:11 AM

Implement host dependencies and targetroot USE flag
 
---
bin/ebuild.sh | 34 +++++++++++++++------
pym/_emerge/depgraph.py | 57 +++++++++++++++++++++---------------
pym/_emerge/main.py | 1 -
pym/portage/__init__.py | 4 +--
pym/portage/dbapi/bintree.py | 6 ++--
pym/portage/dbapi/porttree.py | 2 +-
pym/portage/dbapi/vartree.py | 1 +
pym/portage/eapi.py | 9 +++++-
pym/portage/package/ebuild/config.py | 14 +++++++--
9 files changed, 87 insertions(+), 41 deletions(-)

diff --git a/bin/ebuild.sh b/bin/ebuild.sh
index 79da2b5..06e2c66 100755
--- a/bin/ebuild.sh
+++ b/bin/ebuild.sh
@@ -215,6 +215,7 @@ inherit() {
local B_DEPEND
local B_RDEPEND
local B_PDEPEND
+ local B_HDEPEND
while [ "$1" ]; do
location="${ECLASSDIR}/${1}.eclass"
olocation=""
@@ -257,20 +258,21 @@ inherit() {
EBUILD_OVERLAY_ECLASSES="${EBUILD_OVERLAY_ECLASSES } ${location}"
fi

- #We need to back up the value of DEPEND and RDEPEND to B_DEPEND and B_RDEPEND
+ #We need to back up the values of *DEPEND to B_*DEPEND
#(if set).. and then restore them after the inherit call.

#turn off glob expansion
set -f

# Retain the old data and restore it later.
- unset B_IUSE B_REQUIRED_USE B_DEPEND B_RDEPEND B_PDEPEND
+ unset B_IUSE B_REQUIRED_USE B_DEPEND B_RDEPEND B_PDEPEND B_HDEPEND
[ "${IUSE+set}" = set ] && B_IUSE="${IUSE}"
[ "${REQUIRED_USE+set}" = set ] && B_REQUIRED_USE="${REQUIRED_USE}"
[ "${DEPEND+set}" = set ] && B_DEPEND="${DEPEND}"
[ "${RDEPEND+set}" = set ] && B_RDEPEND="${RDEPEND}"
[ "${PDEPEND+set}" = set ] && B_PDEPEND="${PDEPEND}"
- unset IUSE REQUIRED_USE DEPEND RDEPEND PDEPEND
+ [ "${HDEPEND+set}" = set ] && B_HDEPEND="${HDEPEND}"
+ unset IUSE REQUIRED_USE DEPEND RDEPEND PDEPEND HDEPEND
#turn on glob expansion
set +f

@@ -286,6 +288,7 @@ inherit() {
[ "${DEPEND+set}" = set ] && E_DEPEND+="${E_DEPEND:+ }${DEPEND}"
[ "${RDEPEND+set}" = set ] && E_RDEPEND+="${E_RDEPEND:+ }${RDEPEND}"
[ "${PDEPEND+set}" = set ] && E_PDEPEND+="${E_PDEPEND:+ }${PDEPEND}"
+ [ "${HDEPEND+set}" = set ] && E_HDEPEND+="${E_HDEPEND:+ }${HDEPEND}"

[ "${B_IUSE+set}" = set ] && IUSE="${B_IUSE}"
[ "${B_IUSE+set}" = set ] || unset IUSE
@@ -302,6 +305,9 @@ inherit() {
[ "${B_PDEPEND+set}" = set ] && PDEPEND="${B_PDEPEND}"
[ "${B_PDEPEND+set}" = set ] || unset PDEPEND

+ [ "${B_HDEPEND+set}" = set ] && HDEPEND="${B_HDEPEND}"
+ [ "${B_HDEPEND+set}" = set ] || unset HDEPEND
+
#turn on glob expansion
set +f

@@ -528,8 +534,9 @@ if ! has "$EBUILD_PHASE" clean cleanrm ; then
# In order to ensure correct interaction between ebuilds and
# eclasses, they need to be unset before this process of
# interaction begins.
- unset EAPI DEPEND RDEPEND PDEPEND INHERITED IUSE REQUIRED_USE
- ECLASS E_IUSE E_REQUIRED_USE E_DEPEND E_RDEPEND E_PDEPEND
+ unset EAPI DEPEND RDEPEND PDEPEND HDEPEND INHERITED IUSE REQUIRED_USE
+ ECLASS E_IUSE E_REQUIRED_USE E_DEPEND E_RDEPEND E_PDEPEND
+ E_HDEPEND

if [[ $PORTAGE_DEBUG != 1 || ${-/x/} != $- ]] ; then
source "$EBUILD" || die "error sourcing ebuild"
@@ -560,13 +567,14 @@ if ! has "$EBUILD_PHASE" clean cleanrm ; then
DEPEND+="${DEPEND:+ }${E_DEPEND}"
RDEPEND+="${RDEPEND:+ }${E_RDEPEND}"
PDEPEND+="${PDEPEND:+ }${E_PDEPEND}"
+ HDEPEND+="${HDEPEND:+ }${E_HDEPEND}"
REQUIRED_USE+="${REQUIRED_USE:+ }${E_REQUIRED_USE}"

- unset ECLASS E_IUSE E_REQUIRED_USE E_DEPEND E_RDEPEND E_PDEPEND
+ unset ECLASS E_IUSE E_REQUIRED_USE E_DEPEND E_RDEPEND E_PDEPEND E_HDEPEND
__INHERITED_QA_CACHE

# alphabetically ordered by $EBUILD_PHASE value
- case "$EAPI" in
+ case ${EAPI} in
0|1)
_valid_phases="src_compile pkg_config pkg_info src_install
pkg_nofetch pkg_postinst pkg_postrm pkg_preinst pkg_prerm
@@ -664,9 +672,17 @@ if [[ $EBUILD_PHASE = depend ]] ; then

auxdbkeys="DEPEND RDEPEND SLOT SRC_URI RESTRICT HOMEPAGE LICENSE
DESCRIPTION KEYWORDS INHERITED IUSE REQUIRED_USE PDEPEND PROVIDE EAPI
- PROPERTIES DEFINED_PHASES UNUSED_05 UNUSED_04
+ PROPERTIES DEFINED_PHASES HDEPEND UNUSED_04
UNUSED_03 UNUSED_02 UNUSED_01"

+ case ${EAPI} in
+ 5-hdepend)
+ ;;
+ *)
+ unset HDEPEND
+ ;;
+ esac
+
# The extra $(echo) commands remove newlines.
if [ -n "${dbkey}" ] ; then
> "${dbkey}"
@@ -684,7 +700,7 @@ else
# Note: readonly variables interfere with __preprocess_ebuild_env(), so
# declare them only after it has already run.
declare -r $PORTAGE_READONLY_METADATA $PORTAGE_READONLY_VARS
- case "$EAPI" in
+ case ${EAPI} in
0|1|2)
[[ " ${FEATURES} " == *" force-prefix "* ]] &&
declare -r ED EPREFIX EROOT
diff --git a/pym/_emerge/depgraph.py b/pym/_emerge/depgraph.py
index 9da202c..dca1a74 100644
--- a/pym/_emerge/depgraph.py
+++ b/pym/_emerge/depgraph.py
@@ -24,7 +24,7 @@ from portage.dep import Atom, best_match_to_list, extract_affecting_use,
_repo_separator
from portage.dep._slot_operator import ignore_built_slot_operator_deps
from portage.eapi import eapi_has_strong_blocks, eapi_has_required_use,
- _get_eapi_attrs
+ _get_eapi_attrs, eapi_has_hdepend
from portage.exception import (InvalidAtom, InvalidDependString,
PackageNotFound, PortageException)
from portage.output import colorize, create_color_func,
@@ -504,7 +504,7 @@ class depgraph(object):

pkg_tree_map = RootConfig.pkg_tree_map

- _dep_keys = ["DEPEND", "RDEPEND", "PDEPEND"]
+ _dep_keys = ["DEPEND", "RDEPEND", "PDEPEND", "HDEPEND"]

def __init__(self, settings, trees, myopts, myparams, spinner,
frozen_config=None, backtrack_parameters=BacktrackParameter(), allow_backtracking=False):
@@ -537,10 +537,6 @@ class depgraph(object):
preload_installed_pkgs =
"--nodeps" not in self._frozen_config.myopts

- if self._frozen_config.myopts.get("--root-deps") is not None and
- myroot != self._frozen_config.target_root:
- continue
-
fake_vartree = self._frozen_config.trees[myroot]["vartree"]
if not fake_vartree.dbapi:
# This needs to be called for the first depgraph, but not for
@@ -1685,7 +1681,7 @@ class depgraph(object):
removal_action = "remove" in self._dynamic_config.myparams

edepend={}
- depkeys = ["DEPEND","RDEPEND","PDEPEND"]
+ depkeys = ["DEPEND","RDEPEND","PDEPEND","HDEPEND"]
for k in depkeys:
edepend[k] = metadata[k]

@@ -1713,31 +1709,44 @@ class depgraph(object):
# Removal actions never traverse ignored buildtime
# dependencies, so it's safe to discard them early.
edepend["DEPEND"] = ""
+ edepend["HDEPEND"] = ""
ignore_build_time_deps = True

+ ignore_depend_deps = ignore_build_time_deps
+ ignore_hdepend_deps = ignore_build_time_deps
+
if removal_action:
depend_root = myroot
else:
- depend_root = self._frozen_config._running_root.root
- root_deps = self._frozen_config.myopts.get("--root-deps")
- if root_deps is not None:
- if root_deps is True:
- depend_root = myroot
- elif root_deps == "rdeps":
- ignore_build_time_deps = True
+ if eapi_has_hdepend(pkg.metadata['EAPI']):
+ depend_root = myroot
+ else:
+ depend_root = self._frozen_config._running_root.root
+ root_deps = self._frozen_config.myopts.get("--root-deps")
+ if root_deps is not None:
+ if root_deps is True:
+ depend_root = myroot
+ elif root_deps == "rdeps":
+ ignore_depend_deps = True

# If rebuild mode is not enabled, it's safe to discard ignored
# build-time dependencies. If you want these deps to be traversed
# in "complete" mode then you need to specify --with-bdeps=y.
- if ignore_build_time_deps and
- not self._rebuild.rebuild:
- edepend["DEPEND"] = ""
-
+ if not self._rebuild.rebuild:
+ if ignore_depend_deps:
+ edepend["DEPEND"] = ""
+ if ignore_hdepend_deps:
+ edepend["HDEPEND"] = ""
+
deps = (
(depend_root, edepend["DEPEND"],
self._priority(buildtime=True,
- optional=(pkg.built or ignore_build_time_deps),
- ignored=ignore_build_time_deps)),
+ optional=(pkg.built or ignore_depend_deps),
+ ignored=ignore_depend_deps)),
+ (self._frozen_config._running_root.root, edepend["HDEPEND"],
+ self._priority(buildtime=True,
+ optional=(pkg.built or ignore_hdepend_deps),
+ ignored=ignore_hdepend_deps)),
(myroot, edepend["RDEPEND"],
self._priority(runtime=True)),
(myroot, edepend["PDEPEND"],
@@ -2838,7 +2847,7 @@ class depgraph(object):
return [pkg.slot_atom for pkg in greedy_pkgs]

blockers = {}
- blocker_dep_keys = ["DEPEND", "PDEPEND", "RDEPEND"]
+ blocker_dep_keys = ["DEPEND", "PDEPEND", "RDEPEND", "HDEPEND"]
for pkg in greedy_pkgs + [highest_pkg]:
dep_str = " ".join(pkg.metadata[k] for k in blocker_dep_keys)
try:
@@ -3099,7 +3108,7 @@ class depgraph(object):

if target_atom is not None and isinstance(node, Package):
affecting_use = set()
- for dep_str in "DEPEND", "RDEPEND", "PDEPEND":
+ for dep_str in "DEPEND", "RDEPEND", "PDEPEND", "HDEPEND":
try:
affecting_use.update(extract_affecting_use(
node.metadata[dep_str], target_atom,
@@ -3183,10 +3192,12 @@ class depgraph(object):
dep_strings.add(node.metadata["DEPEND"])
dep_strings.add(node.metadata["RDEPEND"])
dep_strings.add(node.metadata["PDEPEND"])
+ dep_strings.add(node.metadata["HDEPEND"])
else:
for priority in priorities:
if priority.buildtime:
dep_strings.add(node.metadata["DEPEND"])
+ dep_strings.add(node.metadata["HDEPEND"])
if priority.runtime:
dep_strings.add(node.metadata["RDEPEND"])
if priority.runtime_post:
@@ -4129,7 +4140,7 @@ class depgraph(object):
if pkg not in self._dynamic_config.digraph.nodes:
return False

- for key in "DEPEND", "RDEPEND", "PDEPEND", "LICENSE":
+ for key in "DEPEND", "RDEPEND", "PDEPEND", "HDEPEND", "LICENSE":
dep = pkg.metadata[key]
old_val = set(portage.dep.use_reduce(dep, pkg.use.enabled, is_valid_flag=pkg.iuse.is_valid_flag, flat=True))
new_val = set(portage.dep.use_reduce(dep, new_use, is_valid_flag=pkg.iuse.is_valid_flag, flat=True))
diff --git a/pym/_emerge/main.py b/pym/_emerge/main.py
index d19b795..c3e9646 100644
--- a/pym/_emerge/main.py
+++ b/pym/_emerge/main.py
@@ -977,7 +977,6 @@ def parse_opts(tmpcmdline, silent=False):
"type" : "choice",
"choices" : true_y_or_n
},
-
}

from optparse import OptionParser
diff --git a/pym/portage/__init__.py b/pym/portage/__init__.py
index 30c7e72..695f1ea 100644
--- a/pym/portage/__init__.py
+++ b/pym/portage/__init__.py
@@ -414,7 +414,7 @@ def abssymlink(symlink, target=None):

_doebuild_manifest_exempt_depend = 0

-_testing_eapis = frozenset(["4-python", "4-slot-abi", "5-progress"])
+_testing_eapis = frozenset(["4-python", "4-slot-abi", "5-progress", "5-hdepend"])
_deprecated_eapis = frozenset(["4_pre1", "3_pre2", "3_pre1", "5_pre1", "5_pre2"])

def _eapi_is_deprecated(eapi):
@@ -472,7 +472,7 @@ auxdbkeys = (
'RESTRICT', 'HOMEPAGE', 'LICENSE', 'DESCRIPTION',
'KEYWORDS', 'INHERITED', 'IUSE', 'REQUIRED_USE',
'PDEPEND', 'PROVIDE', 'EAPI',
- 'PROPERTIES', 'DEFINED_PHASES', 'UNUSED_05', 'UNUSED_04',
+ 'PROPERTIES', 'DEFINED_PHASES', 'HDEPEND', 'UNUSED_04',
'UNUSED_03', 'UNUSED_02', 'UNUSED_01',
)
auxdbkeylen=len(auxdbkeys)
diff --git a/pym/portage/dbapi/bintree.py b/pym/portage/dbapi/bintree.py
index 7f09436..921f51d 100644
--- a/pym/portage/dbapi/bintree.py
+++ b/pym/portage/dbapi/bintree.py
@@ -75,6 +75,7 @@ class bindbapi(fakedbapi):
["BUILD_TIME", "CHOST", "DEPEND", "EAPI", "IUSE", "KEYWORDS",
"LICENSE", "PDEPEND", "PROPERTIES", "PROVIDE",
"RDEPEND", "repository", "RESTRICT", "SLOT", "USE", "DEFINED_PHASES",
+ "HDEPEND",
])
self._aux_cache_slot_dict = slot_dict_class(self._aux_cache_keys)
self._aux_cache = {}
@@ -304,11 +305,11 @@ class binarytree(object):
["BUILD_TIME", "CHOST", "DEPEND", "DESCRIPTION", "EAPI",
"IUSE", "KEYWORDS", "LICENSE", "PDEPEND", "PROPERTIES",
"PROVIDE", "RDEPEND", "repository", "SLOT", "USE", "DEFINED_PHASES",
- "BASE_URI"]
+ "BASE_URI", "HDEPEND"]
self._pkgindex_aux_keys = list(self._pkgindex_aux_keys)
self._pkgindex_use_evaluated_keys =
("LICENSE", "RDEPEND", "DEPEND",
- "PDEPEND", "PROPERTIES", "PROVIDE")
+ "PDEPEND", "PROPERTIES", "PROVIDE", "HDEPEND")
self._pkgindex_header_keys = set([
"ACCEPT_KEYWORDS", "ACCEPT_LICENSE",
"ACCEPT_PROPERTIES", "CBUILD",
@@ -330,6 +331,7 @@ class binarytree(object):
"SLOT" : "0",
"USE" : "",
"DEFINED_PHASES" : "",
+ "HDEPEND" : "",
}
self._pkgindex_inherited_keys = ["CHOST", "repository"]

diff --git a/pym/portage/dbapi/porttree.py b/pym/portage/dbapi/porttree.py
index 0cb290f..b6b3d00 100644
--- a/pym/portage/dbapi/porttree.py
+++ b/pym/portage/dbapi/porttree.py
@@ -189,7 +189,7 @@ class portdbapi(dbapi):
self._aux_cache_keys = set(
["DEPEND", "EAPI", "INHERITED", "IUSE", "KEYWORDS", "LICENSE",
"PDEPEND", "PROPERTIES", "PROVIDE", "RDEPEND", "repository",
- "RESTRICT", "SLOT", "DEFINED_PHASES", "REQUIRED_USE"])
+ "RESTRICT", "SLOT", "DEFINED_PHASES", "REQUIRED_USE", "HDEPEND"])

self._aux_cache = {}
self._broken_ebuilds = set()
diff --git a/pym/portage/dbapi/vartree.py b/pym/portage/dbapi/vartree.py
index 7d6d6a8..0822883 100644
--- a/pym/portage/dbapi/vartree.py
+++ b/pym/portage/dbapi/vartree.py
@@ -164,6 +164,7 @@ class vardbapi(dbapi):
"EAPI", "HOMEPAGE", "IUSE", "KEYWORDS",
"LICENSE", "PDEPEND", "PROPERTIES", "PROVIDE", "RDEPEND",
"repository", "RESTRICT" , "SLOT", "USE", "DEFINED_PHASES",
+ "HDEPEND",
])
self._aux_cache_obj = None
self._aux_cache_filename = os.path.join(self._eroot,
diff --git a/pym/portage/eapi.py b/pym/portage/eapi.py
index b12d81d..7c45843 100644
--- a/pym/portage/eapi.py
+++ b/pym/portage/eapi.py
@@ -83,9 +83,15 @@ def eapi_supports_stable_use_forcing_and_masking(eapi) :
def eapi_allows_directories_on_profile_level_and_repos itory_level(eapi):
return eapi in ("4-python", "5-progress")

+def eapi_has_hdepend(eapi):
+ return eapi in ("5-hdepend",)
+
+def eapi_has_targetroot(eapi):
+ return eapi in ("5-hdepend",)
+
_eapi_attrs = collections.namedtuple('_eapi_attrs',
'dots_in_PN dots_in_use_flags exports_EBUILD_PHASE_FUNC '
- 'feature_flag_test iuse_defaults iuse_effective '
+ 'feature_flag_test feature_flag_targetroot iuse_defaults iuse_effective '
'repo_deps required_use required_use_at_most_one_of slot_operator slot_deps '
'src_uri_arrows strong_blocks use_deps use_dep_defaults')

@@ -112,6 +118,7 @@ def _get_eapi_attrs(eapi):
dots_in_use_flags = (eapi is None or eapi_allows_dots_in_use_flags(eapi)),
exports_EBUILD_PHASE_FUNC = (eapi is None or eapi_exports_EBUILD_PHASE_FUNC(eapi)),
feature_flag_test = True,
+ feature_flag_targetroot = eapi_has_targetroot(eapi),
iuse_defaults = (eapi is None or eapi_has_iuse_defaults(eapi)),
iuse_effective = (eapi is not None and eapi_has_iuse_effective(eapi)),
repo_deps = (eapi is None or eapi_has_repo_deps(eapi)),
diff --git a/pym/portage/package/ebuild/config.py b/pym/portage/package/ebuild/config.py
index 894d14c..4992292 100644
--- a/pym/portage/package/ebuild/config.py
+++ b/pym/portage/package/ebuild/config.py
@@ -33,7 +33,8 @@ from portage.dbapi.porttree import portdbapi
from portage.dbapi.vartree import vartree
from portage.dep import Atom, isvalidatom, match_from_list, use_reduce, _repo_separator, _slot_separator
from portage.eapi import eapi_exports_AA, eapi_exports_merge_type,
- eapi_supports_prefix, eapi_exports_replace_vars, _get_eapi_attrs
+ eapi_supports_prefix, eapi_exports_replace_vars, _get_eapi_attrs,
+ eapi_has_targetroot
from portage.env.loaders import KeyValuePairFileLoader
from portage.exception import InvalidDependString, PortageException
from portage.localization import _
@@ -63,7 +64,7 @@ if sys.hexversion >= 0x3000000:
_feature_flags_cache = {}

def _get_feature_flags(eapi_attrs):
- cache_key = (eapi_attrs.feature_flag_test,)
+ cache_key = (eapi_attrs.feature_flag_test, eapi_attrs.feature_flag_targetroot)
flags = _feature_flags_cache.get(cache_key)
if flags is not None:
return flags
@@ -71,6 +72,8 @@ def _get_feature_flags(eapi_attrs):
flags = []
if eapi_attrs.feature_flag_test:
flags.append("test")
+ if eapi_attrs.feature_flag_targetroot:
+ flags.append("targetroot")

flags = frozenset(flags)
_feature_flags_cache[cache_key] = flags
@@ -1503,6 +1506,13 @@ class config(object):
self.usemask =
frozenset(x for x in self.usemask if x != "test")

+ if ("targetroot" in explicit_iuse or iuse_implicit_match("targetroot")) and
+ eapi_has_targetroot(eapi):
+ if self["ROOT"] != "/":
+ use.add("targetroot")
+ else:
+ use.discard("targetroot")
+
# Allow _* flags from USE_EXPAND wildcards to pass through here.
use.difference_update([x for x in use
if (x not in explicit_iuse and
--
1.7.12

Mike Frysinger 09-24-2012 05:01 PM

Implement host dependencies and targetroot USE flag
 
On Monday 24 September 2012 06:11:01 Ambroz Bizjak wrote:
> > case ${EAPI} in
>
> But then, there are two other places in ebuild.sh using "case EAPI" and
> they both look exactly like mine. Updated patch changes all of them.

WFM, thanks
-mike

Zac Medico 09-24-2012 08:18 PM

Implement host dependencies and targetroot USE flag
 
On 09/24/2012 03:11 AM, Ambroz Bizjak wrote:
> ---
> bin/ebuild.sh | 34 +++++++++++++++------
> pym/_emerge/depgraph.py | 57 +++++++++++++++++++++---------------
> pym/_emerge/main.py | 1 -
> pym/portage/__init__.py | 4 +--
> pym/portage/dbapi/bintree.py | 6 ++--
> pym/portage/dbapi/porttree.py | 2 +-
> pym/portage/dbapi/vartree.py | 1 +
> pym/portage/eapi.py | 9 +++++-
> pym/portage/package/ebuild/config.py | 14 +++++++--
> 9 files changed, 87 insertions(+), 41 deletions(-)

Thanks, I've committed your patch:

http://git.overlays.gentoo.org/gitweb/?p=proj/portage.git;a=commit;h=814e82f24afc221eee72f2b53a3 fb7587605cbf9

I just made a few trivial changes, adding HDEPEND in more places that
work with *DEPEND variables, and ordering variable lists in lexical order.
--
Thanks,
Zac


All times are GMT. The time now is 09:43 PM.

VBulletin, Copyright ©2000 - 2014, Jelsoft Enterprises Ltd.
Content Relevant URLs by vBSEO ©2007, Crawlability, Inc.