Add treetype instance member to dblink. Add treetype parameters to v2.0.53_rc7
authorJason Stubbs <jstubbs@gentoo.org>
Sun, 30 Oct 2005 07:23:42 +0000 (07:23 -0000)
committerJason Stubbs <jstubbs@gentoo.org>
Sun, 30 Oct 2005 07:23:42 +0000 (07:23 -0000)
dblink.__init__() and merge(). Adjust all calls to dblink(), merge()
and doebuild() to specify what tree should be used for aux_get().
Patch created with the help of Zac Medico (zmedico).

svn path=/main/branches/2.0/; revision=2203

bin/emerge
bin/repoman
pym/portage.py
pym/portage_util.py

index 1522b57a70026c87b29875c46b5edc99123eb764..05b86ad762f6595a755399500ce5e71b27e1cfef 100755 (executable)
@@ -1848,9 +1848,9 @@ class depgraph:
                                        raise Exception, "Merging a blocker"
                                elif ("--fetchonly" in myopts) or ("--fetch-all-uri" in myopts):
                                        if ("--fetch-all-uri" in myopts):
-                                               retval=portage.doebuild(y,"fetch",myroot,self.pkgsettings,edebug,("--pretend" in myopts),fetchonly=1,fetchall=1)
+                                               retval=portage.doebuild(y,"fetch",myroot,self.pkgsettings,edebug,("--pretend" in myopts),fetchonly=1,fetchall=1,tree="porttree")
                                        else:
-                                               retval=portage.doebuild(y,"fetch",myroot,self.pkgsettings,edebug,("--pretend" in myopts),fetchonly=1)
+                                               retval=portage.doebuild(y,"fetch",myroot,self.pkgsettings,edebug,("--pretend" in myopts),fetchonly=1,tree="porttree")
                                        if (retval == None) or retval:
                                                print
                                                print "!!! Fetch for",y,"failed, continuing..."
@@ -1865,7 +1865,7 @@ class depgraph:
                                        #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)
-                                       retval=portage.doebuild(y,"clean",myroot,self.pkgsettings,edebug,cleanup=1)
+                                       retval=portage.doebuild(y,"clean",myroot,self.pkgsettings,edebug,cleanup=1,tree="porttree")
                                        if (retval == None):
                                                portage_util.writemsg("Unable to run required binary.\n")
                                                sys.exit(127)
@@ -1873,7 +1873,7 @@ class depgraph:
                                                sys.exit(retval)
                                        short_msg = "emerge: ("+str(mergecount)+" of "+str(len(mymergelist))+") "+x[pkgindex]+" Compile"
                                        emergelog(" === ("+str(mergecount)+" of "+str(len(mymergelist))+") Compiling/Packaging ("+x[pkgindex]+"::"+y+")", short_msg=short_msg)
-                                       retval=portage.doebuild(y,"package",myroot,self.pkgsettings,edebug)
+                                       retval=portage.doebuild(y,"package",myroot,self.pkgsettings,edebug,tree="porttree")
                                        if (retval == None):
                                                portage_util.writemsg("Unable to run required binary.\n")
                                                sys.exit(127)
@@ -1895,7 +1895,7 @@ class depgraph:
                                else:
                                        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)
-                                       retval=portage.doebuild(y,"clean",myroot,self.pkgsettings,edebug,cleanup=1)
+                                       retval=portage.doebuild(y,"clean",myroot,self.pkgsettings,edebug,cleanup=1,tree="porttree")
                                        if (retval == None):
                                                portage_util.writemsg("Unable to run required binary.\n")
                                                sys.exit(127)
@@ -1903,7 +1903,7 @@ class depgraph:
                                                sys.exit(retval)
                                        short_msg = "emerge: ("+str(mergecount)+" of "+str(len(mymergelist))+") "+x[pkgindex]+" Compile"
                                        emergelog(" === ("+str(mergecount)+" of "+str(len(mymergelist))+") Compiling/Merging ("+x[pkgindex]+"::"+y+")", short_msg=short_msg)
-                                       retval=portage.doebuild(y,"merge",myroot,self.pkgsettings,edebug)
+                                       retval=portage.doebuild(y,"merge",myroot,self.pkgsettings,edebug,tree="porttree")
                                        if (retval == None):
                                                portage_util.writemsg("Unable to run required binary.\n")
                                                sys.exit(127)
@@ -1945,7 +1945,7 @@ class depgraph:
                                if ("noclean" not in portage.features) and (x[0] != "binary"):
                                        short_msg = "emerge: ("+str(mergecount)+" of "+str(len(mymergelist))+") "+x[pkgindex]+" Clean Post"
                                        emergelog(" === ("+str(mergecount)+" of "+str(len(mymergelist))+") Post-Build Cleaning ("+x[pkgindex]+"::"+y+")", short_msg=short_msg)
-                                       retval=portage.doebuild(y,"clean",myroot,self.pkgsettings,edebug,cleanup=1)
+                                       retval=portage.doebuild(y,"clean",myroot,self.pkgsettings,edebug,cleanup=1,tree="porttree")
                                        if (retval == None):
                                                portage_util.writemsg("Unable to run required binary.\n")
                                                sys.exit(127)
@@ -2845,7 +2845,7 @@ elif "config"==myaction:
        print
        ebuildpath = portage.db[portage.root]["vartree"].dbapi.findname(pkg)
        mysettings = portage.config(clone=portage.settings)
-       portage.doebuild(ebuildpath,"config",portage.root,mysettings,debug=("--debug" in myopts),cleanup=True)
+       portage.doebuild(ebuildpath,"config",portage.root,mysettings,debug=("--debug" in myopts),cleanup=True,tree="vartree")
        print
 
 # INFO action
@@ -3211,7 +3211,7 @@ else:
                                        if pkgline[0]=="ebuild" and pkgline[3]=="merge":
                                                y=portage.portdb.findname(pkgline[2])
                                                tmpsettings = portage.config(clone=portage.settings)
-                                               retval=portage.doebuild(y,"digest",portage.root,tmpsettings,edebug,("--pretend" in myopts))
+                                               retval=portage.doebuild(y,"digest",portage.root,tmpsettings,edebug,("--pretend" in myopts),tree="porttree")
                        if "--fetchonly" in myopts or "--fetch-all-uri" in myopts:
                                pkglist = []
                                for pkg in mydepgraph.altlist():
index 17f10a63ba2ef7dc125aa0260a5e2257711ae178..9e4afb2314fb212a0eb8241a5e921c869df7d156 100755 (executable)
@@ -800,7 +800,7 @@ for x in scanlist:
                                                                        fails["digest.unmatch"].append(y+"::"+myf)
                                                                else:
                                                                        eb_name,eb_location = portage.db["/"]["porttree"].dbapi.findname2(mykey)
-                                                                       portage.doebuild(eb_name, "digest", "/", uri_settings)
+                                                                       portage.doebuild(eb_name, "digest", "/", uri_settings, tree="porttree")
                                                        else:
                                                                stats["digest.partial"] += 1
                                                                fails["digest.partial"].append(y+"::"+myf)
index 4e4aec9c44336062bdffe4d44fc722694cad0177..1e6dadbead115692457d70c781c66eb8ff146227 100644 (file)
@@ -89,7 +89,7 @@ try:
        import portage_util
        from portage_util import grab_multiple, grabdict, grabdict_package, grabfile, grabfile_package, \
                grabints, map_dictlist_vals, pickle_read, pickle_write, stack_dictlist, stack_dicts, stack_lists, \
-               unique_array, varexpand, writedict, writeints, writemsg, getconfig
+               unique_array, varexpand, writedict, writeints, writemsg, getconfig, dump_traceback
        import portage_exception
        import portage_gpg
        import portage_locks
@@ -2352,9 +2352,13 @@ def eapi_is_supported(eapi):
        return str(eapi).strip() == str(portage_const.EAPI).strip()
 
 
-def doebuild(myebuild,mydo,myroot,mysettings,debug=0,listonly=0,fetchonly=0,cleanup=0,dbkey=None,use_cache=1,fetchall=0,tree="porttree"):
+def doebuild(myebuild,mydo,myroot,mysettings,debug=0,listonly=0,fetchonly=0,cleanup=0,dbkey=None,use_cache=1,fetchall=0,tree=None):
        global db, actionmap_deps
 
+       if not tree:
+               dump_traceback("tree not specified to doebuild")
+               tree = "porttree"
+
        ebuild_path = os.path.abspath(myebuild)
        pkg_dir     = os.path.dirname(ebuild_path)
 
@@ -2759,12 +2763,12 @@ def doebuild(myebuild,mydo,myroot,mysettings,debug=0,listonly=0,fetchonly=0,clea
                        print "!!! mydo=qmerge, but install phase hasn't been ran"
                        sys.exit(1)
                #qmerge is specifically not supposed to do a runtime dep check
-               return merge(mysettings["CATEGORY"],mysettings["PF"],mysettings["D"],mysettings["BUILDDIR"]+"/build-info",myroot,mysettings,myebuild=mysettings["EBUILD"])
+               return merge(mysettings["CATEGORY"],mysettings["PF"],mysettings["D"],mysettings["BUILDDIR"]+"/build-info",myroot,mysettings,myebuild=mysettings["EBUILD"],mytree=tree)
        elif mydo=="merge":
                retval=spawnebuild("install",actionmap,mysettings,debug,alwaysdep=1,logfile=logfile)
                if retval:
                        return retval
-               return merge(mysettings["CATEGORY"],mysettings["PF"],mysettings["D"],mysettings["BUILDDIR"]+"/build-info",myroot,mysettings,myebuild=mysettings["EBUILD"])
+               return merge(mysettings["CATEGORY"],mysettings["PF"],mysettings["D"],mysettings["BUILDDIR"]+"/build-info",myroot,mysettings,myebuild=mysettings["EBUILD"],mytree=tree)
        else:
                print "!!! Unknown mydo:",mydo
                sys.exit(1)
@@ -2937,12 +2941,12 @@ def movefile(src,dest,newmtime=None,sstat=None,mysettings=None):
 
        return newmtime
 
-def merge(mycat,mypkg,pkgloc,infloc,myroot,mysettings,myebuild=None):
-       mylink=dblink(mycat,mypkg,myroot,mysettings)
+def merge(mycat,mypkg,pkgloc,infloc,myroot,mysettings,myebuild=None,mytree=None):
+       mylink=dblink(mycat,mypkg,myroot,mysettings,treetype=mytree)
        return mylink.merge(pkgloc,infloc,myroot,myebuild)
 
 def unmerge(cat,pkg,myroot,mysettings,mytrimworld=1):
-       mylink=dblink(cat,pkg,myroot,mysettings)
+       mylink=dblink(cat,pkg,myroot,mysettings,treetype="vartree")
        if mylink.exists():
                mylink.unmerge(trimworld=mytrimworld,cleanup=1)
        mylink.delete()
@@ -5393,7 +5397,7 @@ class portdbapi(dbapi):
                                        writemsg("Uncaught handled exception: %(exception)s\n" % {"exception":str(e)})
                                        raise
 
-                       myret=doebuild(myebuild,"depend","/",self.mysettings,dbkey=mydbkey)
+                       myret=doebuild(myebuild,"depend","/",self.mysettings,dbkey=mydbkey,tree="porttree")
                        if myret:
                                portage_locks.unlockfile(mylock)
                                self.lock_held = 0
@@ -6027,12 +6031,13 @@ class binarytree(packagetree):
 
 class dblink:
        "this class provides an interface to the standard text package database"
-       def __init__(self,cat,pkg,myroot,mysettings):
+       def __init__(self,cat,pkg,myroot,mysettings,treetype=None):
                "create a dblink object for cat/pkg.  This dblink entry may or may not exist"
                self.cat     = cat
                self.pkg     = pkg
                self.mycpv   = self.cat+"/"+self.pkg
                self.mysplit = pkgsplit(self.mycpv)
+               self.treetype = treetype
 
                self.dbroot   = os.path.normpath(myroot+VDB_PATH)
                self.dbcatdir = self.dbroot+"/"+cat
@@ -6213,7 +6218,7 @@ class dblink:
 
                #do prerm script
                if myebuildpath and os.path.exists(myebuildpath):
-                       a=doebuild(myebuildpath,"prerm",self.myroot,self.settings,cleanup=cleanup,use_cache=0,tree="vartree")
+                       a=doebuild(myebuildpath,"prerm",self.myroot,self.settings,cleanup=cleanup,use_cache=0,tree=self.treetype)
                        # XXX: Decide how to handle failures here.
                        if a != 0:
                                writemsg("!!! FAILED prerm: "+str(a)+"\n")
@@ -6419,7 +6424,7 @@ class dblink:
                if myebuildpath and os.path.exists(myebuildpath):
                        # XXX: This should be the old config, not the current one.
                        # XXX: Use vardbapi to load up env vars.
-                       a=doebuild(myebuildpath,"postrm",self.myroot,self.settings,use_cache=0,tree="vartree")
+                       a=doebuild(myebuildpath,"postrm",self.myroot,self.settings,use_cache=0,tree=self.treetype)
                        # XXX: Decide how to handle failures here.
                        if a != 0:
                                writemsg("!!! FAILED postrm: "+str(a)+"\n")
@@ -6541,9 +6546,9 @@ class dblink:
                if myebuild:
                        # if we are merging a new ebuild, use *its* pre/postinst rather than using the one in /var/db/pkg
                        # (if any).
-                       a=doebuild(myebuild,"preinst",root,self.settings,cleanup=cleanup,use_cache=0)
+                       a=doebuild(myebuild,"preinst",root,self.settings,cleanup=cleanup,use_cache=0,tree=self.treetype)
                else:
-                       a=doebuild(inforoot+"/"+self.pkg+".ebuild","preinst",root,self.settings,cleanup=cleanup,use_cache=0)
+                       a=doebuild(inforoot+"/"+self.pkg+".ebuild","preinst",root,self.settings,cleanup=cleanup,use_cache=0,tree=self.treetype)
 
                # XXX: Decide how to handle failures here.
                if a != 0:
@@ -6658,9 +6663,9 @@ class dblink:
                if myebuild:
                        # if we are merging a new ebuild, use *its* pre/postinst rather than using the one in /var/db/pkg
                        # (if any).
-                       a=doebuild(myebuild,"postinst",root,self.settings,use_cache=0)
+                       a=doebuild(myebuild,"postinst",root,self.settings,use_cache=0,tree=self.treetype)
                else:
-                       a=doebuild(inforoot+"/"+self.pkg+".ebuild","postinst",root,self.settings,use_cache=0)
+                       a=doebuild(inforoot+"/"+self.pkg+".ebuild","postinst",root,self.settings,use_cache=0,tree=self.treetype)
 
                # XXX: Decide how to handle failures here.
                if a != 0:
@@ -7074,7 +7079,7 @@ def pkgmerge(mytbz2,myroot,mysettings):
        # the merge takes care of pre/postinst and old instance
        # auto-unmerge, virtual/provides updates, etc.
        mysettings.load_infodir(infloc)
-       mylink=dblink(mycat,mypkg,myroot,mysettings)
+       mylink=dblink(mycat,mypkg,myroot,mysettings,treetype="bintree")
        mylink.merge(pkgloc,infloc,myroot,myebuild,cleanup=1)
 
        if not os.path.exists(infloc+"/RDEPEND"):
index 3584e5fdc7f9891341d7f175d7713d1cae472add..6a0c10155c92872fcf801fab30d01fcda2303504 100644 (file)
@@ -455,5 +455,11 @@ def unique_array(array):
        return mya
 
 
-
-
+def dump_traceback(msg):
+       import sys, traceback
+       writemsg("\n====================================\n", noiselevel=1)
+       writemsg("Warning: %s\n" % msg, noiselevel=1)
+       for line in traceback.format_list(traceback.extract_stack()[:-1]):
+               writemsg(line, noiselevel=1)
+       writemsg("Please file a bug for %s\n" % sys.argv[0], noiselevel=1)
+       writemsg("====================================\n\n", noiselevel=1)