Chromium Code Reviews
chromiumcodereview-hr@appspot.gserviceaccount.com (chromiumcodereview-hr) | Please choose your nickname with Settings | Help | Chromium Project | Gerrit Changes | Sign out
(83)

Side by Side Diff: pym/_emerge/FakeVartree.py

Issue 6688037: Update Portage to sync BlockerDB at init, rather than before every package. (Closed) Base URL: http://git.chromium.org/git/portage_tool.git@cros-2.1.9
Patch Set: Address review feedback. Created 9 years, 9 months ago
Use n/p to move between diff chunks; N/P to move between comments. Draft comments are only viewable by you.
Jump to:
View unified diff | Download patch | Annotate | Revision Log
« no previous file with comments | « pym/_emerge/BlockerDB.py ('k') | pym/_emerge/Scheduler.py » ('j') | no next file with comments »
Toggle Intra-line Diffs ('i') | Expand Comments ('e') | Collapse Comments ('c') | Show Comments Hide Comments ('s')
OLDNEW
1 # Copyright 1999-2010 Gentoo Foundation 1 # Copyright 1999-2010 Gentoo Foundation
2 # Distributed under the terms of the GNU General Public License v2 2 # Distributed under the terms of the GNU General Public License v2
3 3
4 import sys 4 import sys
5 5
6 import portage 6 import portage
7 from portage import os 7 from portage import os
8 from _emerge.Package import Package 8 from _emerge.Package import Package
9 from _emerge.PackageVirtualDbapi import PackageVirtualDbapi 9 from _emerge.PackageVirtualDbapi import PackageVirtualDbapi
10 from portage.const import VDB_PATH 10 from portage.const import VDB_PATH
(...skipping 82 matching lines...) Expand 10 before | Expand all | Expand 10 after
93 raise KeyError(pkg) 93 raise KeyError(pkg)
94 self.dbapi.aux_update(pkg, live_metadata) 94 self.dbapi.aux_update(pkg, live_metadata)
95 except (KeyError, portage.exception.PortageException): 95 except (KeyError, portage.exception.PortageException):
96 if self._global_updates is None: 96 if self._global_updates is None:
97 self._global_updates = \ 97 self._global_updates = \
98 grab_global_updates(self._portdb) 98 grab_global_updates(self._portdb)
99 perform_global_updates( 99 perform_global_updates(
100 pkg, self.dbapi, self._global_updates) 100 pkg, self.dbapi, self._global_updates)
101 return self._aux_get(pkg, wants) 101 return self._aux_get(pkg, wants)
102 102
103 def cpv_discard(self, pkg):
104 """
105 Discard a package from the fake vardb if it exists.
106 """
107 old_pkg = self.dbapi.get(pkg)
108 if old_pkg is not None:
109 self.dbapi.cpv_remove(old_pkg)
110 self._pkg_cache.pop(old_pkg, None)
111 self._aux_get_history.discard(old_pkg.cpv)
112
103 def sync(self, acquire_lock=1): 113 def sync(self, acquire_lock=1):
104 """ 114 """
105 Call this method to synchronize state with the real vardb 115 Call this method to synchronize state with the real vardb
106 after one or more packages may have been installed or 116 after one or more packages may have been installed or
107 uninstalled. 117 uninstalled.
108 """ 118 """
109 vdb_path = os.path.join(self.settings['EROOT'], portage.VDB_PATH ) 119 vdb_path = os.path.join(self.settings['EROOT'], portage.VDB_PATH )
110 try: 120 try:
111 # At least the parent needs to exist for the lock file. 121 # At least the parent needs to exist for the lock file.
112 portage.util.ensure_dirs(vdb_path) 122 portage.util.ensure_dirs(vdb_path)
(...skipping 21 matching lines...) Expand all
134 144
135 real_vardb = self._root_config.trees["vartree"].dbapi 145 real_vardb = self._root_config.trees["vartree"].dbapi
136 current_cpv_set = frozenset(real_vardb.cpv_all()) 146 current_cpv_set = frozenset(real_vardb.cpv_all())
137 pkg_vardb = self.dbapi 147 pkg_vardb = self.dbapi
138 pkg_cache = self._pkg_cache 148 pkg_cache = self._pkg_cache
139 aux_get_history = self._aux_get_history 149 aux_get_history = self._aux_get_history
140 150
141 # Remove any packages that have been uninstalled. 151 # Remove any packages that have been uninstalled.
142 for pkg in list(pkg_vardb): 152 for pkg in list(pkg_vardb):
143 if pkg.cpv not in current_cpv_set: 153 if pkg.cpv not in current_cpv_set:
144 » » » » pkg_vardb.cpv_remove(pkg) 154 » » » » self.cpv_discard(pkg)
145 » » » » pkg_cache.pop(pkg, None)
146 » » » » aux_get_history.discard(pkg.cpv)
147 155
148 # Validate counters and timestamps. 156 # Validate counters and timestamps.
149 slot_counters = {} 157 slot_counters = {}
150 root = self.root 158 root = self.root
151 validation_keys = ["COUNTER", "_mtime_"] 159 validation_keys = ["COUNTER", "_mtime_"]
152 for cpv in current_cpv_set: 160 for cpv in current_cpv_set:
153 161
154 pkg_hash_key = ("installed", root, cpv, "nomerge") 162 pkg_hash_key = ("installed", root, cpv, "nomerge")
155 pkg = pkg_vardb.get(pkg_hash_key) 163 pkg = pkg_vardb.get(pkg_hash_key)
156 if pkg is not None: 164 if pkg is not None:
157 counter, mtime = real_vardb.aux_get(cpv, validat ion_keys) 165 counter, mtime = real_vardb.aux_get(cpv, validat ion_keys)
158 try: 166 try:
159 counter = long(counter) 167 counter = long(counter)
160 except ValueError: 168 except ValueError:
161 counter = 0 169 counter = 0
162 170
163 if counter != pkg.counter or \ 171 if counter != pkg.counter or \
164 mtime != pkg.mtime: 172 mtime != pkg.mtime:
165 » » » » » pkg_vardb.cpv_remove(pkg) 173 » » » » » self.cpv_discard(pkg)
166 » » » » » pkg_cache.pop(pkg, None)
167 » » » » » aux_get_history.discard(pkg.cpv)
168 pkg = None 174 pkg = None
169 175
170 if pkg is None: 176 if pkg is None:
171 pkg = self._pkg(cpv) 177 pkg = self._pkg(cpv)
172 178
173 other_counter = slot_counters.get(pkg.slot_atom) 179 other_counter = slot_counters.get(pkg.slot_atom)
174 if other_counter is not None: 180 if other_counter is not None:
175 if other_counter > pkg.counter: 181 if other_counter > pkg.counter:
176 continue 182 continue
177 183
(...skipping 61 matching lines...) Expand 10 before | Expand all | Expand 10 after
239 mycommands = myupdates['DEFAULT'] 245 mycommands = myupdates['DEFAULT']
240 except KeyError: 246 except KeyError:
241 return 247 return
242 248
243 if not mycommands: 249 if not mycommands:
244 return 250 return
245 251
246 updates = update_dbentries(mycommands, aux_dict) 252 updates = update_dbentries(mycommands, aux_dict)
247 if updates: 253 if updates:
248 mydb.aux_update(mycpv, updates) 254 mydb.aux_update(mycpv, updates)
OLDNEW
« no previous file with comments | « pym/_emerge/BlockerDB.py ('k') | pym/_emerge/Scheduler.py » ('j') | no next file with comments »

Powered by Google App Engine
This is Rietveld 408576698