os.kill(0,signal.SIGKILL)
signal.signal(signal.SIGINT,exithandler)
-REPOROOTS=["gentoo-x86"]
+REPOROOTS=["gentoo-x86","gentoo-alt/trunk/prefix"]
shortmodes={"ci":"commit"}
modeshelp={
"scan" : "Scan directory tree for QA issues (default)",
def last():
try:
#Retrieve and unpickle stats and fails from saved files
- savedf=open('/var/cache/edb/repo.stats','r')
+ mystats=os.path.normpath(portage_const.CACHE_DIR+'/repo.stats')
+ myfails=os.path.normpath(portage_const.CACHE_DIR+'/repo.fails')
+ savedf=open(mystat,'r')
stats = pickle.load(savedf)
savedf.close()
- savedf=open('/var/cache/edb/repo.fails','r')
+ savedf=open(myfails,'r')
fails = pickle.load(savedf)
savedf.close()
except SystemExit, e:
print
sys.exit(123)
-if not "--pretend" in myoptions and not isCvs:
+isSvn=False
+myreporoot=None
+if os.path.isdir(".svn"):
+ repoman_settings["PORTDIR_OVERLAY"]=""
+ if "svn" not in portage.features:
+ print
+ print
+ print red('!!! You do not have ')+bold('FEATURES="svn" ')+red("enabled...")
+ print red("!!! ")+bold("Adding \"svn\" to FEATURES")
+ print
+ os.environ["FEATURES"]=repoman_settings["FEATURES"]+" svn"
+
+ try:
+ isSvn=True
+ myrepoinfo=os.popen("svn info").readlines()
+ myreporoot=myrepoinfo[1].split("var/svnroot/")[1].rstrip()
+ myreporootpath=os.path.normpath(myrepoinfo[1].split("svn.gentoo.org")[1].rstrip().replace(myreporoot,''))
+ except SystemExit, e:
+ raise # Need to propogate this
+ except:
+ err("Error grabbing repository information; exiting.")
+
+if not "--pretend" in myoptions and not isCvs and not isSvn:
print
- print darkgreen("Not in a CVS repository; enabling pretend mode.")
+ print darkgreen("Not in a CVS or SVN repository; enabling pretend mode.")
myoptions.append("--pretend");
myreporoot = os.path.basename(portdir_overlay)
myreporoot += mydir[len(portdir_overlay):-1]
-if isCvs:
+if isCvs or isSvn:
reporoot=None
for x in REPOROOTS:
if myreporoot[0:len(x)]==x:
reporoot=myreporoot
if not reporoot:
err("Couldn't recognize repository type. Supported repositories:\n"+repr(REPOROOTS))
-reposplit=string.split(myreporoot,"/")
+if isSvn:
+ reposplit=string.split(os.path.normpath(myrepoinfo[1].split("svn.gentoo.org")[1].rstrip().replace("/var/svnroot",'')).replace(x,'')[2:],"/")
+ reposplit.insert(0,myrepo)
+else:
+ reposplit=string.split(myreporoot,"/")
repolevel=len(reposplit)
# check if it's in $PORTDIR/$CATEGORY/$PN , otherwise bail if commiting.
# Reason for this is if they're trying to commit in just $FILESDIR/*, the Manifest needs updating.
# this check ensure that repoman knows where it is, and the manifest recommit is at least possible.
if mymode == "commit" and repolevel not in [1,2,3]:
- print red("***")+" Commit attempts *must* be from within a cvs co, category, or package directory."
+ print red("***")+" Commit attempts *must* be from within a cvs or svn co, category, or package directory."
print red("***")+" Attempting to commit from a packages files directory will be blocked for instance."
print red("***")+" This is intended behaviour, to ensure the manifest is recommited for a package."
print red("***")
except:
err("Couldn't read KEYWORDS from arch.list")
if not kwlist:
- kwlist=["alpha","arm","hppa","mips","ppc","sparc","x86"]
+ kwlist=["alpha","arm","hppa","mips","ppc","ppc-macos","sparc","x86"]
scanlist=[]
if repolevel==2:
caterror(catdir)
mydirlist=os.listdir(startdir)
for x in mydirlist:
- if x=="CVS":
+ if x=="CVS" or x==".svn":
continue
if os.path.isdir(startdir+"/"+x):
scanlist.append(catdir+"/"+x)
if not os.path.isdir(startdir+"/"+x):
continue
for y in os.listdir(startdir+"/"+x):
- if y=="CVS":
+ if y=="CVS" or y==".svn":
continue
if os.path.isdir(startdir+"/"+x+"/"+y):
scanlist.append(x+"/"+y)
s = s[s.rfind("\n") + 1:]
fails["file.UTF8"].append("%s/%s: line %i, just after: '%s'" % (checkdir, y, line, s))
- if isCvs:
+ if isCvs or isSvn:
try:
mystat=os.stat(checkdir+"/files")[0]
if len(ebuildlist) and not S_ISDIR(mystat):
fails["filedir.missing"].append(checkdir)
continue
try:
- myf=open(checkdir+"/CVS/Entries","r")
- myl=myf.readlines()
+ if isCvs:
+ myf=open(checkdir+"/CVS/Entries","r")
+ if isSvn:
+ myf=os.popen("svn list")
+ myl=myf.readlines()
+ myf.close()
for l in myl:
if l[0]!="/":
+ lname=l.split()
+ else:
+ lname=l[1:].split("/")
+ if not len(lname):
continue
- splitl=l[1:].split("/")
- if not len(splitl):
- continue
- objsadded.append(splitl[0])
- if splitl[0][-7:]==".ebuild":
- eadded.append(splitl[0][:-7])
- if splitl[0]=="ChangeLog":
+ objsadded.append(lname[0])
+ if lname[0][-7:]==".ebuild":
+ eadded.append(lname[0][:-7])
+ if lname[0]=="ChangeLog":
cladded=1
except IOError:
- if mymode=="commit":
+ if mymode=="commit" and isCvs:
stats["CVS/Entries.IO_error"] += 1
fails["CVS/Entries.IO_error"].append(checkdir+"/CVS/Entries")
+ if mymode=="commit" and isSvn:
+ stats["svn.IO_error"] += 1
+ fails["svn.IO_error"].append(checkdir+"svn info")
continue
try:
- myf=open(checkdir+"/files/CVS/Entries","r")
+ if isCvs:
+ myf=open(checkdir+"/files/CVS/Entries","r")
+ if isSvn:
+ myf=os.popen("svn list "+os.path.normpath(checkdir+"/files"))
myl=myf.readlines()
+ myf.close()
for l in myl:
if l[0]!="/":
+ lname=l.split()
+ else:
+ lname=l[1:].split("/")
+ if not len(lname):
continue
- splitl=l[1:].split("/")
- if not len(splitl):
- continue
- objsadded.append(splitl[0])
- if splitl[0][:7]=="digest-":
- dadded.append(splitl[0][7:])
+ objsadded.append(lname[0])
+ if lname[0][:7]=="digest-":
+ dadded.append(lname[0][7:])
except IOError:
- if mymode=="commit":
+ if mymode=="commit" and isCvs:
stats["CVS/Entries.IO_error"] += 1
fails["CVS/Entries.IO_error"].append(checkdir+"/files/CVS/Entries")
+ if mymode=="commit" and isSvn:
+ stats["svn.IO_error"] += 1
+ fails["svn.IO_error"].append(checkdir+"/files svn info")
continue
if os.path.exists(checkdir+"/files"):
for y in filesdirlist:
if y[:7]=="digest-":
if y[7:] not in dadded:
- #digest not added to cvs
+ #digest not added to cvs or svn
stats["digest.notadded"]=stats["digest.notadded"]+1
fails["digest.notadded"].append(x+"/files/"+y)
if y[7:] in eadded:
if y[7:] not in ebuildlist:
#stray digest
if mymode=="fix":
+ if isCvs:
+ vcsrm="cvs rm -f"
+ if isSvn:
+ vcsrm="svn rm"
if "--pretend" in myoptions:
- print "(cd "+repodir+"/"+x+"/files; cvs rm -f "+y+")"
+ print "(cd "+repodir+"/"+x+"/files; "+vcsrm+" "+y+")"
+
else:
- os.system("(cd "+repodir+"/"+x+"/files; cvs rm -f "+y+")")
+ os.system("(cd "+repodir+"/"+x+"/files; "+vcsrm+" "+y+")")
else:
stats["digest.stray"]=stats["digest.stray"]+1
fails["digest.stray"].append(x+"/files/"+y)
else:
raise oe
if S_ISDIR(mystat.st_mode):
- if y == "CVS":
+ if y == "CVS" or y == ".svn":
continue
for z in os.listdir(checkdir+"/files/"+y):
filesdirlist.append(y+"/"+z)
if mymode=="fix":
if "--pretend" in myoptions:
print "You will need to run:"
- print " "+"portage_const.PORTAGE_BASE+"/usr/sbin/ebuild "+repodir+"/"+x+"/"+y+".ebuild digest"
+ print " "+portage_const.PORTAGE_BASE+"/bin/ebuild "+repodir+"/"+x+"/"+y+".ebuild digest"
else:
- retval=os.system(portage_const.PORTAGE_BASE+"/usr/sbin/ebuild "+repodir+"/"+x+"/"+y+".ebuild digest")
+ retval=os.system(portage_const.PORTAGE_BASE+"/bin/ebuild "+repodir+"/"+x+"/"+y+".ebuild digest")
if retval:
print "!!! Exiting on ebuild digest (shell) error code:",retval
sys.exit(retval)
fails[mykey].append(x+"/"+y+".ebuild: "+keyword+"("+prof[0]+") "+repr(mydep[1]))
# this check needs work, it won't catch (\ndie)
- if not os.system("@EGREP@ '^[^#]*\([^)]*\<die\>' "+checkdir+"/"+y+".ebuild >/dev/null 2>&1"):
+ if not os.system(portage_const.PREFIX+"/usr/bin/grep -E '^[^#]*\([^)]*\<die\>' "+checkdir+"/"+y+".ebuild >/dev/null 2>&1"):
stats["ebuild.nesteddie"]=stats["ebuild.nesteddie"]+1
fails["ebuild.nesteddie"].append(x+"/"+y+".ebuild")
# uselist checks - global
fails["ebuild.allmasked"].append(x)
#Pickle and save results for instant reuse in last and lfull
-savef=open('/var/cache/edb/repo.stats','w')
+statsfile=os.path.normpath(portage_const.CACHE_PATH+"/repo.stats")
+failsfile=os.path.normpath(portage_const.CACHE_PATH+"/repo.fails")
+savef=open(statsfile,'w')
pickle.dump(stats,savef)
savef.close()
-savef=open('/var/cache/edb/repo.fails','w')
+savef=open(failsfile,'w')
pickle.dump(fails,savef)
savef.close()
-if not (os.stat('/var/cache/edb/repo.stats')[ST_GID] == getgrnam('portage')[2]):
- os.chown('/var/cache/edb/repo.stats',os.geteuid(),getgrnam('portage')[2])
- os.chmod('/var/cache/edb/repo.stats',0664)
-if not (os.stat('/var/cache/edb/repo.fails')[ST_GID] == getgrnam('portage')[2]):
- os.chown('/var/cache/edb/repo.fails',os.geteuid(),getgrnam('portage')[2])
- os.chmod('/var/cache/edb/repo.fails',0664)
-if quiet < 2:
- print
+if not (os.stat(statsfile)[ST_GID] == getgrnam('portage')[2]):
+ os.chown(statsfile,os.geteuid(),getgrnam('portage')[2])
+ os.chmod(statsfile,0664)
+if not (os.stat(failsfile)[ST_GID] == getgrnam('portage')[2]):
+ os.chown(failsfile,os.geteuid(),getgrnam('portage')[2])
+ os.chmod(failsfile,0664)
+print
#dofail will be set to 1 if we have failed in at least one non-warning category
dofail=0
#dowarn will be set to 1 if we tripped any warnings
#dofull will be set if we should print a "repoman full" informational message
dofull=0
for x in qacats:
- if not isCvs and (string.find(x, "notadded") != -1):
+ if not isCvs and not isSvn and (string.find(x, "notadded") != -1):
stats[x] = 0
if stats[x]:
dowarn=1
print "!!! Exiting on ebuild digest (shell) error code:",retval
sys.exit(retval)
- mycvstree=cvstree.getentries("./",recursive=1)
- if isCvs and not mycvstree:
- print "!!! It seems we don't have a cvs tree?"
- sys.exit(3)
+ if isCvs:
+ try:
+ myvcstree=cvstree.getentries("./",recursive=1)
+ myunadded=cvstree.findunadded(myvcstree,recursive=1,basedir="./")
+ except SystemExit, e:
+ raise # TODO propogate this
+ except:
+ err("Error retrieving CVS tree; exiting.")
- myunadded=cvstree.findunadded(mycvstree,recursive=1,basedir="./")
+ if isSvn:
+ try:
+ svnstatus=os.popen("svn status").readlines()
+ myunadded = [ "./"+elem.rstrip().split()[1] for elem in svnstatus if elem.startswith("?") ]
+ except SystemExit, e:
+ raise # TODO propogate this
+ except:
+ err("Error retrieving SVN info; exiting.")
myautoadd=[]
if myunadded:
for x in range(len(myunadded)-1,-1,-1):
if myautoadd:
print ">>> Auto-Adding missing digests..."
if "--pretend" in myoptions:
- print "(cvs add "+string.join(myautoadd)+")"
+ if isCvs:
+ print "(cvs add "+string.join(myautoadd)+")"
+ if isSvn:
+ print "(svn add "+string.join(myautoadd)+")"
retval=0
else:
- retval=os.system("cvs add "+string.join(myautoadd))
+ if isCvs:
+ retval=os.system("cvs add "+string.join(myautoadd))
+ if isSvn:
+ retval=os.system("svn add "+string.join(myautoadd))
if retval:
- print "!!! Exiting on cvs (shell) error code:",retval
+ print "!!! Exiting on vcs (shell) error code:",retval
sys.exit(retval)
if myunadded:
- print red("!!! The following files are in your cvs tree but are not added to the master")
- print red("!!! tree. Please remove them from the cvs tree or add them to the master tree.")
+ print red("!!! The following files are in your local tree but are not added to the master")
+ print red("!!! tree. Please remove them from the local tree or add them to the master tree.")
for x in myunadded:
print " ",x
print
print
sys.exit(1)
+
+ myheaders=[]
+ mychanged=[]
+ mydirty=[]
+ mynew=[]
+ myupdates=[]
+ myremoved=[]
mymissing=None
- if mymissing:
- print "The following files are obviously missing from your cvs tree"
- print "and are being fetched so we can continue:"
- for x in mymissing:
- print " ",x
- if "--pretend" in myoptions:
- print "(cvs -q up "+string.join(mymissing)+")"
- retval=0
- else:
- retval=os.system("cvs -q up "+string.join(mymissing))
- if retval:
- print "!!! Exiting on cvs (shell) error code:",retval
- sys.exit(retval)
- del mymissing
-
- retval=["",""]
if isCvs:
+ if mymissing:
+ print "The following files are obviously missing from your cvs tree"
+ print "and are being fetched so we can continue:"
+ for x in mymissing:
+ print " ",x
+ if "--pretend" in myoptions:
+ print "(cvs -q up "+string.join(mymissing)+")"
+ retval=0
+ else:
+ retval=os.system("cvs -q up "+string.join(mymissing))
+ if retval:
+ print "!!! Exiting on cvs (shell) error code:",retval
+ sys.exit(retval)
+ del mymissing
+ retval=["",""]
print "Performing a "+green("cvs -n up")+" with a little magic grep to check for updates."
- retval=getstatusoutput("cvs -n up 2>&1 | @EGREP@ '^[^\?] .*' | @EGREP@ -v '^. .*/digest-[^/]+|^cvs server: .* -- ignored$'")
-
- mylines=string.split(retval[1], "\n")
- myupdates=[]
- for x in mylines:
- if not x:
- continue
- if x[0] not in "UPMAR": # Updates,Patches,Modified,Added,Removed
- print red("!!! Please fix the following issues reported from cvs: ")+green("(U,P,M,A,R are ok)")
- print red("!!! Note: This is a pretend/no-modify pass...")
- print retval[1]
- print
- sys.exit(1)
- elif x[0] in ["U","P"]:
- myupdates+=[x[2:]]
-
- if myupdates:
- print green("Fetching trivial updates...")
- if "--pretend" in myoptions:
- print "(cvs up "+string.join(myupdates)+")"
- retval=0
- else:
- retval=os.system("cvs up "+string.join(myupdates))
- if retval!=0:
- print "!!! cvs exited with an error. Terminating."
- sys.exit(retval)
+ retval=getstatusoutput("cvs -n up 2>&1 | "+portage_const.PREFIX+"/bin/grep -E '^[^\?] .*' | "+portage_const.PREFIX+"/bin/grep -E -v '^. .*/digest-[^/]+|^cvs server: .* -- ignored$'")
+ mylines=string.split(retval[1], "\n")
+
+ for x in mylines:
+ if not x:
+ continue
+ if x[0] not in "UPMAR": # Updates,Patches,Modified,Added,Removed
+ print red("!!! Please fix the following issues reported from cvs: ")+green("(U,P,M,A,R are ok)")
+ print red("!!! Note: This is a pretend/no-modify pass...")
+ print retval[1]
+ print
+ sys.exit(1)
+ elif x[0] in ["U","P"]:
+ myupdates+=[x[2:]]
- if isCvs:
mycvstree=cvstree.getentries("./",recursive=1)
mychanged=cvstree.findchanged(mycvstree,recursive=1,basedir="./")
mynew=cvstree.findnew(mycvstree,recursive=1,basedir="./")
print "(Didn't find any changed files...)"
print
sys.exit(0)
+ if myupdates:
+ print green("Fetching trivial updates...")
+ if "--pretend" in myoptions:
+ print "(cvs up "+string.join(myupdates)+")"
+ retval=0
+ else:
+ retval=os.system("cvs up "+string.join(myupdates))
+ if retval!=0:
+ print "!!! cvs exited with an error. Terminating."
+ sys.exit(retval)
+ myupdates=mychanged+mynew
+ headerstring="'\$(Header|Id)"
+ headerstring+=".*\$'"
+ for myfile in myupdates:
+ myout=getstatusoutput(portage_const.PREFIX+"/bin/grep -E -q "+headerstring+" "+myfile)
+ if myout[0]==0:
+ myheaders.append(myfile)
+
+ print "*",green(str(len(myupdates))),"files being committed...",green(str(len(myheaders))),"have headers that will change."
+ print "*","Files with headers will cause the manifests to be made and recommited."
+ print "myupdates:",myupdates
+ print "myheaders:",myheaders
+ print
+ unlinkfile=0
+
+ # TODO svn check for UPMAR
+ if isSvn:
+
+ myconflicts=[]
+ print "Checking "+green("svn -u status")+" to check for updates."
+ mylines=[ elem.strip().split() for elem in getstatusoutput("svn -u status")[1].split("\n") ][:-1]
+ if not mylines:
+ print green("Repoman sez:"), "\n\"Yeah....You want me to do nothing? Very Zen.\"\n"
+ print "(Didn't find any changed files...)\n"
+ sys.exit(0)
+ for x in mylines:
+ print x[0]
+ if x[0] not in "ADM!*":
+ myconflicts.append(x[0]+" "+x[-1])
+ elif x[0] in "*!":
+ myupdates+=x[-1]
+ elif x[0]=="A":
+ mynew+=x[-1]
+ elif x[0]=="D":
+ print x[-1]
+ myremoved.append(x[2])
+ elif x[0]=="M":
+ print x[-1]
+ mychanged.append(x[-1])
+ if myconflicts:
+ print red("!!! Please fix the following issues reported from svn: ")+green("type `svn help status` for help")
+ print red("!!! Note: No files have been modified.")
+ for x in myconflicts:
+ print red(x)
+ sys.exit(1)
+ if myupdates:
+ print green("Fetching trivial updates...")
+ if "--pretend" in myoptions:
+ print "(svn -u status "+string.join(myupdates)+")"
+ retval=0
+ else:
+ retval=os.system("svn up "+string.join(myupdates))
+ if reval!=0:
+ print red("!!! svn error. Terminating.")
+ sys.exit(retval)
+ myupdates=mychanged+mynew+myremoved
+ if myremoved:
+ print "*",red(str(len(myremoved))),"file(s) being removed..."
+ if mynew:
+ print "*",green(str(len(mynew))),"file(s) being added..."
+ if mychanged:
+ print "*",green(str(len(mychanged))),"modified..."
+ print "*",green(str(len(myupdates))),"file(s) total being committed..."
+ print "myupdates:",myupdates
- myupdates=mychanged+mynew
- myheaders=[]
- mydirty=[]
- headerstring="'\$(Header|Id)"
- headerstring+=".*\$'"
- for myfile in myupdates:
- myout=getstatusoutput("@EGREP@ -q "+headerstring+" "+myfile)
- if myout[0]==0:
- myheaders.append(myfile)
-
- print "*",green(str(len(myupdates))),"files being committed...",green(str(len(myheaders))),"have headers that will change."
- print "*","Files with headers will cause the manifests to be made and recommited."
- print "myupdates:",myupdates
- print "myheaders:",myheaders
- print
- unlinkfile=0
if not (commitmessage or commitmessagefile):
- print "Please enter a CVS commit message at the prompt:"
+ print "Please enter a commit message at the prompt:"
while not commitmessage:
try:
commitmessage=raw_input(green("> "))
except KeyboardInterrupt:
exithandler()
try:
- commitmessage+="\n(Portage version: "+str(portage.VERSION)+")"
+ commitmessage+="\n(Portage version: "+str(portage.VERSION)+"-prefix)"
except:
print "Failed to insert portage version in message!"
commitmessage+="\n(Portage version: Unknown)"
print
if "--pretend" in myoptions:
- print "(cvs -q commit -F "+commitmessagefile+")"
+ if isCvs:
+ print "(cvs -q commit -F "+commitmessagefile+")"
+ if isSvn:
+ print "(svn -q commit -F "+commitmessagefile+")"
retval=0
else:
- retval=os.system("cvs -q commit -F "+commitmessagefile)
+ if isCvs:
+ retval=os.system("cvs -q commit -F "+commitmessagefile)
+ if isSvn:
+ retval=os.system("svn -q commit -F "+commitmessagefile)
if retval:
- print "!!! Exiting on cvs (shell) error code:",retval
+ print "!!! Exiting on vcs (shell) error code:",retval
sys.exit(retval)
# Setup the GPG commands
sys.exit(1)
if "--pretend" in myoptions:
- print "(cvs -q commit -F "+commitmessagefile+")"
+ if isCvs:
+ print "(cvs -q commit -F "+commitmessagefile+")"
+ if isSvn:
+ print "(svn -q commit -F "+commitmessagefile+")"
else:
mymsg=open(commitmessagefile,"w")
mymsg.write(commitmessage)
mymsg.write("\n (Unsigned Manifest commit)")
mymsg.close()
- retval=os.system("cvs -q commit -F "+commitmessagefile)
+ if isCvs:
+ retval=os.system("cvs -q commit -F "+commitmessagefile)
+ if isSvn:
+ retval=os.system("svn -q commit -F "+commitmessagefile)
if retval:
print "!!! Exiting on cvs (shell) error code:",retval
sys.exit(retval)
time.sleep(3)
if "--pretend" in myoptions:
- print "(cvs -q commit -F "+commitmessagefile+")"
+ if isCvs:
+ print "(cvs -q commit -F "+commitmessagefile+")"
+ if isSvn:
+ print "(svn -q commit -F "+commitmessagefile+")"
else:
mymsg=open(commitmessagefile,"w")
mymsg.write(commitmessage)
mymsg.write("\n (Signed Manifest commit)")
mymsg.close()
- retval=os.system("cvs -q commit -F "+commitmessagefile)
+ if isCvs:
+ retval=os.system("cvs -q commit -F "+commitmessagefile)
+ if isSvn:
+ retval=os.system("svn -q commit -F "+commitmessagefile)
if retval:
- print "!!! Exiting on cvs (shell) error code:",retval
+ print "!!! Exiting on vcs (shell) error code:",retval
sys.exit(retval)
if unlinkfile:
os.unlink(commitmessagefile)
print
- if isCvs:
- print "CVS commit complete."
+ if isCvs or isSvn:
+ print "Commit complete."
else:
- print "repoman was too scared by not seeing any familiar cvs file that he forgot to commit anything"
+ print "repoman was too scared by not seeing any familiar version control file that he forgot to commit anything"
print green("RepoMan sez:"), "\"If everyone were like you, I'd be out of business!\"\n"
sys.exit(0)