OLD | NEW |
---|---|
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 Loading... | |
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. | |
diandersAtChromium
2011/03/22 02:57:59
Is pkg always a Package object? It's never a 4-tu
davidjames
2011/03/23 20:19:11
Nope, we don't need that functionality... that sai
| |
106 """ | |
107 old_pkg = self.dbapi.get(pkg) | |
diandersAtChromium
2011/03/22 02:57:59
I would _love_ if it you added a docstring to Pack
davidjames
2011/03/23 20:19:11
That's a good idea for a followup CL.
| |
108 if old_pkg: | |
diandersAtChromium
2011/03/22 02:57:59
Should check for 'is None' or use 'if pkg in self.
davidjames
2011/03/23 20:19:11
Done.
| |
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 Loading... | |
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) |
diandersAtChromium
2011/03/22 02:57:59
Looks like you added an extra level of indirection
davidjames
2011/03/23 20:19:11
Yup.
| |
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 Loading... | |
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) |
OLD | NEW |