From d9785f96de5f1697b5f87def919dc358cc2cc30d Mon Sep 17 00:00:00 2001 From: Brian Harring Date: Sat, 5 Nov 2005 06:13:33 +0000 Subject: integration chunk of the cache subsystem patch. Will deal with UNUSED_0* after this svn path=/main/branches/2.0/; revision=2258 --- bin/emerge | 127 +++++++++++++++++++++++++----------------------------------- bin/repoman | 2 +- 2 files changed, 53 insertions(+), 76 deletions(-) (limited to 'bin') diff --git a/bin/emerge b/bin/emerge index 6ea0aceb0..3a38f66a0 100755 --- a/bin/emerge +++ b/bin/emerge @@ -2671,14 +2671,12 @@ if myaction in ["sync","rsync","metadata"] and (not "--help" in myopts): portage.portdb.flush_cache() - try: - os.umask(002) - os.chown(cachedir, os.getuid(), portage.portage_gid) - os.chmod(cachedir, 02775) - except SystemExit, e: - raise # Needed else can't exit - except: - pass + ec = portage.eclass_cache.cache(portage.portdb.porttree_root) + # kinda ugly. + # XXX: nuke the filter when mr UNUSED_0? keys are dead + cm = portage.settings.load_best_module("portdbapi.metadbmodule")(myportdir, "metadata/cache", + filter(lambda x: not x.startswith("UNUSED_0"), portage.auxdbkeys)) + # we don't make overlay trees cache here, plus we don't trust portage.settings.categories porttree_root = portage.portdb.porttree_root conf = portage.config(config_profile_path=portage.settings.profile_path[:], \ @@ -2694,75 +2692,54 @@ if myaction in ["sync","rsync","metadata"] and (not "--help" in myopts): pass pdb = portage.portdbapi(porttree_root, conf) - cp_list = pdb.cp_all() - if len(cp_list) == 0: - print "no metadata to transfer, exiting" - sys.exit(0) - cp_list.sort() - pcnt=0 - pcntstr="" - pcntcount=len(cp_list)/100.0 - nextupdate=pcntcount - current=1 - - def cleanse_cache(pdb, cat, saves, porttree_root=porttree_root): - try: - if len(saves): - d={} - for v in saves: - d[portage.catsplit(v)[1]] = True - for pv in pdb.auxdb[porttree_root][cat].keys(): - if pv not in d: - pdb.auxdb[porttree_root][cat].del_key(pv) - else: - try: - pdb.auxdb[porttree_root][cat].clear() - del pdb.auxdb[porttree_root][cat] - except KeyError: - pass - except KeyError: - # stop breaking things, cleansing is minor. - pass - savelist = [] - catlist = [] - oldcat = portage.catsplit(cp_list[0])[0] - for cp in cp_list: - current += 1 - if current >= nextupdate: - pcnt += 1 - nextupdate += pcntcount - if "--quiet" not in myopts: - pcntstr = str(pcnt) - sys.stdout.write("\b"*(len(pcntstr)+1)+pcntstr+"%") - sys.stdout.flush() - cat = portage.catsplit(cp)[0] - if cat != oldcat: - catlist.append(oldcat) - cleanse_cache(pdb, oldcat, savelist) - savelist = [] - oldcat = cat - mymatches = pdb.xmatch("match-all", cp) - savelist.extend(mymatches) - for cpv in mymatches: - try: pdb.aux_get(cpv, ["IUSE"],metacachedir=myportdir+"/metadata/cache",debug=("cachedebug" in portage.features)) - except SystemExit: raise - except Exception, e: print "\nFailed cache update:",cpv,e - catlist.append(oldcat) - catlist.append("local") - cleanse_cache(pdb, oldcat, savelist) - filelist = portage.listdir(cachedir+"/"+myportdir) - for x in filelist: - found = False - for y in catlist: - if x.startswith(y): - found = True - break - if not found: - portage.spawn("cd /; rm -Rf "+cachedir+"/"+myportdir+"/"+x,portage.settings,free=1,droppriv=1) + cp_all_list = pdb.cp_all() + import cache.util + + class percentage_noise_maker(cache.util.quiet_mirroring): + def __init__(self, dbapi): + self.dbapi = dbapi + self.cp_all = dbapi.cp_all() + self.cp_all.sort() + l = len(self.cp_all) + self.call_update_min = 100000000 + self.min_cp_all = l/100.0 + self.count = 1 + self.pstr = '' + + def __iter__(self): + for x in self.cp_all: + self.count += 1 + if self.count > self.min_cp_all: + self.call_update_min = 0 + self.count = 0 + for y in self.dbapi.cp_list(x): + yield y + self.call_update_mine = 0 + + def update(self, *arg): + try: self.pstr = int(self.pstr) + 1 + except ValueError: self.pstr = 1 + sys.stdout.write("%s%i%%" % ("\b" * (len(str(self.pstr))+1), self.pstr)) + sys.stdout.flush() + self.call_update_min = 10000000 + + def finish(self, *arg): + sys.stdout.write("\b\b\b\b100%\n") + sys.stdout.flush() - sys.stdout.write("\n\n") + if "--quiet" in myopts: + def quicky_cpv_generator(cp_all_list): + for x in cp_all_list: + for y in pdb.cp_list(x): + yield y + source = quicky_cpv_generator(pdb.cp_all()) + noise_maker = cache.util.quiet_mirroring() + else: + noise_maker = source = percentage_noise_maker(pdb) + cache.util.mirror_cache(source, cm, pdb.auxdb[porttree_root], eclass_cache=ec, verbose_instance=noise_maker) + sys.stdout.flush() portage.portageexit() @@ -2796,7 +2773,7 @@ elif myaction=="regen": print "processing",x for y in mymatches: try: - foo=portage.portdb.aux_get(y,["DEPEND"],debug=1) + foo=portage.portdb.aux_get(y,["DEPEND"]) except SystemExit, e: # sys.exit is an exception... And consequently, we can't catch it. raise diff --git a/bin/repoman b/bin/repoman index 9e4afb231..49578ad59 100755 --- a/bin/repoman +++ b/bin/repoman @@ -898,7 +898,7 @@ for x in scanlist: fails["ebuild.namenomatch"].append(x+"/"+y+".ebuild") continue try: - myaux=portage.db["/"]["porttree"].dbapi.aux_get(catdir+"/"+y,allvars,strict=1) + myaux=portage.db["/"]["porttree"].dbapi.aux_get(catdir+"/"+y,allvars) except KeyError: stats["ebuild.syntax"]=stats["ebuild.syntax"]+1 fails["ebuild.syntax"].append(x+"/"+y+".ebuild") -- cgit v1.2.3-1-g7c22