 Chromium Code Reviews
 Chromium Code Reviews 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
    
  
    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| OLD | NEW | 
|---|---|
| 1 # Copyright 1999-2011 Gentoo Foundation | 1 # Copyright 1999-2011 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 from __future__ import print_function | 4 from __future__ import print_function | 
| 5 | 5 | 
| 6 import gc | 6 import gc | 
| 7 import gzip | 7 import gzip | 
| 8 import logging | 8 import logging | 
| 9 import shutil | 9 import shutil | 
| 10 import signal | 10 import signal | 
| (...skipping 299 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... | |
| 310 if isinstance(merge, PackageMerge): | 310 if isinstance(merge, PackageMerge): | 
| 311 self._running_tasks.remove(merge.merge.pkg) | 311 self._running_tasks.remove(merge.merge.pkg) | 
| 312 for q in self._task_queues.values(): | 312 for q in self._task_queues.values(): | 
| 313 q.clear() | 313 q.clear() | 
| 314 | 314 | 
| 315 def _init_graph(self, graph_config): | 315 def _init_graph(self, graph_config): | 
| 316 """ | 316 """ | 
| 317 Initialization structures used for dependency calculations | 317 Initialization structures used for dependency calculations | 
| 318 involving currently installed packages. | 318 involving currently installed packages. | 
| 319 """ | 319 """ | 
| 320 # TODO: Replace the BlockerDB with a depgraph of installed packa ges | |
| 321 # that's updated incrementally with each upgrade/uninstall opera tion | |
| 322 # This will be useful for making quick and safe decisions with r espect | |
| 323 # to aggressive parallelization discussed in bug #279623. | |
| 324 self._set_graph_config(graph_config) | 320 self._set_graph_config(graph_config) | 
| 325 self._blocker_db = {} | 321 self._blocker_db = {} | 
| 326 for root in self.trees: | 322 for root in self.trees: | 
| 327 if graph_config is None: | 323 if graph_config is None: | 
| 328 fake_vartree = FakeVartree(self.trees[root]["roo t_config"], | 324 fake_vartree = FakeVartree(self.trees[root]["roo t_config"], | 
| 329 pkg_cache=self._pkg_cache) | 325 pkg_cache=self._pkg_cache) | 
| 330 else: | 326 else: | 
| 331 fake_vartree = graph_config.trees[root]['vartree '] | 327 fake_vartree = graph_config.trees[root]['vartree '] | 
| 328 fake_vartree.sync() | |
| 
diandersAtChromium
2011/03/22 02:57:59
How did you decide this was the place to put the s
 
davidjames
2011/03/23 20:19:11
Exactly right.
 | |
| 332 self._blocker_db[root] = BlockerDB(fake_vartree) | 329 self._blocker_db[root] = BlockerDB(fake_vartree) | 
| 333 | 330 | 
| 334 def _destroy_graph(self): | 331 def _destroy_graph(self): | 
| 335 """ | 332 """ | 
| 336 Use this to free memory at the beginning of _calc_resume_list(). | 333 Use this to free memory at the beginning of _calc_resume_list(). | 
| 337 After _calc_resume_list(), the _init_graph() method | 334 After _calc_resume_list(), the _init_graph() method | 
| 338 must to be called in order to re-generate the structures that | 335 must to be called in order to re-generate the structures that | 
| 339 this method destroys. | 336 this method destroys. | 
| 340 """ | 337 """ | 
| 341 self._blocker_db = None | 338 self._blocker_db = None | 
| (...skipping 294 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... | |
| 636 | 633 | 
| 637 def _schedule_unpack(self, unpack_phase): | 634 def _schedule_unpack(self, unpack_phase): | 
| 638 """ | 635 """ | 
| 639 Schedule an unpack phase on the unpack queue, in order | 636 Schedule an unpack phase on the unpack queue, in order | 
| 640 to serialize $DISTDIR access for live ebuilds. | 637 to serialize $DISTDIR access for live ebuilds. | 
| 641 """ | 638 """ | 
| 642 self._task_queues.unpack.add(unpack_phase) | 639 self._task_queues.unpack.add(unpack_phase) | 
| 643 | 640 | 
| 644 def _find_blockers(self, new_pkg): | 641 def _find_blockers(self, new_pkg): | 
| 645 """ | 642 """ | 
| 646 » » Returns a callable which should be called only when | 643 » » Returns a callable. | 
| 
diandersAtChromium
2011/03/22 02:57:59
...that will find the blockers for the given packa
 
davidjames
2011/03/23 20:19:11
Done.
 | |
| 647 » » the vdb lock has been acquired. | |
| 648 """ | 644 """ | 
| 649 def get_blockers(): | 645 def get_blockers(): | 
| 650 » » » return self._find_blockers_with_lock(new_pkg, acquire_lo ck=0) | 646 » » » return self._find_blockers_impl(new_pkg) | 
| 651 return get_blockers | 647 return get_blockers | 
| 652 | 648 | 
| 653 » def _find_blockers_with_lock(self, new_pkg, acquire_lock=0): | 649 » def _find_blockers_impl(self, new_pkg): | 
| 654 if self._opts_ignore_blockers.intersection(self.myopts): | 650 if self._opts_ignore_blockers.intersection(self.myopts): | 
| 655 return None | 651 return None | 
| 656 | 652 | 
| 
diandersAtChromium
2011/03/22 02:57:59
Are you sure that the gc.collect() is no longer ne
 
davidjames
2011/03/23 20:19:11
This gc.collect() call was only needed to workarou
 | |
| 657 # Call gc.collect() here to avoid heap overflow that | |
| 658 # triggers 'Cannot allocate memory' errors (reported | |
| 659 # with python-2.5). | |
| 660 gc.collect() | |
| 661 | |
| 662 blocker_db = self._blocker_db[new_pkg.root] | 653 blocker_db = self._blocker_db[new_pkg.root] | 
| 663 | 654 | 
| 664 blocker_dblinks = [] | 655 blocker_dblinks = [] | 
| 665 » » for blocking_pkg in blocker_db.findInstalledBlockers( | 656 » » for blocking_pkg in blocker_db.findInstalledBlockers(new_pkg): | 
| 666 » » » new_pkg, acquire_lock=acquire_lock): | |
| 667 if new_pkg.slot_atom == blocking_pkg.slot_atom: | 657 if new_pkg.slot_atom == blocking_pkg.slot_atom: | 
| 668 continue | 658 continue | 
| 669 if new_pkg.cpv == blocking_pkg.cpv: | 659 if new_pkg.cpv == blocking_pkg.cpv: | 
| 670 continue | 660 continue | 
| 671 blocker_dblinks.append(portage.dblink( | 661 blocker_dblinks.append(portage.dblink( | 
| 672 blocking_pkg.category, blocking_pkg.pf, blocking _pkg.root, | 662 blocking_pkg.category, blocking_pkg.pf, blocking _pkg.root, | 
| 673 self.pkgsettings[blocking_pkg.root], treetype="v artree", | 663 self.pkgsettings[blocking_pkg.root], treetype="v artree", | 
| 674 vartree=self.trees[blocking_pkg.root]["vartree"] )) | 664 vartree=self.trees[blocking_pkg.root]["vartree"] )) | 
| 675 | 665 | 
| 676 gc.collect() | |
| 677 | |
| 678 return blocker_dblinks | 666 return blocker_dblinks | 
| 679 | 667 | 
| 680 def _dblink_pkg(self, pkg_dblink): | 668 def _dblink_pkg(self, pkg_dblink): | 
| 681 cpv = pkg_dblink.mycpv | 669 cpv = pkg_dblink.mycpv | 
| 682 type_name = RootConfig.tree_pkg_map[pkg_dblink.treetype] | 670 type_name = RootConfig.tree_pkg_map[pkg_dblink.treetype] | 
| 683 root_config = self.trees[pkg_dblink.myroot]["root_config"] | 671 root_config = self.trees[pkg_dblink.myroot]["root_config"] | 
| 684 installed = type_name == "installed" | 672 installed = type_name == "installed" | 
| 685 return self._pkg(cpv, type_name, root_config, installed=installe d) | 673 return self._pkg(cpv, type_name, root_config, installed=installe d) | 
| 686 | 674 | 
| 687 def _dblink_elog(self, pkg_dblink, phase, func, msgs): | 675 def _dblink_elog(self, pkg_dblink, phase, func, msgs): | 
| (...skipping 832 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... | |
| 1520 self._status_display.running = self._jobs | 1508 self._status_display.running = self._jobs | 
| 1521 self._schedule() | 1509 self._schedule() | 
| 1522 | 1510 | 
| 1523 def _extract_exit(self, build): | 1511 def _extract_exit(self, build): | 
| 1524 self._build_exit(build) | 1512 self._build_exit(build) | 
| 1525 | 1513 | 
| 1526 def _task_complete(self, pkg): | 1514 def _task_complete(self, pkg): | 
| 1527 self._completed_tasks.add(pkg) | 1515 self._completed_tasks.add(pkg) | 
| 1528 self._unsatisfied_system_deps.discard(pkg) | 1516 self._unsatisfied_system_deps.discard(pkg) | 
| 1529 self._choose_pkg_return_early = False | 1517 self._choose_pkg_return_early = False | 
| 1518 blocker_db = self._blocker_db[pkg.root] | |
| 1519 blocker_db.discardBlocker(pkg) | |
| 1530 | 1520 | 
| 1531 def _merge(self): | 1521 def _merge(self): | 
| 1532 | 1522 | 
| 1533 self._add_prefetchers() | 1523 self._add_prefetchers() | 
| 1534 self._add_packages() | 1524 self._add_packages() | 
| 1535 pkg_queue = self._pkg_queue | 1525 pkg_queue = self._pkg_queue | 
| 1536 failed_pkgs = self._failed_pkgs | 1526 failed_pkgs = self._failed_pkgs | 
| 1537 portage.locks._quiet = self._background | 1527 portage.locks._quiet = self._background | 
| 1538 portage.elog.add_listener(self._elog_listener) | 1528 portage.elog.add_listener(self._elog_listener) | 
| 1539 rval = os.EX_OK | 1529 rval = os.EX_OK | 
| (...skipping 537 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... | |
| 2077 tree_type = depgraph.pkg_tree_map[type_name] | 2067 tree_type = depgraph.pkg_tree_map[type_name] | 
| 2078 db = root_config.trees[tree_type].dbapi | 2068 db = root_config.trees[tree_type].dbapi | 
| 2079 db_keys = list(self.trees[root_config.root][ | 2069 db_keys = list(self.trees[root_config.root][ | 
| 2080 tree_type].dbapi._aux_cache_keys) | 2070 tree_type].dbapi._aux_cache_keys) | 
| 2081 metadata = zip(db_keys, db.aux_get(cpv, db_keys)) | 2071 metadata = zip(db_keys, db.aux_get(cpv, db_keys)) | 
| 2082 pkg = Package(built=(type_name != "ebuild"), | 2072 pkg = Package(built=(type_name != "ebuild"), | 
| 2083 cpv=cpv, installed=installed, metadata=metadata, | 2073 cpv=cpv, installed=installed, metadata=metadata, | 
| 2084 root_config=root_config, type_name=type_name) | 2074 root_config=root_config, type_name=type_name) | 
| 2085 self._pkg_cache[pkg] = pkg | 2075 self._pkg_cache[pkg] = pkg | 
| 2086 return pkg | 2076 return pkg | 
| OLD | NEW |