1 |
vapier 13/02/25 18:03:52 |
2 |
|
3 |
Added: 0.3.0.7-root.patch |
4 |
Log: |
5 |
Add fix for ROOT handling #160815. |
6 |
|
7 |
(Portage version: 2.2.0_alpha163/cvs/Linux x86_64, signed Manifest commit with key FB7C4156) |
8 |
|
9 |
Revision Changes Path |
10 |
1.1 app-portage/gentoolkit/files/0.3.0.7-root.patch |
11 |
|
12 |
file : http://sources.gentoo.org/viewvc.cgi/gentoo-x86/app-portage/gentoolkit/files/0.3.0.7-root.patch?rev=1.1&view=markup |
13 |
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 |
14 |
|
15 |
Index: 0.3.0.7-root.patch |
16 |
=================================================================== |
17 |
From 35cc856ee0ce03858a39210525b9893ca061f079 Mon Sep 17 00:00:00 2001 |
18 |
From: Mike Frysinger <vapier@g.o> |
19 |
Date: Wed, 19 Dec 2012 18:50:17 -0500 |
20 |
Subject: [PATCH] equery: make more ROOT aware |
21 |
|
22 |
This at least fixes: |
23 |
belongs |
24 |
check |
25 |
depends |
26 |
files |
27 |
list |
28 |
size |
29 |
|
30 |
URL: https://bugs.gentoo.org/160815 |
31 |
Signed-off-by: Mike Frysinger <vapier@g.o> |
32 |
Signed-off-by: Paul Varner <fuzzyray@g.o> |
33 |
--- |
34 |
pym/gentoolkit/equery/check.py | 17 +++++++++-------- |
35 |
pym/gentoolkit/package.py | 35 ++++++++++++++++++++++------------- |
36 |
2 files changed, 31 insertions(+), 21 deletions(-) |
37 |
|
38 |
diff --git a/pym/gentoolkit/equery/check.py b/pym/gentoolkit/equery/check.py |
39 |
index 84be634..e903355 100644 |
40 |
--- a/pym/gentoolkit/equery/check.py |
41 |
+++ b/pym/gentoolkit/equery/check.py |
42 |
@@ -105,26 +105,27 @@ class VerifyContents(object): |
43 |
for cfile in files: |
44 |
n_checked += 1 |
45 |
ftype = files[cfile][0] |
46 |
- if not os.path.exists(cfile): |
47 |
+ real_cfile = os.environ.get('ROOT', '') + cfile |
48 |
+ if not os.path.exists(real_cfile): |
49 |
errs.append("%s does not exist" % cfile) |
50 |
continue |
51 |
elif ftype == "dir": |
52 |
- if not os.path.isdir(cfile): |
53 |
+ if not os.path.isdir(real_cfile): |
54 |
err = "%(cfile)s exists, but is not a directory" |
55 |
errs.append(err % locals()) |
56 |
continue |
57 |
elif ftype == "obj": |
58 |
- obj_errs = self._verify_obj(files, cfile, errs) |
59 |
+ obj_errs = self._verify_obj(files, cfile, real_cfile, errs) |
60 |
if len(obj_errs) > len(errs): |
61 |
errs = obj_errs[:] |
62 |
continue |
63 |
elif ftype == "sym": |
64 |
target = files[cfile][2].strip() |
65 |
- if not os.path.islink(cfile): |
66 |
+ if not os.path.islink(real_cfile): |
67 |
err = "%(cfile)s exists, but is not a symlink" |
68 |
errs.append(err % locals()) |
69 |
continue |
70 |
- tgt = os.readlink(cfile) |
71 |
+ tgt = os.readlink(real_cfile) |
72 |
if tgt != target: |
73 |
err = "%(cfile)s does not point to %(target)s" |
74 |
errs.append(err % locals()) |
75 |
@@ -137,14 +138,14 @@ class VerifyContents(object): |
76 |
|
77 |
return n_passed, n_checked, errs |
78 |
|
79 |
- def _verify_obj(self, files, cfile, errs): |
80 |
+ def _verify_obj(self, files, cfile, real_cfile, errs): |
81 |
"""Verify the MD5 sum and/or mtime and return any errors.""" |
82 |
|
83 |
obj_errs = errs[:] |
84 |
if self.check_sums: |
85 |
md5sum = files[cfile][2] |
86 |
try: |
87 |
- cur_checksum = checksum.perform_md5(cfile, calc_prelink=1) |
88 |
+ cur_checksum = checksum.perform_md5(real_cfile, calc_prelink=1) |
89 |
except IOError: |
90 |
err = "Insufficient permissions to read %(cfile)s" |
91 |
obj_errs.append(err % locals()) |
92 |
@@ -155,7 +156,7 @@ class VerifyContents(object): |
93 |
return obj_errs |
94 |
if self.check_timestamps: |
95 |
mtime = int(files[cfile][1]) |
96 |
- st_mtime = int(os.lstat(cfile).st_mtime) |
97 |
+ st_mtime = int(os.lstat(real_cfile).st_mtime) |
98 |
if st_mtime != mtime: |
99 |
err = ( |
100 |
"%(cfile)s has wrong mtime (is %(st_mtime)d, should be " |
101 |
diff --git a/pym/gentoolkit/package.py b/pym/gentoolkit/package.py |
102 |
index e324399..2a103de 100644 |
103 |
--- a/pym/gentoolkit/package.py |
104 |
+++ b/pym/gentoolkit/package.py |
105 |
@@ -58,16 +58,14 @@ from gentoolkit.eprefix import EPREFIX |
106 |
# Settings |
107 |
# ======= |
108 |
|
109 |
-if EPREFIX: |
110 |
- default_settings = portage.config(local_config=True, eprefix=EPREFIX) |
111 |
- default_settings.lock() |
112 |
- nolocal_settings = portage.config(local_config=False, eprefix=EPREFIX) |
113 |
- nolocal_settings.lock() |
114 |
-else: |
115 |
- default_settings = portage.config(local_config=True) |
116 |
- default_settings.lock() |
117 |
- nolocal_settings = portage.config(local_config=False) |
118 |
- nolocal_settings.lock() |
119 |
+def _NewPortageConfig(local_config): |
120 |
+ ret = portage.config(local_config=local_config, |
121 |
+ eprefix=EPREFIX if EPREFIX else None, |
122 |
+ target_root=os.environ.get('ROOT', None)) |
123 |
+ ret.lock() |
124 |
+ return ret |
125 |
+default_settings = _NewPortageConfig(local_config=True) |
126 |
+nolocal_settings = _NewPortageConfig(local_config=False) |
127 |
|
128 |
# ======= |
129 |
# Classes |
130 |
@@ -350,14 +348,25 @@ class Package(CPV): |
131 |
iuse, final_flags = get_flags(self.cpv, final_setting=True) |
132 |
return final_flags |
133 |
|
134 |
- def parsed_contents(self): |
135 |
+ def parsed_contents(self, prefix_root=False): |
136 |
"""Returns the parsed CONTENTS file. |
137 |
|
138 |
@rtype: dict |
139 |
@return: {'/full/path/to/obj': ['type', 'timestamp', 'md5sum'], ...} |
140 |
""" |
141 |
|
142 |
- return self.dblink.getcontents() |
143 |
+ contents = self.dblink.getcontents() |
144 |
+ |
145 |
+ # Portage will automatically prepend ROOT. Undo that. |
146 |
+ if not prefix_root: |
147 |
+ myroot = self._settings["ROOT"] |
148 |
+ if myroot != '/': |
149 |
+ ret = {} |
150 |
+ for key, val in self.dblink.getcontents().iteritems(): |
151 |
+ ret['/' + os.path.relpath(key, myroot)] = val |
152 |
+ contents = ret |
153 |
+ |
154 |
+ return contents |
155 |
|
156 |
def size(self): |
157 |
"""Estimates the installed size of the contents of this package. |
158 |
@@ -368,7 +377,7 @@ class Package(CPV): |
159 |
|
160 |
seen = set() |
161 |
size = n_files = n_uncounted = 0 |
162 |
- for f in self.parsed_contents(): |
163 |
+ for f in self.parsed_contents(prefix_root=True): |
164 |
try: |
165 |
st = os.lstat(path) |
166 |
except OSError: |
167 |
-- |
168 |
1.8.1.2 |