--- pym/config.py 2005-03-23 19:37:42.000000000 +0100 +++ pym/config.py 2005-04-12 17:49:21.000000000 +0200 @@ -464,9 +472,9 @@ self.configdict["pkg"]["USE"] = self.puse[:] # this gets appended to USE self.reset(keeping_pkg=1,use_cache=use_cache) - def setinst(self,mycpv,mydbapi): + def getprovides(self,mycpv,mydbapi): """ - Grab the virtuals this package provides and add them into the tree virtuals. + Returns the list of virtuals a package provides. """ provides = mydbapi.aux_get(mycpv, ["PROVIDE"])[0] @@ -478,7 +486,13 @@ else: myuse = mydbapi.aux_get(mycpv, ["USE"])[0] virts = flatten(portage_dep.use_reduce(portage_dep.paren_reduce(provides), uselist=myuse.split())) + return virts + def setinst(self,mycpv,mydbapi): + """ + Grab the virtuals this package provides and add them into the tree virtuals. + """ + virts = self.getprovides(mycpv,mydbapi) cp = portage_dep.dep_getkey(mycpv) for virt in virts: virt = portage_dep.dep_getkey(virt) @@ -490,7 +504,22 @@ for v in val.values(): v.reverse() self.virtuals = val - + + def issystem(self,mydbapi,mycpv=None): + """ + Check whether mycpv (or self.mycpv) is a system package (or provides a system virtual) + """ + if not mycpv: + if self.mycpv: mycpv = self.mycpv + else: return 0 + mysplit = portage_versions.pkgsplit(mycpv) + pkgdeps = [ dep[1:] for dep in self.packages if dep[0] == '*' ] + if portage_dep.match_to_list(mycpv,pkgdeps): return 1 + myprovides = self.getprovides(mycpv,mydbapi) + for mykey in myprovides: + if mykey in pkgdeps: return 1 + return 0 + def regenerate(self,useonly=0,use_cache=1): if self.already_in_regenerate: # XXX: THIS REALLY NEEDS TO GET FIXED. autouse() loops. --- pym/portage_const.py 2005-03-23 19:37:42.000000000 +0100 +++ pym/portage_const.py 2005-03-26 15:45:51.000000000 +0100 @@ -49,7 +49,7 @@ SANDBOX_PIDS_FILE = "/tmp/sandboxpids.tmp" CONFIG_MEMORY_FILE = PRIVATE_PATH + "/config" -INCREMENTALS=["USE","FEATURES","ACCEPT_KEYWORDS","ACCEPT_LICENSE","CONFIG_PROTECT_MASK","CONFIG_PROTECT","PRELINK_PATH","PRELINK_PATH_MASK"] +INCREMENTALS=["USE","FEATURES","ACCEPT_KEYWORDS","ACCEPT_LICENSE","CONFIG_PROTECT_MASK","CONFIG_PROTECT","PRELINK_PATH","PRELINK_PATH_MASK","BUILD_PKGS"] STICKIES=["KEYWORDS_ACCEPT","USE","CFLAGS","CXXFLAGS","MAKEOPTS","EXTRA_ECONF","EXTRA_EINSTALL","EXTRA_EMAKE"] CONFCACHE_FILE = CACHE_PATH+"/confcache" --- pym/portage.py 2005-03-23 19:37:42.000000000 +0100 +++ pym/portage.py 2005-04-29 17:36:27.000000000 +0200 @@ -3427,6 +3427,43 @@ newlist.append(mycpv) return newlist + def istobuildpkg(self,mycpv): + """ + Check whether a package match the BUILD_PKGS policy. + Returns a boolean. + """ + mykey = cpv_getkey(mycpv) + mycat = mykey.split("/")[0] + mybuildpolicy = self.mysettings["BUILD_PKGS"].split() + # A package will be kept if it matches at least one positive rule, + # and no negative rule of a strictly higher level. Levels are: + # 4 for "cat/pkg", 3 for "category", 2 for "system", 1 for "*" + conclusion=0 + bestrule="" + for myrule in mybuildpolicy: + # Rule sign: negative if "!something" + rulesign=1 + if myrule[0]=="!": + rulesign=-1 + myrule=myrule[1:] + # Calculate rule value (0 if non-matching) + rulevalue=0 + if myrule=="*": + rulevalue = 1 * rulesign + elif myrule=="system" and self.mysettings.issystem(self, mycpv): + rulevalue = 2 * rulesign + elif myrule==mycat: + rulevalue = 3 * rulesign + elif myrule==mykey: + rulevalue = 4 * rulesign + # Update conclusion. Be carefull not to depend on rules ordering. + if (conclusion >= 0) and (abs(rulevalue) > conclusion) \ + or (conclusion < 0) and (abs(rulevalue) >= abs(conclusion)): + conclusion=rulevalue + bestrule=myrule + if conclusion > 0: return bestrule + else: return 0 + class binarytree(packagetree): "this tree scans for a list of all packages available in PKGDIR" def __init__(self,root,pkgdir,virtual=None,clone=None): --- bin/emerge 2005-03-23 19:37:42.000000000 +0100 +++ bin/emerge 2005-04-03 12:54:50.000000000 +0200 @@ -1768,8 +1768,6 @@ if ("--pretend" not in myopts): sys.exit(1) - #buildsyspkg: I need mysysdict also on resume (moved from the else block) - mysysdict=genericdict(syslist) if ("--resume" in myopts): # We're resuming. print green("*** Resuming merge...") @@ -1781,6 +1779,7 @@ else: myfavs=portage.grabfile(portage.root+portage.WORLD_FILE) myfavdict=genericdict(myfavs) + mysysdict=genericdict(syslist) for x in range(len(mylist)): if mylist[x][3]!="nomerge": # Add to the mergelist @@ -1854,12 +1853,8 @@ self.pkgsettings["EMERGE_FROM"] = x[0][:] self.pkgsettings.backup_changes("EMERGE_FROM") - #buildsyspkg: Check if we need to _force_ binary package creation - issyspkg = ("buildsyspkg" in myfeat) \ - and x[0] != "blocks" \ - and mysysdict.has_key(portage.cpv_getkey(x[2])) \ - and not ("--buildpkg" in myopts) if x[0] in ["ebuild","blocks"]: + buildpkgrule = portage.db[myroot]["porttree"].dbapi.istobuildpkg(x[pkgindex]) if (x[0]=="blocks") and ("--fetchonly" not in myopts): raise Exception, "Merging a blocker" elif ("--fetchonly" in myopts) or ("--fetch-all-uri" in myopts): @@ -1873,11 +1868,10 @@ print returnme=1 continue - elif "--buildpkg" in myopts or issyspkg: - #buildsyspkg: Sounds useful to display something, but I don't know if we should also log it - if issyspkg: - print ">>> This is a system package, let's pack a rescue tarball." - #emergelog(">>> This is a system package, let's pack a rescue tarball.") + elif ("--buildpkg" in myopts) or buildpkgrule : + if not ("--buildpkg" in myopts) : + print ">>> We'll keep a binary tarball of this package," + print ">>> because of BUILD_PKGS rule \"%s\"" % buildpkgrule #create pkg, then merge pkg short_msg = "emerge: ("+str(mergecount)+" of "+str(len(mymergelist))+") "+x[pkgindex]+" Clean" emergelog(" === ("+str(mergecount)+" of "+str(len(mymergelist))+") Cleaning ("+x[pkgindex]+"::"+y+")", short_msg=short_msg)