* [gentoo-portage-dev] [PATCH] unprivileged mode: fix cross-prefix support
@ 2014-11-17 17:02 Zac Medico
2014-11-17 17:34 ` Brian Dolbec
0 siblings, 1 reply; 2+ messages in thread
From: Zac Medico @ 2014-11-17 17:02 UTC (permalink / raw
To: gentoo-portage-dev; +Cc: Zac Medico
In commit 1364fcd89384c9f60e6d72d7057dc00d8caba175, EROOT calculation
in portage.data did not account from cross-prefix support. This is
fixed by using new _target_root and _target_eprefix functions to
perform the calculation. The _target_eprefix function is also useful
in portageq, where the target EPREFIX needs to be known before
portage.settings is instantiated.
Fixes 1364fcd89384 ("Support unprivileged mode for bug #433453.")
---
bin/portageq | 4 +---
pym/portage/data.py | 35 +++++++++++++++++++++++++++++++----
2 files changed, 32 insertions(+), 7 deletions(-)
diff --git a/bin/portageq b/bin/portageq
index ef565d1..6a42bfd 100755
--- a/bin/portageq
+++ b/bin/portageq
@@ -1397,9 +1397,7 @@ def main(argv):
# portage.settings["EPREFIX"] here, but that would force
# instantiation of portage.settings, which we don't want to do
# until after we've calculated ROOT (see bug #529200).
- eprefix = os.environ.get("EPREFIX", portage.const.EPREFIX)
- if eprefix:
- eprefix = portage.util.normalize_path(eprefix)
+ eprefix = portage.data._target_eprefix()
eroot = portage.util.normalize_path(argv[2])
if eprefix:
diff --git a/pym/portage/data.py b/pym/portage/data.py
index d9b36ee..2fd287d 100644
--- a/pym/portage/data.py
+++ b/pym/portage/data.py
@@ -35,6 +35,35 @@ if not lchown:
lchown = portage._unicode_func_wrapper(lchown)
+def _target_eprefix():
+ """
+ Calculate the target EPREFIX, which may be different from
+ portage.const.EPREFIX due to cross-prefix support. The result
+ is equivalent to portage.settings["EPREFIX"], but the calculation
+ is done without the expense of instantiating portage.settings.
+ @rtype: str
+ @return: the target EPREFIX
+ """
+ eprefix = os.environ.get("EPREFIX", portage.const.EPREFIX)
+ if eprefix:
+ eprefix = portage.util.normalize_path(eprefix)
+ return eprefix
+
+def _target_root():
+ """
+ Calculate the target ROOT. The result is equivalent to
+ portage.settings["ROOT"], but the calculation
+ is done without the expense of instantiating portage.settings.
+ @rtype: str
+ @return: the target ROOT (always ends with a slash)
+ """
+ root = os.environ.get("ROOT")
+ if not root:
+ # Handle either empty or unset ROOT.
+ root = os.sep
+ root = portage.util.normalize_path(root)
+ return root.rstrip(os.sep) + os.sep
+
def portage_group_warning():
warn_prefix = colorize("BAD", "*** WARNING *** ")
mylines = [
@@ -96,8 +125,7 @@ def _get_global(k):
# The config class has equivalent code, but we also need to
# do it here if _disable_legacy_globals() has been called.
eroot_or_parent = first_existing(os.path.join(
- os.environ.get('ROOT', os.sep),
- portage.const.EPREFIX.lstrip(os.sep)))
+ _target_root(), _target_eprefix().lstrip(os.sep)))
try:
eroot_st = os.stat(eroot_or_parent)
except OSError:
@@ -210,8 +238,7 @@ def _get_global(k):
# The config class has equivalent code, but we also need to
# do it here if _disable_legacy_globals() has been called.
eroot_or_parent = first_existing(os.path.join(
- os.environ.get('ROOT', os.sep),
- portage.const.EPREFIX.lstrip(os.sep)))
+ _target_root(), _target_eprefix().lstrip(os.sep)))
try:
eroot_st = os.stat(eroot_or_parent)
except OSError:
--
2.0.4
^ permalink raw reply related [flat|nested] 2+ messages in thread
* Re: [gentoo-portage-dev] [PATCH] unprivileged mode: fix cross-prefix support
2014-11-17 17:02 [gentoo-portage-dev] [PATCH] unprivileged mode: fix cross-prefix support Zac Medico
@ 2014-11-17 17:34 ` Brian Dolbec
0 siblings, 0 replies; 2+ messages in thread
From: Brian Dolbec @ 2014-11-17 17:34 UTC (permalink / raw
To: gentoo-portage-dev
On Mon, 17 Nov 2014 09:02:45 -0800
Zac Medico <zmedico@gentoo.org> wrote:
> In commit 1364fcd89384c9f60e6d72d7057dc00d8caba175, EROOT calculation
> in portage.data did not account from cross-prefix support. This is
^
for
> fixed by using new _target_root and _target_eprefix functions to
> perform the calculation. The _target_eprefix function is also useful
> in portageq, where the target EPREFIX needs to be known before
> portage.settings is instantiated.
>
> Fixes 1364fcd89384 ("Support unprivileged mode for bug #433453.")
> ---
Just a wrong word in the commit message, otherwise looks good
--
Brian Dolbec <dolsen>
^ permalink raw reply [flat|nested] 2+ messages in thread
end of thread, other threads:[~2014-11-17 17:34 UTC | newest]
Thread overview: 2+ messages (download: mbox.gz follow: Atom feed
-- links below jump to the message on this page --
2014-11-17 17:02 [gentoo-portage-dev] [PATCH] unprivileged mode: fix cross-prefix support Zac Medico
2014-11-17 17:34 ` Brian Dolbec
This is a public inbox, see mirroring instructions
for how to clone and mirror all data and code used for this inbox