* [gentoo-commits] gentoo-x86 commit in app-portage/gentoolkit/files: 0.3.0.7-root.patch
@ 2013-02-25 18:03 Mike Frysinger (vapier)
0 siblings, 0 replies; only message in thread
From: Mike Frysinger (vapier) @ 2013-02-25 18:03 UTC (permalink / raw
To: gentoo-commits
vapier 13/02/25 18:03:52
Added: 0.3.0.7-root.patch
Log:
Add fix for ROOT handling #160815.
(Portage version: 2.2.0_alpha163/cvs/Linux x86_64, signed Manifest commit with key FB7C4156)
Revision Changes Path
1.1 app-portage/gentoolkit/files/0.3.0.7-root.patch
file : http://sources.gentoo.org/viewvc.cgi/gentoo-x86/app-portage/gentoolkit/files/0.3.0.7-root.patch?rev=1.1&view=markup
plain: http://sources.gentoo.org/viewvc.cgi/gentoo-x86/app-portage/gentoolkit/files/0.3.0.7-root.patch?rev=1.1&content-type=text/plain
Index: 0.3.0.7-root.patch
===================================================================
From 35cc856ee0ce03858a39210525b9893ca061f079 Mon Sep 17 00:00:00 2001
From: Mike Frysinger <vapier@gentoo.org>
Date: Wed, 19 Dec 2012 18:50:17 -0500
Subject: [PATCH] equery: make more ROOT aware
This at least fixes:
belongs
check
depends
files
list
size
URL: https://bugs.gentoo.org/160815
Signed-off-by: Mike Frysinger <vapier@gentoo.org>
Signed-off-by: Paul Varner <fuzzyray@gentoo.org>
---
pym/gentoolkit/equery/check.py | 17 +++++++++--------
pym/gentoolkit/package.py | 35 ++++++++++++++++++++++-------------
2 files changed, 31 insertions(+), 21 deletions(-)
diff --git a/pym/gentoolkit/equery/check.py b/pym/gentoolkit/equery/check.py
index 84be634..e903355 100644
--- a/pym/gentoolkit/equery/check.py
+++ b/pym/gentoolkit/equery/check.py
@@ -105,26 +105,27 @@ class VerifyContents(object):
for cfile in files:
n_checked += 1
ftype = files[cfile][0]
- if not os.path.exists(cfile):
+ real_cfile = os.environ.get('ROOT', '') + cfile
+ if not os.path.exists(real_cfile):
errs.append("%s does not exist" % cfile)
continue
elif ftype == "dir":
- if not os.path.isdir(cfile):
+ if not os.path.isdir(real_cfile):
err = "%(cfile)s exists, but is not a directory"
errs.append(err % locals())
continue
elif ftype == "obj":
- obj_errs = self._verify_obj(files, cfile, errs)
+ obj_errs = self._verify_obj(files, cfile, real_cfile, errs)
if len(obj_errs) > len(errs):
errs = obj_errs[:]
continue
elif ftype == "sym":
target = files[cfile][2].strip()
- if not os.path.islink(cfile):
+ if not os.path.islink(real_cfile):
err = "%(cfile)s exists, but is not a symlink"
errs.append(err % locals())
continue
- tgt = os.readlink(cfile)
+ tgt = os.readlink(real_cfile)
if tgt != target:
err = "%(cfile)s does not point to %(target)s"
errs.append(err % locals())
@@ -137,14 +138,14 @@ class VerifyContents(object):
return n_passed, n_checked, errs
- def _verify_obj(self, files, cfile, errs):
+ def _verify_obj(self, files, cfile, real_cfile, errs):
"""Verify the MD5 sum and/or mtime and return any errors."""
obj_errs = errs[:]
if self.check_sums:
md5sum = files[cfile][2]
try:
- cur_checksum = checksum.perform_md5(cfile, calc_prelink=1)
+ cur_checksum = checksum.perform_md5(real_cfile, calc_prelink=1)
except IOError:
err = "Insufficient permissions to read %(cfile)s"
obj_errs.append(err % locals())
@@ -155,7 +156,7 @@ class VerifyContents(object):
return obj_errs
if self.check_timestamps:
mtime = int(files[cfile][1])
- st_mtime = int(os.lstat(cfile).st_mtime)
+ st_mtime = int(os.lstat(real_cfile).st_mtime)
if st_mtime != mtime:
err = (
"%(cfile)s has wrong mtime (is %(st_mtime)d, should be "
diff --git a/pym/gentoolkit/package.py b/pym/gentoolkit/package.py
index e324399..2a103de 100644
--- a/pym/gentoolkit/package.py
+++ b/pym/gentoolkit/package.py
@@ -58,16 +58,14 @@ from gentoolkit.eprefix import EPREFIX
# Settings
# =======
-if EPREFIX:
- default_settings = portage.config(local_config=True, eprefix=EPREFIX)
- default_settings.lock()
- nolocal_settings = portage.config(local_config=False, eprefix=EPREFIX)
- nolocal_settings.lock()
-else:
- default_settings = portage.config(local_config=True)
- default_settings.lock()
- nolocal_settings = portage.config(local_config=False)
- nolocal_settings.lock()
+def _NewPortageConfig(local_config):
+ ret = portage.config(local_config=local_config,
+ eprefix=EPREFIX if EPREFIX else None,
+ target_root=os.environ.get('ROOT', None))
+ ret.lock()
+ return ret
+default_settings = _NewPortageConfig(local_config=True)
+nolocal_settings = _NewPortageConfig(local_config=False)
# =======
# Classes
@@ -350,14 +348,25 @@ class Package(CPV):
iuse, final_flags = get_flags(self.cpv, final_setting=True)
return final_flags
- def parsed_contents(self):
+ def parsed_contents(self, prefix_root=False):
"""Returns the parsed CONTENTS file.
@rtype: dict
@return: {'/full/path/to/obj': ['type', 'timestamp', 'md5sum'], ...}
"""
- return self.dblink.getcontents()
+ contents = self.dblink.getcontents()
+
+ # Portage will automatically prepend ROOT. Undo that.
+ if not prefix_root:
+ myroot = self._settings["ROOT"]
+ if myroot != '/':
+ ret = {}
+ for key, val in self.dblink.getcontents().iteritems():
+ ret['/' + os.path.relpath(key, myroot)] = val
+ contents = ret
+
+ return contents
def size(self):
"""Estimates the installed size of the contents of this package.
@@ -368,7 +377,7 @@ class Package(CPV):
seen = set()
size = n_files = n_uncounted = 0
- for f in self.parsed_contents():
+ for f in self.parsed_contents(prefix_root=True):
try:
st = os.lstat(path)
except OSError:
--
1.8.1.2
^ permalink raw reply related [flat|nested] only message in thread
only message in thread, other threads:[~2013-02-25 18:03 UTC | newest]
Thread overview: (only message) (download: mbox.gz follow: Atom feed
-- links below jump to the message on this page --
2013-02-25 18:03 [gentoo-commits] gentoo-x86 commit in app-portage/gentoolkit/files: 0.3.0.7-root.patch Mike Frysinger (vapier)
This is a public inbox, see mirroring instructions
for how to clone and mirror all data and code used for this inbox