1 |
Author: zmedico |
2 |
Date: 2009-11-01 22:11:59 +0000 (Sun, 01 Nov 2009) |
3 |
New Revision: 14772 |
4 |
|
5 |
Modified: |
6 |
main/trunk/pym/_emerge/FakeVartree.py |
7 |
Log: |
8 |
Eliminate duplicate code from the FakeVartree constructor which does the |
9 |
same thing as FakeVartree.sync(). |
10 |
|
11 |
|
12 |
Modified: main/trunk/pym/_emerge/FakeVartree.py |
13 |
=================================================================== |
14 |
--- main/trunk/pym/_emerge/FakeVartree.py 2009-11-01 10:56:19 UTC (rev 14771) |
15 |
+++ main/trunk/pym/_emerge/FakeVartree.py 2009-11-01 22:11:59 UTC (rev 14772) |
16 |
@@ -36,51 +36,6 @@ |
17 |
self._db_keys = mykeys |
18 |
self._pkg_cache = pkg_cache |
19 |
self.dbapi = PackageVirtualDbapi(real_vartree.settings) |
20 |
- vdb_path = os.path.join(self.root, portage.VDB_PATH) |
21 |
- try: |
22 |
- # At least the parent needs to exist for the lock file. |
23 |
- portage.util.ensure_dirs(vdb_path) |
24 |
- except portage.exception.PortageException: |
25 |
- pass |
26 |
- vdb_lock = None |
27 |
- try: |
28 |
- if acquire_lock and os.access(vdb_path, os.W_OK): |
29 |
- vdb_lock = portage.locks.lockdir(vdb_path) |
30 |
- real_dbapi = real_vartree.dbapi |
31 |
- slot_counters = {} |
32 |
- for cpv in real_dbapi.cpv_all(): |
33 |
- cache_key = ("installed", self.root, cpv, "nomerge") |
34 |
- pkg = self._pkg_cache.get(cache_key) |
35 |
- if pkg is not None: |
36 |
- metadata = pkg.metadata |
37 |
- else: |
38 |
- metadata = dict(zip(mykeys, real_dbapi.aux_get(cpv, mykeys))) |
39 |
- myslot = metadata["SLOT"] |
40 |
- mycp = portage.cpv_getkey(cpv) |
41 |
- myslot_atom = "%s:%s" % (mycp, myslot) |
42 |
- try: |
43 |
- mycounter = long(metadata["COUNTER"]) |
44 |
- except ValueError: |
45 |
- mycounter = 0 |
46 |
- metadata["COUNTER"] = str(mycounter) |
47 |
- other_counter = slot_counters.get(myslot_atom, None) |
48 |
- if other_counter is not None: |
49 |
- if other_counter > mycounter: |
50 |
- continue |
51 |
- slot_counters[myslot_atom] = mycounter |
52 |
- if pkg is None: |
53 |
- pkg = Package(built=True, cpv=cpv, |
54 |
- installed=True, metadata=metadata, |
55 |
- root_config=root_config, type_name="installed") |
56 |
- self._pkg_cache[pkg] = pkg |
57 |
- self.dbapi.cpv_inject(pkg) |
58 |
- real_dbapi.flush_cache() |
59 |
- finally: |
60 |
- if vdb_lock: |
61 |
- portage.locks.unlockdir(vdb_lock) |
62 |
- # Populate the old-style virtuals using the cached values. |
63 |
- if not self.settings.treeVirtuals: |
64 |
- self.settings._populate_treeVirtuals(self) |
65 |
|
66 |
# Intialize variables needed for lazy cache pulls of the live ebuild |
67 |
# metadata. This ensures that the vardb lock is released ASAP, without |
68 |
@@ -94,6 +49,8 @@ |
69 |
self._portdb = portdb |
70 |
self._global_updates = None |
71 |
|
72 |
+ self.sync() |
73 |
+ |
74 |
def _match_wrapper(self, cpv, use_cache=1): |
75 |
""" |
76 |
Make sure the metadata in Package instances gets updated for any |
77 |
@@ -148,6 +105,10 @@ |
78 |
if vdb_lock: |
79 |
portage.locks.unlockdir(vdb_lock) |
80 |
|
81 |
+ # Populate the old-style virtuals using the cached values. |
82 |
+ if not self.settings.treeVirtuals: |
83 |
+ self.settings._populate_treeVirtuals(self) |
84 |
+ |
85 |
def _sync(self): |
86 |
|
87 |
real_vardb = self._root_config.trees["vartree"].dbapi |