Gentoo Archives: gentoo-commits

From: "Fabian Groffen (grobian)" <grobian@g.o>
To: gentoo-commits@l.g.o
Subject: [gentoo-commits] portage r11736 - in main/branches/prefix: bin pym/_emerge pym/portage pym/portage/dbapi pym/portage/sets
Date: Tue, 28 Oct 2008 19:09:57
Message-Id: E1Kutww-0004ta-RT@stork.gentoo.org
1 Author: grobian
2 Date: 2008-10-28 19:09:53 +0000 (Tue, 28 Oct 2008)
3 New Revision: 11736
4
5 Modified:
6 main/branches/prefix/bin/ebuild.sh
7 main/branches/prefix/pym/_emerge/__init__.py
8 main/branches/prefix/pym/portage/__init__.py
9 main/branches/prefix/pym/portage/dbapi/vartree.py
10 main/branches/prefix/pym/portage/sets/__init__.py
11 main/branches/prefix/pym/portage/util.py
12 Log:
13 Merged from trunk -r11724:11733
14
15 | 11725 | When creating the temporary $DISTDIR, do not try to set the |
16 | zmedico | uid since it will fail when not running as root. |
17
18 | 11726 | Enable bashrc even when $EBUILD_PHASE is unset, so it's |
19 | zmedico | possible to override things like INSTALL_MASK. |
20
21 | 11727 | In fetch(), avoid the "Adjusting permissions recursively" |
22 | zmedico | message in cases when the directory has just been created |
23 | | and therefore it must be empty. |
24
25 | 11728 | Return early from fetch() if no uris are given. |
26 | zmedico | |
27
28 | 11729 | Pass $ROOT into portage.util.getlibpaths(). |
29 | zmedico | |
30
31 | 11730 | Pass $ROOT into the LinkageMap._ObjectKey constructor since |
32 | zmedico | it's needed for os.stat() and realpath() calls. |
33
34 | 11731 | Fix incorrect $ROOT handling inside dblink._preserve_libs(). |
35 | zmedico | |
36
37 | 11732 | Make SetConfig.getSetAtoms() raise a PackageSetNotFound |
38 | zmedico | exception when necessary and add handling code in emerge. |
39 | | This solves an unhandled KeyError that was raise when a |
40 | | nested set did not exist. Thanks to ABCD for reporting. |
41
42 | 11733 | Fix some incorrect $ROOT handling inside LinkageMap. |
43 | zmedico | |
44
45
46 Modified: main/branches/prefix/bin/ebuild.sh
47 ===================================================================
48 --- main/branches/prefix/bin/ebuild.sh 2008-10-28 18:51:42 UTC (rev 11735)
49 +++ main/branches/prefix/bin/ebuild.sh 2008-10-28 19:09:53 UTC (rev 11736)
50 @@ -1535,10 +1535,9 @@
51 # function for the current phase.
52 #
53 source_all_bashrcs() {
54 - [ -n "$EBUILD_PHASE" ] || return
55 local x
56
57 - if [[ -n ${EAPI/prefix/} ]] ; then
58 + if [[ -n $EBUILD_PHASE && -n ${EAPI/prefix/} ]] ; then
59 # PREFIX HACK: just remove "prefix" from EAPI here, this file
60 # currently assumes EAPI to contain a single token, and "prefix"
61 # is ortogonal to all supported EAPIs here.
62
63 Modified: main/branches/prefix/pym/_emerge/__init__.py
64 ===================================================================
65 --- main/branches/prefix/pym/_emerge/__init__.py 2008-10-28 18:51:42 UTC (rev 11735)
66 +++ main/branches/prefix/pym/_emerge/__init__.py 2008-10-28 19:09:53 UTC (rev 11736)
67 @@ -13788,15 +13788,22 @@
68 display_missing_pkg_set(root_config, s)
69 return (None, 1)
70 setconfig.active.append(s)
71 + try:
72 + set_atoms = setconfig.getSetAtoms(s)
73 + except portage.exception.PackageSetNotFound, e:
74 + writemsg_level(("emerge: the given set '%s' " + \
75 + "contains a non-existent set named '%s'.\n") % \
76 + (s, e), level=logging.ERROR, noiselevel=-1)
77 + return (None, 1)
78 if myaction in unmerge_actions and \
79 not sets[s].supportsOperation("unmerge"):
80 sys.stderr.write("emerge: the given set '%s' does " % s + \
81 "not support unmerge operations\n")
82 retval = 1
83 - elif not setconfig.getSetAtoms(s):
84 + elif not set_atoms:
85 print "emerge: '%s' is an empty set" % s
86 elif myaction not in do_not_expand:
87 - newargs.extend(setconfig.getSetAtoms(s))
88 + newargs.extend(set_atoms)
89 else:
90 newargs.append(SETPREFIX+s)
91 for e in sets[s].errors:
92
93 Modified: main/branches/prefix/pym/portage/__init__.py
94 ===================================================================
95 --- main/branches/prefix/pym/portage/__init__.py 2008-10-28 18:51:42 UTC (rev 11735)
96 +++ main/branches/prefix/pym/portage/__init__.py 2008-10-28 19:09:53 UTC (rev 11736)
97 @@ -3359,6 +3359,9 @@
98 def fetch(myuris, mysettings, listonly=0, fetchonly=0, locks_in_subdir=".locks",use_locks=1, try_mirrors=1):
99 "fetch files. Will use digest file if available."
100
101 + if not myuris:
102 + return 1
103 +
104 features = mysettings.features
105 restrict = mysettings.get("PORTAGE_RESTRICT","").split()
106
107 @@ -3603,7 +3606,12 @@
108 write_test_file = os.path.join(
109 mydir, ".__portage_test_write__")
110
111 - if os.path.isdir(mydir):
112 + try:
113 + st = os.stat(mydir)
114 + except OSError:
115 + st = None
116 +
117 + if st is not None and stat.S_ISDIR(st.st_mode):
118 if not (userfetch or userpriv):
119 continue
120 if _userpriv_test_write_file(mysettings, write_test_file):
121 @@ -3611,6 +3619,10 @@
122
123 _userpriv_test_write_file_cache.pop(write_test_file, None)
124 if portage.util.ensure_dirs(mydir, gid=dir_gid, mode=dirmode, mask=modemask):
125 + if st is None:
126 + # The directory has just been created
127 + # and therefore it must be empty.
128 + continue
129 writemsg("Adjusting permissions recursively: '%s'\n" % mydir,
130 noiselevel=-1)
131 def onerror(e):
132 @@ -5704,7 +5716,7 @@
133 mysettings["PORTAGE_ACTUAL_DISTDIR"] = orig_distdir
134 edpath = mysettings["DISTDIR"] = \
135 os.path.join(mysettings["PORTAGE_BUILDDIR"], "distdir")
136 - portage.util.ensure_dirs(edpath, uid=portage_uid, mode=0755)
137 + portage.util.ensure_dirs(edpath, gid=portage_gid, mode=0755)
138
139 # Remove any unexpected files or directories.
140 for x in os.listdir(edpath):
141
142 Modified: main/branches/prefix/pym/portage/dbapi/vartree.py
143 ===================================================================
144 --- main/branches/prefix/pym/portage/dbapi/vartree.py 2008-10-28 18:51:42 UTC (rev 11735)
145 +++ main/branches/prefix/pym/portage/dbapi/vartree.py 2008-10-28 19:09:53 UTC (rev 11736)
146 @@ -144,9 +144,10 @@
147
148 def __init__(self, vardbapi):
149 self._dbapi = vardbapi
150 + self._root = self._dbapi.root
151 self._libs = {}
152 self._obj_properties = {}
153 - self._defpath = set(getlibpaths())
154 + self._defpath = set(getlibpaths(self._root))
155 self._obj_key_cache = {}
156
157 class _ObjectKey(object):
158 @@ -155,7 +156,7 @@
159
160 __slots__ = ("__weakref__", "_key")
161
162 - def __init__(self, object):
163 + def __init__(self, object, root):
164 """
165 This takes a path to an object.
166
167 @@ -163,7 +164,7 @@
168 @type object: string (example: '/usr/bin/bar')
169
170 """
171 - self._key = self._generate_object_key(object)
172 + self._key = self._generate_object_key(object, root)
173
174 def __hash__(self):
175 return hash(self._key)
176 @@ -171,7 +172,7 @@
177 def __eq__(self, other):
178 return self._key == other._key
179
180 - def _generate_object_key(self, object):
181 + def _generate_object_key(self, object, root):
182 """
183 Generate object key for a given object.
184
185 @@ -185,12 +186,13 @@
186 2. realpath of object if object does not exist.
187
188 """
189 + abs_path = os.path.join(root, object.lstrip(os.path.sep))
190 try:
191 - object_stat = os.stat(object)
192 + object_stat = os.stat(abs_path)
193 except OSError:
194 # Use the realpath as the key if the file does not exists on the
195 # filesystem.
196 - return os.path.realpath(object)
197 + return os.path.realpath(abs_path)
198 # Return a tuple of the device and inode.
199 return (object_stat.st_dev, object_stat.st_ino)
200
201 @@ -207,6 +209,7 @@
202 return isinstance(self._key, tuple)
203
204 def rebuild(self, include_file=None):
205 + root = self._root
206 libs = {}
207 obj_key_cache = {}
208 obj_properties = {}
209 @@ -239,9 +242,10 @@
210 continue
211 arch = fields[0]
212 obj = fields[1]
213 - obj_key = self._ObjectKey(obj)
214 + obj_key = self._ObjectKey(obj, root)
215 soname = fields[2]
216 - path = set([normalize_path(x)
217 + path = set([
218 + normalize_path(os.path.join(self._root, x.lstrip(os.path.sep)))
219 for x in filter(None, fields[3].replace(
220 "${ORIGIN}", os.path.dirname(obj)).replace(
221 "$ORIGIN", os.path.dirname(obj)).split(":"))])
222 @@ -313,7 +317,7 @@
223 if obj in self._obj_key_cache:
224 obj_key = self._obj_key_cache.get(obj)
225 else:
226 - obj_key = self._ObjectKey(obj)
227 + obj_key = self._ObjectKey(obj, self._root)
228 # Check that the library exists on the filesystem.
229 if obj_key.file_exists():
230 # Get the arch and soname from LinkageMap._obj_properties if
231 @@ -427,7 +431,7 @@
232
233 """
234 basename = os.path.basename(obj)
235 - obj_key = self._ObjectKey(obj)
236 + obj_key = self._ObjectKey(obj, self._root)
237 if obj_key not in self._obj_properties:
238 raise KeyError("%s (%s) not in object list" % (obj_key, obj))
239 soname = self._obj_properties[obj_key][3]
240 @@ -501,7 +505,7 @@
241 else:
242 obj_key = self._obj_key_cache.get(obj)
243 if obj_key not in self._obj_properties:
244 - obj_key = self._ObjectKey(obj)
245 + obj_key = self._ObjectKey(obj, self._root)
246 if obj_key not in self._obj_properties:
247 raise KeyError("%s (%s) not in object list" % (obj_key, obj))
248
249 @@ -516,7 +520,8 @@
250 for provider_key in self._libs[soname][arch]["providers"]:
251 providers = self._obj_properties[provider_key][4]
252 for provider in providers:
253 - if os.path.dirname(provider) in path:
254 + if os.path.join(self._root,
255 + os.path.dirname(provider).lstrip(os.path.sep)) in path:
256 rValue[soname].add(provider)
257 return rValue
258
259 @@ -555,7 +560,7 @@
260 objs = set([obj])
261 obj_key = self._obj_key_cache.get(obj)
262 if obj_key not in self._obj_properties:
263 - obj_key = self._ObjectKey(obj)
264 + obj_key = self._ObjectKey(obj, self._root)
265 if obj_key not in self._obj_properties:
266 raise KeyError("%s (%s) not in object list" % (obj_key, obj))
267
268 @@ -568,8 +573,8 @@
269 # have any consumers.
270 if not isinstance(obj, self._ObjectKey):
271 soname = self._obj_properties[obj_key][3]
272 - obj_dir = os.path.dirname(obj)
273 - master_link = os.path.join(obj_dir, soname)
274 + master_link = os.path.join(self._root,
275 + os.path.dirname(obj).lstrip(os.path.sep), soname)
276 try:
277 master_st = os.stat(master_link)
278 obj_st = os.stat(obj)
279 @@ -598,6 +603,7 @@
280
281 def __init__(self, vardbapi):
282 self._dbapi = vardbapi
283 + self._root = self._dbapi.root
284 self._libs = {}
285 self._obj_properties = {}
286 self._obj_key_cache = {}
287 @@ -608,7 +614,7 @@
288
289 __slots__ = ("__weakref__", "_key")
290
291 - def __init__(self, object):
292 + def __init__(self, object, root):
293 """
294 This takes a path to an object.
295
296 @@ -616,7 +622,7 @@
297 @type object: string (example: '/usr/bin/bar')
298
299 """
300 - self._key = self._generate_object_key(object)
301 + self._key = self._generate_object_key(object, root)
302
303 def __hash__(self):
304 return hash(self._key)
305 @@ -624,7 +630,7 @@
306 def __eq__(self, other):
307 return self._key == other._key
308
309 - def _generate_object_key(self, object):
310 + def _generate_object_key(self, object, root):
311 """
312 Generate object key for a given object.
313
314 @@ -638,12 +644,13 @@
315 2. realpath of object if object does not exist.
316
317 """
318 + abs_path = os.path.join(root, object.lstrip(os.path.sep))
319 try:
320 - object_stat = os.stat(object)
321 + object_stat = os.stat(abs_path)
322 except OSError:
323 # Use the realpath as the key if the file does not exists on the
324 # filesystem.
325 - return os.path.realpath(object)
326 + return os.path.realpath(abs_path)
327 # Return a tuple of the device and inode.
328 return (object_stat.st_dev, object_stat.st_ino)
329
330 @@ -660,6 +667,7 @@
331 return isinstance(self._key, tuple)
332
333 def rebuild(self, include_file=None):
334 + root = self._root
335 libs = {}
336 obj_key_cache = {}
337 obj_properties = {}
338 @@ -695,7 +703,7 @@
339 # the install_name of the library in the object.
340 arch = fields[0]
341 obj = fields[1]
342 - obj_key = self._ObjectKey(obj)
343 + obj_key = self._ObjectKey(obj, root)
344 install_name = os.path.normpath(fields[2])
345 needed = filter(None, fields[3].split(","))
346
347 @@ -772,7 +780,7 @@
348 if obj in self._obj_key_cache:
349 obj_key = self._obj_key_cache.get(obj)
350 else:
351 - obj_key = self._ObjectKey(obj)
352 + obj_key = self._ObjectKey(obj, self._root)
353 # Check that the library exists on the filesystem.
354 if obj_key.file_exists():
355 # Get the install_name from LinkageMapMachO._obj_properties if
356 @@ -870,7 +878,7 @@
357
358 """
359 basename = os.path.basename(obj)
360 - obj_key = self._ObjectKey(obj)
361 + obj_key = self._ObjectKey(obj, self._root)
362 if obj_key not in self._obj_properties:
363 raise KeyError("%s (%s) not in object list" % (obj_key, obj))
364 install_name = self._obj_properties[obj_key][2]
365 @@ -944,7 +952,7 @@
366 else:
367 obj_key = self._obj_key_cache.get(obj)
368 if obj_key not in self._obj_properties:
369 - obj_key = self._ObjectKey(obj)
370 + obj_key = self._ObjectKey(obj, self._root)
371 if obj_key not in self._obj_properties:
372 raise KeyError("%s (%s) not in object list" % (obj_key, obj))
373
374 @@ -958,7 +966,8 @@
375 for provider_key in self._libs[install_name][arch]["providers"]:
376 providers = self._obj_properties[provider_key][3]
377 for provider in providers:
378 - if os.path.exists(provider):
379 + if os.path.exists(os.path.join(self._root,
380 + provider.lstrip(os.path.sep))):
381 rValue[install_name].add(provider)
382 return rValue
383
384 @@ -997,7 +1006,7 @@
385 objs = set([obj])
386 obj_key = self._obj_key_cache.get(obj)
387 if obj_key not in self._obj_properties:
388 - obj_key = self._ObjectKey(obj)
389 + obj_key = self._ObjectKey(obj, self._root)
390 if obj_key not in self._obj_properties:
391 raise KeyError("%s (%s) not in object list" % (obj_key, obj))
392
393 @@ -1006,7 +1015,8 @@
394 # other version, this lib will be shadowed and won't
395 # have any consumers.
396 if not isinstance(obj, self._ObjectKey):
397 - master_link = self._obj_properties[obj_key][2]
398 + master_link = os.path.join(self._root,
399 + self._obj_properties[obj_key][2].lstrip(os.path.sep))
400 try:
401 master_st = os.stat(master_link)
402 obj_st = os.stat(obj)
403 @@ -2863,13 +2873,30 @@
404 old_libs = old_contents.intersection(liblist)
405
406 # get list of libraries from new package instance
407 - mylibs = set([os.path.join(os.sep, x) for x in mycontents]).intersection(liblist)
408 + mycontents = set(os.path.join(os.path.sep, x) for x in mycontents)
409 + mylibs = mycontents.intersection(liblist)
410
411 # check which libs are present in the old, but not the new package instance
412 candidates = old_libs.difference(mylibs)
413 -
414 + candidates_inodes = set()
415 + for x in candidates:
416 + x_destroot = os.path.join(destroot, x.lstrip(os.path.sep))
417 + try:
418 + st = os.stat(x_destroot)
419 + except OSError:
420 + continue
421 + candidates_inodes.add((st.st_dev, st.st_ino))
422 +
423 for x in old_contents:
424 - if os.path.islink(x) and os.path.realpath(x) in candidates and x not in mycontents:
425 + x_destroot = os.path.join(destroot, x.lstrip(os.path.sep))
426 + if not os.path.islink(x_destroot):
427 + continue
428 + try:
429 + st = os.stat(x_destroot)
430 + except OSError:
431 + continue
432 + if (st.st_dev, st.st_ino) in candidates_inodes and \
433 + x not in mycontents:
434 candidates.add(x)
435
436 provider_cache = {}
437 @@ -2941,12 +2968,14 @@
438 candidates_stack = list(candidates)
439 while candidates_stack:
440 x = candidates_stack.pop()
441 + x_srcroot = os.path.join(srcroot, x.lstrip(os.path.sep))
442 + x_destroot = os.path.join(destroot, x.lstrip(os.path.sep))
443 # skip existing files so the 'new' libs aren't overwritten
444 if os.path.exists(os.path.join(srcroot, x.lstrip(os.sep))):
445 continue
446 showMessage("injecting %s into %s\n" % (x, srcroot),
447 noiselevel=-1)
448 - if not os.path.exists(os.path.join(destroot, x.lstrip(os.sep))):
449 + if not os.path.exists(x_destroot):
450 showMessage("%s does not exist so can't be preserved\n" % x,
451 noiselevel=-1)
452 continue
453 @@ -2957,8 +2986,8 @@
454 # resolve symlinks and extend preserve list
455 # NOTE: we're extending the list in the loop to emulate recursion to
456 # also get indirect symlinks
457 - if os.path.islink(x):
458 - linktarget = os.readlink(x)
459 + if os.path.islink(x_destroot):
460 + linktarget = os.readlink(x_destroot)
461 os.symlink(linktarget, os.path.join(srcroot, x.lstrip(os.sep)))
462 if linktarget[0] != os.sep:
463 linktarget = os.path.join(os.path.dirname(x), linktarget)
464 @@ -2966,8 +2995,7 @@
465 candidates.add(linktarget)
466 candidates_stack.append(linktarget)
467 else:
468 - shutil.copy2(os.path.join(destroot, x.lstrip(os.sep)),
469 - os.path.join(srcroot, x.lstrip(os.sep)))
470 + shutil.copy2(x_destroot, x_srcroot)
471 preserve_paths.append(x)
472
473 del candidates
474
475 Modified: main/branches/prefix/pym/portage/sets/__init__.py
476 ===================================================================
477 --- main/branches/prefix/pym/portage/sets/__init__.py 2008-10-28 18:51:42 UTC (rev 11735)
478 +++ main/branches/prefix/pym/portage/sets/__init__.py 2008-10-28 19:09:53 UTC (rev 11736)
479 @@ -2,10 +2,14 @@
480 # Distributed under the terms of the GNU General Public License v2
481 # $Id$
482
483 +__all__ = ["SETPREFIX", "get_boolean", "SetConfigError",
484 + "SetConfig", "load_default_config"]
485 +
486 import os
487 from ConfigParser import SafeConfigParser, NoOptionError
488 from portage import load_mod
489 from portage.const import USER_CONFIG_PATH, GLOBAL_CONFIG_PATH
490 +from portage.exception import PackageSetNotFound
491
492 SETPREFIX = "@"
493
494 @@ -131,7 +135,13 @@
495 return self.psets.copy()
496
497 def getSetAtoms(self, setname, ignorelist=None):
498 - myset = self.getSets()[setname]
499 + """
500 + This raises PackageSetNotFound if the give setname does not exist.
501 + """
502 + try:
503 + myset = self.getSets()[setname]
504 + except KeyError:
505 + raise PackageSetNotFound(setname)
506 myatoms = myset.getAtoms()
507 parser = self._parser
508 extend = set()
509 @@ -150,8 +160,12 @@
510
511 ignorelist.add(setname)
512 for n in myset.getNonAtoms():
513 - if n.startswith(SETPREFIX) and n[len(SETPREFIX):] in self.psets:
514 - extend.add(n[len(SETPREFIX):])
515 + if n.startswith(SETPREFIX):
516 + s = n[len(SETPREFIX):]
517 + if s in self.psets:
518 + extend.add(n[len(SETPREFIX):])
519 + else:
520 + raise PackageSetNotFound(s)
521
522 for s in ignorelist:
523 extend.discard(s)
524
525 Modified: main/branches/prefix/pym/portage/util.py
526 ===================================================================
527 --- main/branches/prefix/pym/portage/util.py 2008-10-28 18:51:42 UTC (rev 11735)
528 +++ main/branches/prefix/pym/portage/util.py 2008-10-28 19:09:53 UTC (rev 11736)
529 @@ -1213,7 +1213,7 @@
530 return old_pfile
531 return new_pfile
532
533 -def getlibpaths():
534 +def getlibpaths(root):
535 """ Return a list of paths that are used for library lookups """
536
537 # PREFIX HACK: LD_LIBRARY_PATH isn't portable, and considered
538 @@ -1229,11 +1229,12 @@
539 else:
540 # the following is based on the information from ld.so(8)
541 rval = os.environ.get("LD_LIBRARY_PATH", "").split(":")
542 - rval.extend(grabfile("/etc/ld.so.conf"))
543 + rval.extend(grabfile(os.path.join(root, "etc", "ld.so.conf")))
544 rval.append("/usr/lib")
545 rval.append("/lib")
546
547 - rval = [normalize_path(x) for x in rval if x != ""]
548 -
549 + rval = [normalize_path(os.path.join(root, x.lstrip(os.path.sep))) \
550 + for x in rval if x]
551 +
552 return rval