#!/usr/bin/python -O # # Parallel emerge --regen, useful for SMP systems # # Copyright 2005 Sven Wegener # Distributed under the terms of the GNU General Public License v2 # # $Id: regendepcache 278 2005-09-05 19:42:45Z sven $ # import portage from os import fork, wait from sys import exit, argv # Multiple package workers is a bad thing, because portage has category-based depcaches # and having several package workers for the same category may mess up the cache. try: max_category_procs = int(argv[1]) except: max_category_procs = 2 try: max_package_procs = int(argv[2]) except: max_package_procs = 1 category_procs = 0 package_procs = 0 dbapi = portage.db['/']['porttree'].dbapi cp_all = dbapi.cp_all() for c in portage.settings.categories: if category_procs >= max_category_procs: wait() category_procs -= 1 if max_category_procs == 1 or not fork(): for cp in [cp for cp in cp_all if cp.startswith(c + '/')]: print cp if package_procs >= max_package_procs: wait() package_procs -= 1 if max_package_procs == 1 or not fork(): for cpv in dbapi.cp_list(cp): ignore = dbapi.aux_get(cpv, ['DESCRIPTION']) if max_package_procs != 1: exit(0) else: package_procs += 1 if max_category_procs != 1: exit(0) else: category_procs += 1