aboutsummaryrefslogtreecommitdiff
diff options
context:
space:
mode:
Diffstat (limited to 'pym/portage.py')
-rw-r--r--pym/portage.py110
1 files changed, 66 insertions, 44 deletions
diff --git a/pym/portage.py b/pym/portage.py
index cfda9b6..c115653 100644
--- a/pym/portage.py
+++ b/pym/portage.py
@@ -1,7 +1,7 @@
# portage.py -- core Portage functionality
# Copyright 1998-2003 Daniel Robbins, Gentoo Technologies, Inc.
# Distributed under the GNU Public License v2
-# $Header: /local/data/ulm/cvs/history/var/cvsroot/gentoo-src/portage/pym/portage.py,v 1.325 2003/06/30 06:43:38 carpaski Exp $
+# $Header: /local/data/ulm/cvs/history/var/cvsroot/gentoo-src/portage/pym/portage.py,v 1.326 2003/07/02 03:23:36 carpaski Exp $
VERSION="2.0.48_pre6"
@@ -93,6 +93,19 @@ def abssymlink(symlink):
mylink=mydir+"/"+mylink
return os.path.normpath(mylink)
+def suffix_array(array,suffix,doblanks=1):
+ """Appends a given suffix to each element in an Array/List/Tuple.
+ Returns a List."""
+ if type(array) not in [types.ListType, types.TupleType]:
+ raise TypeError, "List or Tuple expected. Got %s" % type(array)
+ newarray=[]
+ for x in array:
+ if x or doblanks:
+ newarray.append(x + suffix)
+ else:
+ newarray.append(x)
+ return newarray
+
dircache={}
def listdir(mypath,recursive=0,filesonly=0,ignorecvs=0,ignorelist=[],EmptyOnError=0):
"""List directory contents, using cache.
@@ -493,9 +506,9 @@ def env_update(makelinks=1):
# we can safely create links.
print ">>> Regenerating "+root+"etc/ld.so.cache..."
if makelinks:
- getstatusoutput("/sbin/ldconfig -r "+root)
+ getstatusoutput("cd / ; /sbin/ldconfig -r "+root)
else:
- getstatusoutput("/sbin/ldconfig -X -r "+root)
+ getstatusoutput("cd / ; /sbin/ldconfig -X -r "+root)
del specials["LDPATH"]
penvnotice ="# THIS FILE IS AUTOMATICALLY GENERATED BY env-update.\n"
@@ -1262,9 +1275,10 @@ def digestgen(myarchives,overwrite=1,manifestonly=0):
os.makedirs(settings["FILESDIR"])
mycvstree=cvstree.getentries(pbasedir, recursive=1)
- if ("cvs" in features) and not cvstree.isadded(mycvstree,"files"):
- print ">>> Auto-adding files/ dir to CVS..."
- spawn("cd "+pbasedir+"; cvs add files",free=1)
+ if ("cvs" in features) and os.path.exists(pbasedir+"/CVS"):
+ if not cvstree.isadded(mycvstree,"files"):
+ print ">>> Auto-adding files/ dir to CVS..."
+ spawn("cd "+pbasedir+"; cvs add files",free=1)
if (not overwrite) and os.path.exists(digestfn):
return 1
@@ -1317,7 +1331,7 @@ def digestgen(myarchives,overwrite=1,manifestonly=0):
except Exception,e:
print e
- if "cvs" in features:
+ if "cvs" in features and os.path.exists(pbasedir+"/CVS"):
mycvstree=cvstree.getentries(pbasedir, recursive=1)
myunaddedfiles=""
if not manifestonly and not cvstree.isadded(mycvstree,digestfn):
@@ -1479,7 +1493,7 @@ def doebuild(myebuild,mydo,myroot,debug=0,listonly=0,fetchonly=0):
if mydo not in ["help","clean","prerm","postrm","preinst","postinst",
"config","touch","setup","depend","fetch","digest",
"unpack","compile","install","rpm","qmerge","merge",
- "package","unmerge"]:
+ "package","unmerge", "manifest"]:
print "!!! Please specify a valid command."
return 1
if not os.path.exists(myebuild):
@@ -1552,7 +1566,7 @@ def doebuild(myebuild,mydo,myroot,debug=0,listonly=0,fetchonly=0):
return myso[0]
# Build directory creation isn't required for any of these.
- if mydo not in ["digest"]:
+ if mydo not in ["digest","manifest"]:
try:
if ("nouserpriv" not in string.split(settings["RESTRICT"])):
if ("userpriv" in features) and (portage_uid and portage_gid):
@@ -1707,6 +1721,8 @@ def doebuild(myebuild,mydo,myroot,debug=0,listonly=0,fetchonly=0):
elif mydo=="digest":
#since we are calling "digest" directly, recreate the digest even if it already exists
return (not digestgen(checkme,overwrite=1))
+ if mydo=="manifest":
+ return (not digestgen(checkme,overwrite=1,manifestonly=1))
if not digestcheck(checkme, ("strict" in features)):
return 1
@@ -3250,7 +3266,8 @@ def eclass(myeclass=None,mycpv=None,mymtime=None):
if not mtimedb.has_key("starttime") or (mtimedb["starttime"]!=starttime):
mtimedb["starttime"]=starttime
# Update the cache
- for x in [settings["PORTDIR"]+"/eclass", settings["PORTDIR_OVERLAY"]+"/eclass"]:
+ ec_overlays = suffix_array(string.split(settings["PORTDIR_OVERLAY"]), "/eclass")
+ for x in [settings["PORTDIR"]+"/eclass"]+ec_overlays:
if x and os.path.exists(x):
dirlist = listdir(x)
for y in dirlist:
@@ -3326,8 +3343,8 @@ class portdbapi(dbapi):
#if the portdbapi is "frozen", then we assume that we can cache everything (that no updates to it are happening)
self.xcache={}
self.frozen=0
- #oroot="overlay root"
- self.oroot=None
+ #overlays="overlay roots"
+ self.overlays=[]
def finddigest(self,mycpv):
try:
@@ -3355,8 +3372,7 @@ class portdbapi(dbapi):
sys.exit(1)
psplit=pkgsplit(mysplit[1])
- if self.oroot:
- myloc=self.oroot+"/"+mysplit[0]+"/"+psplit[0]+"/"+mysplit[1]+".ebuild"
+ for myloc in suffix_array(self.overlays, "/"+mysplit[0]+"/"+psplit[0]+"/"+mysplit[1]+".ebuild"):
if os.access(myloc, os.R_OK):
return myloc,1
@@ -3581,10 +3597,10 @@ class portdbapi(dbapi):
if not cps:
#invalid cat/pkg-v
return 0
- if self.oroot:
- if os.path.exists(self.oroot+"/"+cps[0]+"/"+cps[1]+"/"+cps2[1]+".ebuild") or os.path.exists(self.oroot+"/"+cps[0]+"/"+cps[1]+"/"+cps2[1]+".ebuild"):
+ for o_cpv in suffix_array(self.overlays,"/"+cps[0]+"/"+cps[1]+"/"+cps2[1]+".ebuild"):
+ if os.path.exists(o_cpv):
return 1
- elif os.path.exists(self.root+"/"+cps[0]+"/"+cps[1]+"/"+cps2[1]+".ebuild"):
+ if os.path.exists(self.root+"/"+cps[0]+"/"+cps[1]+"/"+cps2[1]+".ebuild"):
return 1
return 0
@@ -3596,10 +3612,8 @@ class portdbapi(dbapi):
if y=="CVS":
continue
biglist.append(x+"/"+y)
- if self.oroot:
- for y in listdir(self.oroot+"/"+x,EmptyOnError=1):
- if y=="CVS":
- continue
+ for oroot in self.overlays:
+ for y in listdir(oroot+"/"+x,EmptyOnError=1,ignorecvs=1):
mykey=x+"/"+y
if not mykey in biglist:
biglist.append(mykey)
@@ -3610,8 +3624,8 @@ class portdbapi(dbapi):
for x in listdir(self.root+"/"+mycp,EmptyOnError=1):
if x[-7:]==".ebuild":
returnme.append(x[:-7])
- if self.oroot:
- for x in listdir(self.oroot+"/"+mycp,EmptyOnError=1):
+ for oroot in self.overlays:
+ for x in listdir(oroot+"/"+mycp,EmptyOnError=1,ignorecvs=1):
if x[-7:]==".ebuild":
mye=x[:-7]
if not mye in returnme:
@@ -3626,14 +3640,12 @@ class portdbapi(dbapi):
for x in list:
if x[-7:]==".ebuild":
returnme.append(mysplit[0]+"/"+x[:-7])
- if self.oroot:
- list=listdir(self.oroot+"/"+mycp,EmptyOnError=1)
- if list:
- for x in list:
- if x[-7:]==".ebuild":
- mycp=mysplit[0]+"/"+x[:-7]
- if not mycp in returnme:
- returnme.append(mycp)
+ for oroot in self.overlays:
+ for x in listdir(oroot+"/"+mycp,EmptyOnError=1,ignorecvs=1):
+ if x[-7:]==".ebuild":
+ mycp=mysplit[0]+"/"+x[:-7]
+ if not mycp in returnme:
+ returnme.append(mycp)
return returnme
def freeze(self):
@@ -4398,13 +4410,17 @@ class dblink:
continue
prot_num = prot_num + 1
+ new_pfile = os.path.normpath(real_dirname+"/._cfg"+string.zfill(prot_num,4)+"_"+real_filename)
+ old_pfile = os.path.normpath(real_dirname+"/"+last_pfile)
if last_pfile and newmd5:
if perform_md5(real_dirname+"/"+last_pfile) == newmd5:
- return os.path.normpath(real_dirname+"/"+last_pfile)
+ return old_pfile
else:
- return os.path.normpath(real_dirname+"/._cfg"+string.zfill(prot_num,4)+"_"+real_filename)
-
- return (real_dirname+"/._cfg"+string.zfill(prot_num,4)+"_"+real_filename, real_dirname+"/"+last_pfile)
+ return new_pfile
+ elif newmd5:
+ return new_pfile
+ else:
+ return (new_pfile, old_pfile)
def mergeme(self,srcroot,destroot,outfile,secondhand,stufftomerge,cfgfiledict,thismtime):
srcroot=os.path.normpath("///"+srcroot)+"/"
@@ -4459,9 +4475,9 @@ class dblink:
if self.isprotected(mydest):
# Use md5 of the target in ${D} if it exists...
if os.path.exists(os.path.normpath(srcroot+myabsto)):
- mydest = self.new_protect_filename(myrealdest, perform_md5(srcroot+myabsto))[0]
+ mydest = self.new_protect_filename(myrealdest, perform_md5(srcroot+myabsto))
else:
- mydest = self.new_protect_filename(myrealdest, perform_md5(myabsto))[0]
+ mydest = self.new_protect_filename(myrealdest, perform_md5(myabsto))
# if secondhand==None it means we're operating in "force" mode and should not create a second hand.
if (secondhand!=None) and (not os.path.exists(myrealto)):
@@ -4965,13 +4981,19 @@ if (secpass==2) and (not os.environ.has_key("SANDBOX_ACTIVE")):
#the new standardized db names:
portdb=portdbapi()
-if settings["PORTDIR_OVERLAY"]:
- if os.path.isdir(settings["PORTDIR_OVERLAY"]):
- portdb.oroot=settings["PORTDIR_OVERLAY"]
- else:
- sys.stderr.write("!!! PORTDIR_OVERLAY points to "+settings["PORTDIR_OVERLAY"]+"\n")
- sys.stderr.write("!!! which isn't a directory... Exiting.\n")
- sys.exit(1)
+overlays = string.split(settings["PORTDIR_OVERLAY"])
+if overlays:
+ portdb.overlays = overlays[:]
+ for ov in overlays:
+ if not os.path.isdir(ov):
+ sys.stderr.write(red("!!! Invalid PORTDIR_OVERLAY entry removed: "+ov+"\n"))
+ portdb.overlays.remove(ov)
+ os.environ["PORTDIR_OVERLAY"] = string.join(portdb.overlays)
+ settings["PORTDIR_OVERLAY"] = string.join(portdb.overlays)
+else:
+ portdb.overlays = []
+del overlays
+
#continue setting up other trees
db["/"]["porttree"]=portagetree("/",virts)