Gentoo Archives: gentoo-commits

From: "Fabian Groffen (grobian)" <grobian@g.o>
To: gentoo-commits@l.g.o
Subject: [gentoo-commits] portage r10243 - in main/branches/prefix: bin pym/_emerge pym/portage pym/portage/dbapi
Date: Thu, 08 May 2008 19:14:27
Message-Id: E1JuBZP-0003tQ-GU@stork.gentoo.org
1 Author: grobian
2 Date: 2008-05-08 19:14:22 +0000 (Thu, 08 May 2008)
3 New Revision: 10243
4
5 Modified:
6 main/branches/prefix/bin/isolated-functions.sh
7 main/branches/prefix/pym/_emerge/__init__.py
8 main/branches/prefix/pym/portage/__init__.py
9 main/branches/prefix/pym/portage/const.py
10 main/branches/prefix/pym/portage/dbapi/vartree.py
11 Log:
12 Merged from trunk 10182:10208
13
14 | 10184 | In the package uninstall sanity check, use RDEPEND from the |
15 | zmedico | currently running 'sys-apps/portage' instance to create a |
16 | | set of protected atoms. |
17
18 | 10186 | Fix misplaced variable. |
19 | zmedico | |
20
21 | 10188 | Use a separate digraph to preserve irrelevant blocker |
22 | zmedico | relationships that are removed from |
23 | | depgraph._blocker_parents since the irrelevant blockers are |
24 | | still needed for the blocker cache. |
25
26 | 10190 | Use writemsg() to warn about InvalidDependString exceptions |
27 | zmedico | that may occur for installed packages. |
28
29 | 10192 | Bug #220171 - Filter out 'lost+found' directories in |
30 | zmedico | vardbapi.cpv_all() in order to avoid fatal 'Permission |
31 | | denied' errors. Currently, CVS and names beginning with '.' |
32 | | are also filtered. |
33
34 | 10194 | * Fix --buildpkgonly logic to avoid an unwanted code path. * |
35 | zmedico | Remove unnecessary mtimedb.pop("resume", None) call. |
36
37 | 10195 | Bug #219286 - Whitelist INSTALL_MASK so that it works |
38 | zmedico | properly for binary packages. Also, filter INSTALL_MASK when |
39 | | saving or loading environment.bz2. This also applies to |
40 | | PKG_INSTALL_MASK and DOC_SYMLINKS_DIR, so add them too. |
41
42 | 10198 | Add "package" to EBUILD_PHASES since it's possible for einfo |
43 | zmedico | to be called by install_mask() during that phase. |
44
45 | 10200 | fix preserve_libs logic to properly account for the current |
46 | genone | package instance |
47
48 | 10202 | Handle a potential InvalidData exception in |
49 | zmedico | vardbapi.cp_all(). |
50
51 | 10204 | * In vardbapi.cpv_all() use catpkgsplit() for validation |
52 | zmedico | since that's what with cp_all() uses. * Use the listdir() |
53 | | dirsonly=1 parameter to avoid unnecessary stat calls via |
54 | | os.path.isdir(). |
55
56 | 10206 | Add -MERGING-.* to vardbapi._excluded_dirs. |
57 | zmedico | |
58
59 | 10208 | Use vardbapi._excluded_dirs to filter results inside |
60 | zmedico | cp_list(). |
61
62
63 Modified: main/branches/prefix/bin/isolated-functions.sh
64 ===================================================================
65 --- main/branches/prefix/bin/isolated-functions.sh 2008-05-08 19:04:29 UTC (rev 10242)
66 +++ main/branches/prefix/bin/isolated-functions.sh 2008-05-08 19:14:22 UTC (rev 10243)
67 @@ -503,6 +503,9 @@
68 # Prefix additions
69 unset BPREFIX DEFAULT_PATH EPREFIX EROOT PORTAGE_GROUP PORTAGE_USER
70
71 + # user config variables
72 + unset DOC_SYMLINKS_DIR INSTALL_MASK PKG_INSTALL_MASK
73 +
74 set
75 export
76 )
77
78 Modified: main/branches/prefix/pym/_emerge/__init__.py
79 ===================================================================
80 --- main/branches/prefix/pym/_emerge/__init__.py 2008-05-08 19:04:29 UTC (rev 10242)
81 +++ main/branches/prefix/pym/_emerge/__init__.py 2008-05-08 19:14:22 UTC (rev 10243)
82 @@ -1814,6 +1814,8 @@
83 self._blocker_uninstalls = digraph()
84 # Contains only Package -> Blocker edges
85 self._blocker_parents = digraph()
86 + # Contains only irrelevant Package -> Blocker edges
87 + self._irrelevant_blockers = digraph()
88 # Contains only unsolvable Package -> Blocker edges
89 self._unsolvable_blockers = digraph()
90 self._slot_collision_info = set()
91 @@ -3199,10 +3201,17 @@
92 blocker_atoms = None
93 blockers = None
94 if self.digraph.contains(pkg):
95 + blockers = []
96 try:
97 - blockers = self._blocker_parents.child_nodes(pkg)
98 + blockers.extend(
99 + self._blocker_parents.child_nodes(pkg))
100 except KeyError:
101 - blockers = []
102 + pass
103 + try:
104 + blockers.extend(
105 + self._irrelevant_blockers.child_nodes(pkg))
106 + except KeyError:
107 + pass
108 if blockers is not None:
109 blockers = set("!" + blocker.atom \
110 for blocker in blockers)
111 @@ -3334,6 +3343,7 @@
112 self._blocker_parents.remove(blocker)
113 # Discard any parents that don't have any more blockers.
114 for pkg in parent_pkgs:
115 + self._irrelevant_blockers.add(blocker, pkg)
116 if not self._blocker_parents.child_nodes(pkg):
117 self._blocker_parents.remove(pkg)
118 continue
119 @@ -3408,6 +3418,7 @@
120 # merged.
121 self._blocker_uninstalls.addnode(uninst_task, blocker)
122 if not unresolved_blocks and not depends_on_order:
123 + self._irrelevant_blockers.add(blocker, parent)
124 self._blocker_parents.remove_edge(blocker, parent)
125 if not self._blocker_parents.parent_nodes(blocker):
126 self._blocker_parents.remove(blocker)
127 @@ -3514,19 +3525,43 @@
128 node.operation != "uninstall"]
129
130 # sys-apps/portage needs special treatment if ROOT="/"
131 - portage_python_dep = ">=dev-lang/python-2.4"
132 - portage_unslotted_deps = frozenset(
133 - ["app-shells/bash", "sys-apps/portage"])
134 - portage_node = self.mydbapi["/"].match_pkgs("sys-apps/portage")
135 - if portage_node:
136 - portage_node = portage_node[0]
137 + running_root = "/"
138 + from portage.const import PORTAGE_PACKAGE_ATOM
139 + runtime_deps = InternalPackageSet(
140 + initial_atoms=[PORTAGE_PACKAGE_ATOM])
141 + running_portage = self.trees[running_root]["vartree"].dbapi.match_pkgs(
142 + PORTAGE_PACKAGE_ATOM)
143 + replacement_portage = self.mydbapi[running_root].match_pkgs(
144 + PORTAGE_PACKAGE_ATOM)
145 +
146 + if running_portage:
147 + running_portage = running_portage[0]
148 else:
149 - portage_node = None
150 - if portage_node is not None and \
151 - (not mygraph.contains(portage_node) or \
152 - portage_node.operation == "nomerge"):
153 - portage_node = None
154 + running_portage = None
155
156 + if replacement_portage:
157 + replacement_portage = replacement_portage[0]
158 + else:
159 + replacement_portage = None
160 +
161 + if replacement_portage == running_portage:
162 + replacement_portage = None
163 +
164 + if running_portage is not None:
165 + try:
166 + portage_rdepend = self._select_atoms_highest_available(
167 + running_root, running_portage.metadata["RDEPEND"],
168 + myuse=running_portage.metadata["USE"].split(),
169 + parent=running_portage, strict=False)
170 + except portage.exception.InvalidDependString, e:
171 + portage.writemsg("!!! Invalid RDEPEND in " + \
172 + "'%svar/db/pkg/%s/RDEPEND': %s\n" % \
173 + (running_root, running_portage.cpv, e), noiselevel=-1)
174 + del e
175 + portage_rdepend = []
176 + runtime_deps.update(atom for atom in portage_rdepend \
177 + if not atom.startswith("!"))
178 +
179 ignore_priority_soft_range = [None]
180 ignore_priority_soft_range.extend(
181 xrange(DepPriority.MIN, DepPriority.MEDIUM_SOFT + 1))
182 @@ -3609,7 +3644,8 @@
183 return True
184 if node not in mergeable_nodes:
185 return False
186 - if node == portage_node and mygraph.child_nodes(node,
187 + if node == replacement_portage and \
188 + mygraph.child_nodes(node,
189 ignore_priority=DepPriority.MEDIUM_SOFT):
190 # Make sure that portage always has all of it's
191 # RDEPENDs installed first.
192 @@ -3704,20 +3740,26 @@
193 if self.digraph.contains(inst_pkg):
194 continue
195
196 - if "/" == task.root:
197 + if running_root == task.root:
198 # Never uninstall sys-apps/portage or it's essential
199 # dependencies, except through replacement.
200 - if task.cp in portage_unslotted_deps:
201 + try:
202 + runtime_dep_atoms = \
203 + list(runtime_deps.iterAtomsForPackage(task))
204 + except portage.exception.InvalidDependString, e:
205 + portage.writemsg("!!! Invalid PROVIDE in " + \
206 + "'%svar/db/pkg/%s/PROVIDE': %s\n" % \
207 + (task.root, task.cpv, e), noiselevel=-1)
208 + del e
209 continue
210
211 - # Don't uninstall python if it appears to be
212 - # the only suitable one installed.
213 - if task.cp == "dev-lang/python" and \
214 - portage.match_from_list(
215 - portage_python_dep, [task.cpv_slot]):
216 - vardb = root_config.trees["vartree"].dbapi
217 + # Don't uninstall a runtime dep if it appears
218 + # to be the only suitable one installed.
219 + skip = False
220 + vardb = root_config.trees["vartree"].dbapi
221 + for atom in runtime_dep_atoms:
222 other_version = None
223 - for pkg in vardb.match_pkgs(portage_python_dep):
224 + for pkg in vardb.match_pkgs(atom):
225 if pkg.cpv == task.cpv and \
226 pkg.metadata["COUNTER"] == \
227 task.metadata["COUNTER"]:
228 @@ -3725,7 +3767,10 @@
229 other_version = pkg
230 break
231 if other_version is None:
232 - continue
233 + skip = True
234 + break
235 + if skip:
236 + continue
237
238 # For packages in the system set, don't take
239 # any chances. If the conflict can't be resolved
240 @@ -3736,7 +3781,11 @@
241 "system"].iterAtomsForPackage(task):
242 skip = True
243 break
244 - except portage.exception.InvalidDependString:
245 + except portage.exception.InvalidDependString, e:
246 + portage.writemsg("!!! Invalid PROVIDE in " + \
247 + "'%svar/db/pkg/%s/PROVIDE': %s\n" % \
248 + (task.root, task.cpv, e), noiselevel=-1)
249 + del e
250 skip = True
251 if skip:
252 continue
253 @@ -3765,7 +3814,11 @@
254 if not satisfied:
255 skip = True
256 break
257 - except portage.exception.InvalidDependString:
258 + except portage.exception.InvalidDependString, e:
259 + portage.writemsg("!!! Invalid PROVIDE in " + \
260 + "'%svar/db/pkg/%s/PROVIDE': %s\n" % \
261 + (task.root, task.cpv, e), noiselevel=-1)
262 + del e
263 skip = True
264 if skip:
265 continue
266 @@ -7862,7 +7915,7 @@
267 del mtimedb[k]
268 continue
269 favorites = resume_data.get("favorites")
270 - if not isinstance(resume_opts, list):
271 + if not isinstance(favorites, list):
272 del mtimedb[k]
273 continue
274
275 @@ -8179,8 +8232,7 @@
276 retval = mergetask.merge(pkglist, favorites, mtimedb)
277 merge_count = mergetask.curval
278
279 - if retval == os.EX_OK and not (pretend or fetchonly):
280 - mtimedb.pop("resume", None)
281 + if retval == os.EX_OK and not (buildpkgonly or fetchonly or pretend):
282 if "yes" == settings.get("AUTOCLEAN"):
283 portage.writemsg_stdout(">>> Auto-cleaning packages...\n")
284 unmerge(trees[settings["ROOT"]]["root_config"],
285
286 Modified: main/branches/prefix/pym/portage/__init__.py
287 ===================================================================
288 --- main/branches/prefix/pym/portage/__init__.py 2008-05-08 19:04:29 UTC (rev 10242)
289 +++ main/branches/prefix/pym/portage/__init__.py 2008-05-08 19:14:22 UTC (rev 10243)
290 @@ -943,7 +943,12 @@
291 "PORTAGE_GROUP", "PORTAGE_USER",
292 ]
293
294 + # user config variables
295 _environ_whitelist += [
296 + "DOC_SYMLINKS_DIR", "INSTALL_MASK", "PKG_INSTALL_MASK"
297 + ]
298 +
299 + _environ_whitelist += [
300 "A", "AA", "CATEGORY", "P", "PF", "PN", "PR", "PV", "PVR"
301 ]
302
303
304 Modified: main/branches/prefix/pym/portage/const.py
305 ===================================================================
306 --- main/branches/prefix/pym/portage/const.py 2008-05-08 19:04:29 UTC (rev 10242)
307 +++ main/branches/prefix/pym/portage/const.py 2008-05-08 19:14:22 UTC (rev 10243)
308 @@ -35,6 +35,7 @@
309 PORTAGE_BASE_PATH = PORTAGE_BASE
310 PORTAGE_BIN_PATH = PORTAGE_BASE_PATH+"/bin"
311 PORTAGE_PYM_PATH = PORTAGE_BASE_PATH+"/pym"
312 +PORTAGE_PACKAGE_ATOM = "sys-apps/portage"
313 NEWS_LIB_PATH = EPREFIX+"/var/lib/gentoo"
314 PROFILE_PATH = EPREFIX+"/etc/make.profile"
315 LOCALE_DATA_PATH = PORTAGE_BASE_PATH+"/locale"
316 @@ -66,7 +67,8 @@
317 "CONFIG_PROTECT_MASK", "CONFIG_PROTECT",
318 "PRELINK_PATH", "PRELINK_PATH_MASK", "PROFILE_ONLY_VARIABLES"]
319 EBUILD_PHASES = ["setup", "unpack", "compile", "test", "install",
320 - "preinst", "postinst", "prerm", "postrm", "other"]
321 + "package", "preinst", "postinst","prerm", "postrm",
322 + "other"]
323
324 EAPI = 1
325
326
327 Modified: main/branches/prefix/pym/portage/dbapi/vartree.py
328 ===================================================================
329 --- main/branches/prefix/pym/portage/dbapi/vartree.py 2008-05-08 19:04:29 UTC (rev 10242)
330 +++ main/branches/prefix/pym/portage/dbapi/vartree.py 2008-05-08 19:14:22 UTC (rev 10243)
331 @@ -9,7 +9,7 @@
332 from portage.dbapi import dbapi
333 from portage.dep import dep_getslot, use_reduce, paren_reduce, isvalidatom, \
334 isjustname, dep_getkey, match_from_list
335 -from portage.exception import InvalidPackageName, InvalidAtom, \
336 +from portage.exception import InvalidAtom, InvalidData, InvalidPackageName, \
337 FileNotFound, PermissionDenied, UnsupportedAPIException
338 from portage.locks import lockdir, unlockdir
339 from portage.output import bold, red, green
340 @@ -132,13 +132,16 @@
341 self._obj_properties = {}
342 self._defpath = getlibpaths()
343
344 - def rebuild(self):
345 + def rebuild(self, include_file=None):
346 libs = {}
347 obj_properties = {}
348 lines = []
349 for cpv in self._dbapi.cpv_all():
350 lines += grabfile(self._dbapi.getpath(cpv, filename="NEEDED.ELF.2"))
351 -
352 +
353 + if include_file:
354 + lines += grabfile(include_file)
355 +
356 # have to call scanelf for preserved libs here as they aren't
357 # registered in NEEDED.ELF.2 files
358 if self._dbapi.plib_registry and self._dbapi.plib_registry.getPreservedLibs():
359 @@ -187,10 +190,11 @@
360 def findProviders(self, obj):
361 if not self._libs:
362 self.rebuild()
363 - obj = os.path.realpath(obj)
364 rValue = {}
365 if obj not in self._obj_properties:
366 - raise KeyError("%s not in object list" % obj)
367 + obj = os.path.realpath(obj)
368 + if obj not in self._obj_properties:
369 + raise KeyError("%s not in object list" % obj)
370 arch, needed, path, soname = self._obj_properties[obj]
371 path.extend(self._defpath)
372 path = [os.path.realpath(x) for x in path]
373 @@ -208,7 +212,10 @@
374 def findConsumers(self, obj):
375 if not self._libs:
376 self.rebuild()
377 - obj = os.path.realpath(obj)
378 + if obj not in self._obj_properties:
379 + obj = os.path.realpath(obj)
380 + if obj not in self._obj_properties:
381 + raise KeyError("%s not in object list" % obj)
382 rValue = set()
383 for soname in self._libs:
384 for arch in self._libs[soname]:
385 @@ -307,6 +314,12 @@
386 return rValue
387
388 class vardbapi(dbapi):
389 +
390 + _excluded_dirs = ["CVS", "lost+found"]
391 + _excluded_dirs = [re.escape(x) for x in _excluded_dirs]
392 + _excluded_dirs = re.compile(r'^(\..*|-MERGING-.*|' + \
393 + "|".join(_excluded_dirs) + r')$')
394 +
395 def __init__(self, root, categories=None, settings=None, vartree=None):
396 """
397 The categories parameter is unused since the dbapi class
398 @@ -507,11 +520,8 @@
399
400 returnme = []
401 for x in dir_list:
402 - if x.startswith("."):
403 + if self._excluded_dirs.match(x) is not None:
404 continue
405 - if x[0] == '-':
406 - #writemsg(red("INCOMPLETE MERGE:")+str(x[len("-MERGING-"):])+"\n")
407 - continue
408 ps = pkgsplit(x)
409 if not ps:
410 self.invalidentry(os.path.join(self.getpath(mysplit[0]), x))
411 @@ -530,15 +540,23 @@
412 returnme = []
413 basepath = os.path.join(self.root, VDB_PATH) + os.path.sep
414 for x in listdir(basepath, EmptyOnError=1, ignorecvs=1, dirsonly=1):
415 + if self._excluded_dirs.match(x) is not None:
416 + continue
417 if not self._category_re.match(x):
418 continue
419 - for y in listdir(basepath + x, EmptyOnError=1):
420 - if y.startswith("."):
421 + for y in listdir(basepath + x, EmptyOnError=1, dirsonly=1):
422 + if self._excluded_dirs.match(y) is not None:
423 continue
424 subpath = x + "/" + y
425 # -MERGING- should never be a cpv, nor should files.
426 - if os.path.isdir(basepath + subpath) and (pkgsplit(y) is not None):
427 - returnme += [subpath]
428 + try:
429 + if catpkgsplit(subpath) is None:
430 + self.invalidentry(os.path.join(self.root, subpath))
431 + continue
432 + except portage.exception.InvalidData:
433 + self.invalidentry(os.path.join(self.root, subpath))
434 + continue
435 + returnme.append(subpath)
436 return returnme
437
438 def cp_all(self, use_cache=1):
439 @@ -547,7 +565,11 @@
440 for y in mylist:
441 if y[0] == '*':
442 y = y[1:]
443 - mysplit = catpkgsplit(y)
444 + try:
445 + mysplit = catpkgsplit(y)
446 + except portage.exception.InvalidData:
447 + self.invalidentry(self.getpath(y))
448 + continue
449 if not mysplit:
450 self.invalidentry(self.getpath(y))
451 continue
452 @@ -1732,10 +1754,10 @@
453
454 return False
455
456 - def _preserve_libs(self, srcroot, destroot, mycontents, counter):
457 + def _preserve_libs(self, srcroot, destroot, mycontents, counter, inforoot):
458 # read global reverse NEEDED map
459 linkmap = self.vartree.dbapi.linkmap
460 - linkmap.rebuild()
461 + linkmap.rebuild(include_file=os.path.join(inforoot, "NEEDED.ELF.2"))
462 liblist = linkmap.listLibraryObjects()
463
464 # get list of libraries from old package instance
465 @@ -1743,12 +1765,13 @@
466 old_libs = set(old_contents).intersection(liblist)
467
468 # get list of libraries from new package instance
469 - mylibs = set(mycontents).intersection(liblist)
470 -
471 + mylibs = set([os.path.join(os.sep, x) for x in mycontents]).intersection(liblist)
472 +
473 # check which libs are present in the old, but not the new package instance
474 candidates = old_libs.difference(mylibs)
475 +
476 for x in old_contents:
477 - if os.path.islink(x) and os.path.realpath(x) in candidates:
478 + if os.path.islink(x) and os.path.realpath(x) in candidates and x not in mycontents:
479 candidates.add(x)
480
481 # ignore any libs that are only internally used by the package
482 @@ -1779,6 +1802,7 @@
483 for c in linkmap.findConsumers(lib):
484 localkeep = True
485 providers = linkmap.findProviders(c)
486 +
487 for soname in providers:
488 if lib in providers[soname]:
489 for p in providers[soname]:
490 @@ -2119,7 +2143,7 @@
491
492 # Preserve old libs if they are still in use
493 if slot_matches and "preserve-libs" in self.settings.features:
494 - self._preserve_libs(srcroot, destroot, myfilelist+mylinklist, counter)
495 + self._preserve_libs(srcroot, destroot, myfilelist+mylinklist, counter, inforoot)
496
497 # check for package collisions
498 collisions = self._collision_protect(srcroot, destroot, others_in_slot,
499
500 --
501 gentoo-commits@l.g.o mailing list