From: Zac Medico Date: Wed, 19 Jun 2013 23:41:12 +0000 (-0700) Subject: Fix cross-prefix bugs, and test. X-Git-Tag: v2.2.0_alpha182~1 X-Git-Url: http://git.tremily.us/?a=commitdiff_plain;h=40400439b0c48fbc822b622c1758be3587f4a1f1;p=portage.git Fix cross-prefix bugs, and test. * Fix create_trees to correctly handle the case where ROOT=/ for two different EPREFIX offsets. * For best/has_version, handle the case where ROOT=/ for bug prefixes, though each has a different EPREFIX offset. * Use portage.const.EPREFIX for default EMERGE_LOG_DIR offset, which is analogous to existing un-prefixed behavior. * Use portage.const.EPREFIX for default PORTAGE_CONFIGROOT, which is analogous to existing un-prefixed behavior. * Add cross-prefix cases to emerge tests, including chpathtool for binpkgs. --- diff --git a/bin/phase-helpers.sh b/bin/phase-helpers.sh index 3d51eb002..ba12f1fbd 100644 --- a/bin/phase-helpers.sh +++ b/bin/phase-helpers.sh @@ -676,7 +676,10 @@ has_version() { fi if ___eapi_has_prefix_variables; then - if [[ ${root} == / ]] ; then + # [[ ${root} == / ]] would be ambiguous here, + # since both prefixes can share root=/ while + # having different EPREFIX offsets. + if ${host_root} ; then eroot=${root%/}${PORTAGE_OVERRIDE_EPREFIX}/ else eroot=${root%/}${EPREFIX}/ @@ -732,7 +735,10 @@ best_version() { fi if ___eapi_has_prefix_variables; then - if [[ ${root} == / ]] ; then + # [[ ${root} == / ]] would be ambiguous here, + # since both prefixes can share root=/ while + # having different EPREFIX offsets. + if ${host_root} ; then eroot=${root%/}${PORTAGE_OVERRIDE_EPREFIX}/ else eroot=${root%/}${EPREFIX}/ diff --git a/pym/_emerge/actions.py b/pym/_emerge/actions.py index b331b10c1..c31ad1d86 100644 --- a/pym/_emerge/actions.py +++ b/pym/_emerge/actions.py @@ -3800,8 +3800,7 @@ def run_action(emerge_config): _emerge.emergelog._emerge_log_dir = emerge_log_dir else: _emerge.emergelog._emerge_log_dir = os.path.join(os.sep, - emerge_config.target_config.settings["EPREFIX"].lstrip(os.sep), - "var", "log") + portage.const.EPREFIX.lstrip(os.sep), "var", "log") portage.util.ensure_dirs(_emerge.emergelog._emerge_log_dir) if not "--pretend" in emerge_config.opts: diff --git a/pym/portage/__init__.py b/pym/portage/__init__.py index 2510f86b5..7656c6ebe 100644 --- a/pym/portage/__init__.py +++ b/pym/portage/__init__.py @@ -577,7 +577,7 @@ def create_trees(config_root=None, target_root=None, trees=None, env=None, trees._target_eroot = settings['EROOT'] myroots = [(settings['EROOT'], settings)] - if settings["ROOT"] == "/": + if settings["ROOT"] == "/" and settings["EPREFIX"] == const.EPREFIX: trees._running_eroot = trees._target_eroot else: @@ -593,7 +593,7 @@ def create_trees(config_root=None, target_root=None, trees=None, env=None, if v is not None: clean_env[k] = v settings = config(config_root=None, target_root="/", - env=clean_env, eprefix=eprefix) + env=clean_env, eprefix=None) settings.lock() trees._running_eroot = settings['EROOT'] myroots.append((settings['EROOT'], settings)) diff --git a/pym/portage/package/ebuild/_config/LocationsManager.py b/pym/portage/package/ebuild/_config/LocationsManager.py index 7e799b840..e328441a7 100644 --- a/pym/portage/package/ebuild/_config/LocationsManager.py +++ b/pym/portage/package/ebuild/_config/LocationsManager.py @@ -49,7 +49,7 @@ class LocationsManager(object): self.eprefix = portage.const.EPREFIX if self.config_root is None: - self.config_root = self.eprefix + os.sep + self.config_root = portage.const.EPREFIX + os.sep self.config_root = normalize_path(os.path.abspath( self.config_root)).rstrip(os.path.sep) + os.path.sep diff --git a/pym/portage/tests/emerge/test_simple.py b/pym/portage/tests/emerge/test_simple.py index c1abd52bd..dc7ddb75a 100644 --- a/pym/portage/tests/emerge/test_simple.py +++ b/pym/portage/tests/emerge/test_simple.py @@ -201,6 +201,8 @@ pkg_preinst() { test_ebuild = portdb.findname("dev-libs/A-1") self.assertFalse(test_ebuild is None) + cross_prefix = os.path.join(eprefix, "cross_prefix") + test_commands = ( env_update_cmd, portageq_cmd + ("envvar", "-v", "CONFIG_PROTECT", "EROOT", @@ -266,6 +268,24 @@ pkg_preinst() { emerge_cmd + ("-p", "--unmerge", "-q", eroot + "usr"), emerge_cmd + ("--unmerge", "--quiet", "dev-libs/A"), emerge_cmd + ("-C", "--quiet", "dev-libs/B"), + + # Test cross-prefix usage, including chpathtool for binpkgs. + ({"EPREFIX" : cross_prefix},) + \ + emerge_cmd + ("--usepkgonly", "dev-libs/A"), + ({"EPREFIX" : cross_prefix},) + \ + portageq_cmd + ("has_version", cross_prefix, "dev-libs/A"), + ({"EPREFIX" : cross_prefix},) + \ + portageq_cmd + ("has_version", cross_prefix, "dev-libs/B"), + ({"EPREFIX" : cross_prefix},) + \ + emerge_cmd + ("-C", "--quiet", "dev-libs/B"), + ({"EPREFIX" : cross_prefix},) + \ + emerge_cmd + ("-C", "--quiet", "dev-libs/A"), + ({"EPREFIX" : cross_prefix},) + \ + emerge_cmd + ("dev-libs/A",), + ({"EPREFIX" : cross_prefix},) + \ + portageq_cmd + ("has_version", cross_prefix, "dev-libs/A"), + ({"EPREFIX" : cross_prefix},) + \ + portageq_cmd + ("has_version", cross_prefix, "dev-libs/B"), ) distdir = playground.distdir