diff options
author | Zac Medico <zmedico@gentoo.org> | 2007-05-27 13:59:47 +0000 |
---|---|---|
committer | Zac Medico <zmedico@gentoo.org> | 2007-05-27 13:59:47 +0000 |
commit | 9bcdfdf1bdf3e4f2963b7798d7d6c156fd7a12ec (patch) | |
tree | a09e3d9b50d163c7ad911d849ed6004205dc8569 | |
parent | 554d48ceeeef6cc03c4f3a04f5ec6572e4a3d5fb (diff) | |
download | portage-9bcdfdf1bdf3e4f2963b7798d7d6c156fd7a12ec.tar.gz portage-9bcdfdf1bdf3e4f2963b7798d7d6c156fd7a12ec.tar.bz2 portage-9bcdfdf1bdf3e4f2963b7798d7d6c156fd7a12ec.zip |
Add an emaint "binhost" target which does the time consuming population of $PKGDIR/Packages that is necessary for a binhost (MD5 makes it relatively slow). It reuses metadata from the existing Packages file whenever possible.
svn path=/main/trunk/; revision=6643
-rwxr-xr-x | bin/emaint | 60 |
1 files changed, 59 insertions, 1 deletions
diff --git a/bin/emaint b/bin/emaint index e1fe40d7d..ea9cca085 100755 --- a/bin/emaint +++ b/bin/emaint @@ -74,6 +74,61 @@ class WorldHandler(object): errors.append(self.world_file + " could not be opened for writing") return errors +class BinhostHandler(object): + + def name(): + return "binhost" + name = staticmethod(name) + + def __init__(self): + myroot = portage.settings["ROOT"] + self._bintree = portage.db[myroot]["bintree"] + self._bintree.populate() + self._pkgindex_file = os.path.join(self._bintree.pkgdir, "Packages") + from portage import getbinpkg + self._pkgindex = getbinpkg.PackageIndex() + f = open(self._pkgindex_file, 'r') + try: + self._pkgindex.read(f) + finally: + f.close() + + def check(self, onProgress=None): + errors = [] + missing = [] + cpv_all = self._bintree.dbapi.cpv_all() + cpv_all.sort() + maxval = len(cpv_all) + if onProgress: + onProgress(maxval, 0) + pkgindex = self._pkgindex + missing = [] + for i, cpv in enumerate(cpv_all): + d = pkgindex.packages.get(cpv) + if not d or "MD5" not in d: + missing.append(cpv) + if onProgress: + onProgress(maxval, i+1) + return ["'%s' is not in Packages" % cpv for cpv in missing] + + def fix(self, onProgress=None): + bintree = self._bintree + cpv_all = self._bintree.dbapi.cpv_all() + cpv_all.sort() + missing = [] + maxval = len(cpv_all) + if onProgress: + onProgress(maxval, 0) + pkgindex = self._pkgindex + missing = [] + for i, cpv in enumerate(cpv_all): + d = pkgindex.packages.get(cpv) + if not d or "MD5" not in d: + bintree.inject(cpv) + if onProgress: + onProgress(maxval, i+1) + return None + class VdbKeyHandler(object): def name(): return "vdbkeys" @@ -154,7 +209,10 @@ def emaint_main(myargv): # TODO: Create a system that allows external modules to be added without # the need for hard coding. - modules = {"world" : WorldHandler} + modules = { + "world" : WorldHandler, + "binhost":BinhostHandler + } module_names = modules.keys() module_names.sort() |