Gentoo Archives: gentoo-commits

From: "Fabian Groffen (grobian)" <grobian@g.o>
To: gentoo-commits@l.g.o
Subject: [gentoo-commits] portage r13714 - in main/branches/prefix: bin pym/_emerge pym/portage/dbapi
Date: Sat, 27 Jun 2009 14:33:02
Message-Id: E1MKYxf-0002zE-GC@stork.gentoo.org
1 Author: grobian
2 Date: 2009-06-27 14:32:58 +0000 (Sat, 27 Jun 2009)
3 New Revision: 13714
4
5 Modified:
6 main/branches/prefix/bin/portageq
7 main/branches/prefix/bin/repoman
8 main/branches/prefix/pym/_emerge/Package.py
9 main/branches/prefix/pym/_emerge/Scheduler.py
10 main/branches/prefix/pym/_emerge/depgraph.py
11 main/branches/prefix/pym/portage/dbapi/bintree.py
12 main/branches/prefix/pym/portage/dbapi/vartree.py
13 Log:
14 Merged from trunk -r13677:13688
15
16 | 13678 | Fix imports for _emerge submodules. |
17 | zmedico | |
18
19 | 13679 | Bug #275237 - If a directory exists in a location where a |
20 | zmedico | normal file is to be merged, generate a config-protect |
21 | | filename for the file and merge it that way. Thanks to Jonas |
22 | | Bernoulli <jonas@×××××××××.cc> for this patch. |
23
24 | 13680 | In binarytree.inject(), when a symlink is created for the |
25 | zmedico | current package and it overwrites another package, delete |
26 | | the corresponding metadata from the Packages file. Thanks to |
27 | | Eitan Mosenkis <eitan@××××××××.net> for reporting. |
28
29 | 13681 | Add support to `portageq owners` for querying paths matching |
30 | zmedico | a given basename. It is natural to support this since the |
31 | | vartree already maintains a basename -> owner index anyway. |
32 | | There are plans for the packagekit backend is to support |
33 | | this type of search. |
34
35 | 13685 | Bug #275217 - Part 3 - Splits depgraph.select_files into |
36 | zmedico | select_files and _resolve. Thanks to Sebastian Mingramm |
37 | | (few) <s.mingramm@×××.de> for this patch. |
38
39 | 13686 | * Make Package.metadata['USE'] access trigger USE |
40 | zmedico | calculation for unbuilt ebuilds. * Make |
41 | | Package.metadata['LICENSE'] access trigger USE conditional |
42 | | evaluation. * Make Package.metadata['PROVIDE'] access |
43 | | trigger USE conditional evaluation. * Initialize |
44 | | Package.metadata['CHOST'] in the Package constructor for |
45 | | unbuilt ebuilds. |
46
47 | 13687 | Remove obsolete Package.metadata['CHOST'] initialization. |
48 | zmedico | |
49
50 | 13688 | Use depgraph._pkg() to construct Package instances inside |
51 | zmedico | _select_pkg_highest_available_imp(). |
52
53
54 Modified: main/branches/prefix/bin/portageq
55 ===================================================================
56 --- main/branches/prefix/bin/portageq 2009-06-27 14:31:19 UTC (rev 13713)
57 +++ main/branches/prefix/bin/portageq 2009-06-27 14:32:58 UTC (rev 13714)
58 @@ -161,8 +161,8 @@
59 Given a list of files, print the packages that own the files and which
60 files belong to each package. Files owned by a package are listed on
61 the lines below it, indented by a single tab character (\\t). All file
62 - paths must start with <root>. Returns 1 if no owners could be found,
63 - and 0 otherwise.
64 + paths must either start with <root> or be a basename alone.
65 + Returns 1 if no owners could be found, and 0 otherwise.
66 """
67 if len(argv) < 2:
68 sys.stderr.write("ERROR: insufficient parameters!\n")
69 @@ -183,18 +183,22 @@
70 files = []
71 for f in argv[1:]:
72 f = portage.normalize_path(f)
73 - if not f.startswith(os.path.sep):
74 + is_basename = os.sep not in f
75 + if not is_basename and f[:1] != os.sep:
76 if cwd is None:
77 sys.stderr.write("ERROR: cwd does not exist!\n")
78 sys.stderr.flush()
79 return 2
80 f = os.path.join(cwd, f)
81 f = portage.normalize_path(f)
82 - if not f.startswith(root):
83 + if not is_basename and not f.startswith(root):
84 sys.stderr.write("ERROR: file paths must begin with <root>!\n")
85 sys.stderr.flush()
86 return 2
87 - files.append(f[len(root):])
88 + if is_basename:
89 + files.append(f)
90 + else:
91 + files.append(f[len(root):])
92
93 owners = vardb._owners.get_owners(files)
94
95
96 Modified: main/branches/prefix/bin/repoman
97 ===================================================================
98 --- main/branches/prefix/bin/repoman 2009-06-27 14:31:19 UTC (rev 13713)
99 +++ main/branches/prefix/bin/repoman 2009-06-27 14:32:58 UTC (rev 13714)
100 @@ -48,7 +48,8 @@
101 from repoman.checks import run_checks
102 from repoman import utilities
103
104 -from _emerge import Package, RootConfig
105 +from _emerge.Package import Package
106 +from _emerge.RootConfig import RootConfig
107 from portage.sets import load_default_config
108
109 import portage.checksum
110
111 Modified: main/branches/prefix/pym/_emerge/Package.py
112 ===================================================================
113 --- main/branches/prefix/pym/_emerge/Package.py 2009-06-27 14:31:19 UTC (rev 13713)
114 +++ main/branches/prefix/pym/_emerge/Package.py 2009-06-27 14:32:58 UTC (rev 13714)
115 @@ -11,7 +11,8 @@
116 import portage
117
118 from portage.cache.mappings import slot_dict_class
119 -
120 +from portage.dep import paren_reduce, use_reduce, \
121 + paren_normalize, paren_enclose
122 from _emerge.Task import Task
123
124 class Package(Task):
125 @@ -22,7 +23,8 @@
126 "root_config", "type_name",
127 "category", "counter", "cp", "cpv_split",
128 "inherited", "iuse", "mtime",
129 - "pf", "pv_split", "root", "slot", "slot_atom", "use")
130 + "pf", "pv_split", "root", "slot", "slot_atom",) + \
131 + ("_use",)
132
133 metadata_keys = [
134 "CHOST", "COUNTER", "DEPEND", "EAPI",
135 @@ -35,6 +37,8 @@
136 Task.__init__(self, **kwargs)
137 self.root = self.root_config.root
138 self.metadata = _PackageMetadataWrapper(self, self.metadata)
139 + if not self.built:
140 + self.metadata['CHOST'] = self.root_config.settings.get('CHOST', '')
141 self.cp = portage.cpv_getkey(self.cpv)
142 slot = self.slot
143 if not slot:
144 @@ -46,13 +50,19 @@
145 self.cpv_split = portage.catpkgsplit(self.cpv)
146 self.pv_split = self.cpv_split[1:]
147
148 - class _use(object):
149 + class _use_class(object):
150
151 __slots__ = ("__weakref__", "enabled")
152
153 def __init__(self, use):
154 self.enabled = frozenset(use)
155
156 + @property
157 + def use(self):
158 + if self._use is None:
159 + self._use = self._use_class(self.metadata['USE'].split())
160 + return self._use
161 +
162 class _iuse(object):
163
164 __slots__ = ("__weakref__", "all", "enabled", "disabled", "iuse_implicit", "regex", "tokens")
165 @@ -143,13 +153,38 @@
166
167 __slots__ = ("_pkg",)
168 _wrapped_keys = frozenset(
169 - ["COUNTER", "INHERITED", "IUSE", "SLOT", "USE", "_mtime_"])
170 + ["COUNTER", "INHERITED", "IUSE", "SLOT", "_mtime_"])
171
172 def __init__(self, pkg, metadata):
173 _PackageMetadataWrapperBase.__init__(self)
174 self._pkg = pkg
175 + """LICENSE with USE conditionals evaluated."""
176 +
177 + if not pkg.built:
178 + # USE is lazy, but we want it to show up in self.keys().
179 + self['USE'] = ''
180 +
181 self.update(metadata)
182
183 + def __getitem__(self, k):
184 + v = _PackageMetadataWrapperBase.__getitem__(self, k)
185 + if k in ('PROVIDE', 'LICENSE',):
186 + if '?' in v:
187 + v = paren_enclose(paren_normalize(use_reduce(
188 + paren_reduce(v), uselist=self._pkg.use.enabled)))
189 + self[k] = v
190 +
191 + elif k == 'USE' and not self._pkg.built:
192 + if not v:
193 + # This is lazy because it's expensive.
194 + pkgsettings = self._pkg.root_config.trees[
195 + 'porttree'].dbapi.doebuild_settings
196 + pkgsettings.setcpv(self._pkg)
197 + v = pkgsettings["PORTAGE_USE"]
198 + self['USE'] = v
199 +
200 + return v
201 +
202 def __setitem__(self, k, v):
203 _PackageMetadataWrapperBase.__setitem__(self, k, v)
204 if k in self._wrapped_keys:
205 @@ -167,9 +202,6 @@
206 def _set_slot(self, k, v):
207 self._pkg.slot = v
208
209 - def _set_use(self, k, v):
210 - self._pkg.use = self._pkg._use(v.split())
211 -
212 def _set_counter(self, k, v):
213 if isinstance(v, basestring):
214 try:
215
216 Modified: main/branches/prefix/pym/_emerge/Scheduler.py
217 ===================================================================
218 --- main/branches/prefix/pym/_emerge/Scheduler.py 2009-06-27 14:31:19 UTC (rev 13713)
219 +++ main/branches/prefix/pym/_emerge/Scheduler.py 2009-06-27 14:32:58 UTC (rev 13714)
220 @@ -1627,12 +1627,6 @@
221 db_keys = list(self.trees[root_config.root][
222 tree_type].dbapi._aux_cache_keys)
223 metadata = izip(db_keys, db.aux_get(cpv, db_keys))
224 - pkg = Package(cpv=cpv, metadata=metadata,
225 + return Package(built=(type_name != 'ebuild'),
226 + cpv=cpv, metadata=metadata,
227 root_config=root_config, installed=installed)
228 - if type_name == "ebuild":
229 - settings = self.pkgsettings[root_config.root]
230 - settings.setcpv(pkg)
231 - pkg.metadata["USE"] = settings["PORTAGE_USE"]
232 - pkg.metadata['CHOST'] = settings.get('CHOST', '')
233 -
234 - return pkg
235
236 Modified: main/branches/prefix/pym/_emerge/depgraph.py
237 ===================================================================
238 --- main/branches/prefix/pym/_emerge/depgraph.py 2009-06-27 14:31:19 UTC (rev 13713)
239 +++ main/branches/prefix/pym/_emerge/depgraph.py 2009-06-27 14:32:58 UTC (rev 13714)
240 @@ -176,6 +176,8 @@
241 "--getbinpkgonly" in self.myopts)
242 del trees
243
244 + #contains the args created by select_files
245 + self._initial_arg_list = []
246 self.digraph=portage.digraph()
247 # contains all sets added to the graph
248 self._sets = {}
249 @@ -1067,7 +1069,8 @@
250 yield arg, atom
251
252 def select_files(self, myfiles):
253 - """Given a list of .tbz2s, .ebuilds sets, and deps, create the
254 + """Given a list of .tbz2s, .ebuilds sets, and deps, populate
255 + self._initial_arg_list and call self._resolve to create the
256 appropriate depgraph and return a favorite list."""
257 debug = "--debug" in self.myopts
258 root_config = self.roots[self.target_root]
259 @@ -1146,9 +1149,6 @@
260 metadata = izip(db_keys, portdb.aux_get(mykey, db_keys))
261 pkg = Package(type_name="ebuild", root_config=root_config,
262 cpv=mykey, metadata=metadata, onlydeps=onlydeps)
263 - pkgsettings.setcpv(pkg)
264 - pkg.metadata["USE"] = pkgsettings["PORTAGE_USE"]
265 - pkg.metadata['CHOST'] = pkgsettings.get('CHOST', '')
266 self._pkg_cache[pkg] = pkg
267 args.append(PackageArg(arg=x, package=pkg,
268 root_config=root_config))
269 @@ -1325,14 +1325,25 @@
270 myfavorites.add(arg.arg)
271 myfavorites = list(myfavorites)
272
273 - pprovideddict = pkgsettings.pprovideddict
274 if debug:
275 portage.writemsg("\n", noiselevel=-1)
276 # Order needs to be preserved since a feature of --nodeps
277 # is to allow the user to force a specific merge order.
278 args.reverse()
279 - while args:
280 - arg = args.pop()
281 + self._initial_arg_list = args[:]
282 +
283 + return self._resolve(myfavorites)
284 +
285 + def _resolve(self, myfavorites):
286 + """Given self._initial_arg_list, pull in the root nodes,
287 + call self._creategraph to process theier deps and return
288 + a favorite list."""
289 + debug = "--debug" in self.myopts
290 + onlydeps = "--onlydeps" in self.myopts
291 + myroot = self.target_root
292 + pkgsettings = self.pkgsettings[myroot]
293 + pprovideddict = pkgsettings.pprovideddict
294 + for arg in self._initial_arg_list:
295 for atom in arg.set:
296 self.spinner.update()
297 dep = Dependency(atom=atom, onlydeps=onlydeps,
298 @@ -1866,9 +1877,7 @@
299
300 if not cpv_list:
301 continue
302 - pkg_status = "merge"
303 - if installed or onlydeps:
304 - pkg_status = "nomerge"
305 +
306 # descending order
307 cpv_list.reverse()
308 for cpv in cpv_list:
309 @@ -1880,31 +1889,11 @@
310 # in case there is a visible downgrade.
311 continue
312 reinstall_for_flags = None
313 - cache_key = (pkg_type, root, cpv, pkg_status)
314 - calculated_use = True
315 - pkg = self._pkg_cache.get(cache_key)
316 - if pkg is None:
317 - calculated_use = False
318 - try:
319 - metadata = izip(db_keys, db.aux_get(cpv, db_keys))
320 - except KeyError:
321 - continue
322 - pkg = Package(built=built, cpv=cpv,
323 - installed=installed, metadata=metadata,
324 - onlydeps=onlydeps, root_config=root_config,
325 - type_name=pkg_type)
326 - metadata = pkg.metadata
327 - if not built:
328 - metadata['CHOST'] = pkgsettings.get('CHOST', '')
329 - if not built and ("?" in metadata["LICENSE"] or \
330 - "?" in metadata["PROVIDE"]):
331 - # This is avoided whenever possible because
332 - # it's expensive. It only needs to be done here
333 - # if it has an effect on visibility.
334 - pkgsettings.setcpv(pkg)
335 - metadata["USE"] = pkgsettings["PORTAGE_USE"]
336 - calculated_use = True
337 - self._pkg_cache[pkg] = pkg
338 + try:
339 + pkg = self._pkg(cpv, pkg_type, root_config,
340 + installed=installed, onlydeps=onlydeps)
341 + except portage.exception.PackageNotFound:
342 + continue
343
344 if not installed or (built and matched_packages):
345 # Only enforce visibility on installed packages
346 @@ -1955,11 +1944,9 @@
347 if not visible(pkgsettings, pkg_eb):
348 continue
349
350 - if not pkg.built and not calculated_use:
351 - # This is avoided whenever possible because
352 - # it's expensive.
353 - pkgsettings.setcpv(pkg)
354 - pkg.metadata["USE"] = pkgsettings["PORTAGE_USE"]
355 + # Calculation of USE for unbuilt ebuilds is relatively
356 + # expensive, so it is only performed lazily, after the
357 + # above visibility checks are complete.
358
359 if pkg.cp != atom.cp:
360 # A cpv can be returned from dbapi.match() as an
361 @@ -1972,8 +1959,6 @@
362 myarg = None
363 if root == self.target_root:
364 try:
365 - # Ebuild USE must have been calculated prior
366 - # to this point, in case atoms have USE deps.
367 myarg = self._iter_atoms_for_pkg(pkg).next()
368 except StopIteration:
369 pass
370 @@ -2202,18 +2187,24 @@
371 return 0
372 return 1
373
374 - def _pkg(self, cpv, type_name, root_config, installed=False):
375 + def _pkg(self, cpv, type_name, root_config, installed=False,
376 + onlydeps=False):
377 """
378 Get a package instance from the cache, or create a new
379 - one if necessary. Raises KeyError from aux_get if it
380 + one if necessary. Raises PackageNotFound from aux_get if it
381 failures for some reason (package does not exist or is
382 corrupt).
383 """
384 operation = "merge"
385 - if installed:
386 + if installed or onlydeps:
387 operation = "nomerge"
388 pkg = self._pkg_cache.get(
389 (type_name, root_config.root, cpv, operation))
390 + if pkg is None and onlydeps and not installed:
391 + # Maybe it already got pulled in as a "merge" node.
392 + pkg = self.mydbapi[root_config.root].get(
393 + (type_name, root_config.root, cpv, 'merge'))
394 +
395 if pkg is None:
396 tree_type = self.pkg_tree_map[type_name]
397 db = root_config.trees[tree_type].dbapi
398 @@ -2223,13 +2214,9 @@
399 metadata = izip(db_keys, db.aux_get(cpv, db_keys))
400 except KeyError:
401 raise portage.exception.PackageNotFound(cpv)
402 - pkg = Package(cpv=cpv, metadata=metadata,
403 - root_config=root_config, installed=installed)
404 - if type_name == "ebuild":
405 - settings = self.pkgsettings[root_config.root]
406 - settings.setcpv(pkg)
407 - pkg.metadata["USE"] = settings["PORTAGE_USE"]
408 - pkg.metadata['CHOST'] = settings.get('CHOST', '')
409 + pkg = Package(built=(type_name != "ebuild"), cpv=cpv,
410 + installed=installed, metadata=metadata,
411 + root_config=root_config, type_name=type_name)
412 self._pkg_cache[pkg] = pkg
413 return pkg
414
415 @@ -4369,11 +4356,6 @@
416 installed=installed, metadata=metadata,
417 operation=action, root_config=root_config,
418 type_name=pkg_type)
419 - if pkg_type == "ebuild":
420 - pkgsettings = self.pkgsettings[myroot]
421 - pkgsettings.setcpv(pkg)
422 - pkg.metadata["USE"] = pkgsettings["PORTAGE_USE"]
423 - pkg.metadata['CHOST'] = pkgsettings.get('CHOST', '')
424 self._pkg_cache[pkg] = pkg
425
426 root_config = self.roots[pkg.root]
427 @@ -4815,10 +4797,7 @@
428 db.aux_get(cpv, db_keys)))
429 except KeyError:
430 metadata = None
431 - if metadata and not built:
432 - pkgsettings.setcpv(cpv, mydb=metadata)
433 - metadata["USE"] = pkgsettings["PORTAGE_USE"]
434 - metadata['CHOST'] = pkgsettings.get('CHOST', '')
435 +
436 if metadata is None:
437 mreasons = ["corruption"]
438 else:
439
440 Modified: main/branches/prefix/pym/portage/dbapi/bintree.py
441 ===================================================================
442 --- main/branches/prefix/pym/portage/dbapi/bintree.py 2009-06-27 14:31:19 UTC (rev 13713)
443 +++ main/branches/prefix/pym/portage/dbapi/bintree.py 2009-06-27 14:32:58 UTC (rev 13714)
444 @@ -836,6 +836,7 @@
445 # process) and then updated it, all while holding a lock.
446 from portage.locks import lockfile, unlockfile
447 pkgindex_lock = None
448 + created_symlink = False
449 try:
450 pkgindex_lock = lockfile(self._pkgindex_file,
451 wantnewlockfile=1)
452 @@ -846,6 +847,7 @@
453 if self._all_directory and \
454 self.getname(cpv).split(os.path.sep)[-2] == "All":
455 self._create_symlink(cpv)
456 + created_symlink = True
457 pkgindex = self._new_pkgindex()
458 try:
459 f = open(self._pkgindex_file)
460 @@ -877,8 +879,14 @@
461 # Handle path collisions in $PKGDIR/All
462 # when CPV is not identical.
463 del pkgindex.packages[i]
464 - elif cpv == d2.get("CPV") and path == d2.get("PATH", ""):
465 - del pkgindex.packages[i]
466 + elif cpv == d2.get("CPV"):
467 + if path == d2.get("PATH", ""):
468 + del pkgindex.packages[i]
469 + elif created_symlink and not d2.get("PATH", ""):
470 + # Delete entry for the package that was just
471 + # overwritten by a symlink to this package.
472 + del pkgindex.packages[i]
473 +
474 pkgindex.packages.append(d)
475
476 self._update_pkgindex_header(pkgindex.header)
477
478 Modified: main/branches/prefix/pym/portage/dbapi/vartree.py
479 ===================================================================
480 --- main/branches/prefix/pym/portage/dbapi/vartree.py 2009-06-27 14:31:19 UTC (rev 13713)
481 +++ main/branches/prefix/pym/portage/dbapi/vartree.py 2009-06-27 14:32:58 UTC (rev 13714)
482 @@ -2053,7 +2053,12 @@
483 return x
484
485 for path in path_iter:
486 - name = os.path.basename(path.rstrip(os.path.sep))
487 + is_basename = os.sep != path[:1]
488 + if is_basename:
489 + name = path
490 + else:
491 + name = os.path.basename(path.rstrip(os.path.sep))
492 +
493 if not name:
494 continue
495
496 @@ -2074,9 +2079,15 @@
497
498 if current_hash != hash_value:
499 continue
500 - if dblink(cpv).isowner(path, root):
501 - yield dblink(cpv), path
502
503 + if is_basename:
504 + for p in dblink(cpv).getcontents():
505 + if os.path.basename(p) == name:
506 + yield dblink(cpv), p[len(root):]
507 + else:
508 + if dblink(cpv).isowner(path, root):
509 + yield dblink(cpv), path
510 +
511 class vartree(object):
512 "this tree will scan a var/db/pkg database located at root (passed to init)"
513 def __init__(self, root="/", virtual=None, clone=None, categories=None,
514 @@ -4357,7 +4368,7 @@
515 # destination file exists
516 if stat.S_ISDIR(mydmode):
517 # install of destination is blocked by an existing directory with the same name
518 - moveme = 0
519 + cfgprot = 1
520 showMessage("!!! %s\n" % mydest,
521 level=logging.ERROR, noiselevel=-1)
522 elif stat.S_ISREG(mydmode) or (stat.S_ISLNK(mydmode) and os.path.exists(mydest) and stat.S_ISREG(os.stat(mydest)[stat.ST_MODE])):
523 @@ -4392,8 +4403,8 @@
524 """A previously remembered update has been
525 accepted, so it is removed from confmem."""
526 del cfgfiledict[myrealdest]
527 - if cfgprot:
528 - mydest = new_protect_filename(mydest, newmd5=mymd5)
529 + if cfgprot:
530 + mydest = new_protect_filename(mydest, newmd5=mymd5)
531
532 # whether config protection or not, we merge the new file the
533 # same way. Unless moveme=0 (blocking directory)