--- portage.py.org 2003-09-09 02:05:08.000000000 +0200 +++ portage.py 2003-09-14 16:11:50.000000000 +0200 @@ -2750,6 +2750,23 @@ mypos=mypos+1 return deplist +def fixdbentries(old_value, new_value, dbdir): + """python replacement for the fixdbentries script, replaces old_value + with new_value for package names in files in dbdir.""" + for myfile in [f for f in os.listdir(dbdir) if not f == "CONTENTS"]: + f = open(dbdir+"/"+myfile, "r") + mycontent = f.read() + f.close() + if not mycontent.count(old_value): + continue + mycontent = re.sub(old_value+"$", new_value, mycontent) + mycontent = re.sub(old_value+"(\s)", new_value+"\1", mycontent) + mycontent = re.sub(old_value+"(-[^a-zA-Z])", new_value+"\1", mycontent) + mycontent = re.sub(old_value+"([^a-zA-Z0-9-])", new_value+"\1", mycontent) + f = open(dbdir+"/"+myfile, "w") + f.write(mycontent) + f.close() + class packagetree: def __init__(self,virtual,clone=None): if clone: @@ -3174,11 +3191,12 @@ catfile.write(mynewcat+"\n") catfile.close() - mycmd='/usr/lib/portage/bin/fixdbentries' - mycmd=mycmd+' "'+origcp+'" ' - mycmd=mycmd+' "'+newcp+'" ' - mycmd=mycmd+' "'+self.root+"var/db/pkg/"+'" ' - spawn(mycmd,free=1) + fixdbentries(origcp, newcp, self.root+"var/db/pkg/") + #mycmd='/usr/lib/portage/bin/fixdbentries' + #mycmd=mycmd+' "'+origcp+'" ' + #mycmd=mycmd+' "'+newcp+'" ' + #mycmd=mycmd+' "'+self.root+"var/db/pkg/"+'" ' + #spawn(mycmd,free=1) def cp_list(self,mycp): mysplit=mycp.split("/") @@ -4007,11 +4025,12 @@ mytbz2=xpak.tbz2(tbz2path) mytbz2.decompose(mytmpdir, cleanup=1) - mycmd='/usr/lib/portage/bin/fixdbentries' - mycmd=mycmd+' "'+origcp+'" ' - mycmd=mycmd+' "'+newcp+'" ' - mycmd=mycmd+' "'+mytmpdir+'" ' - spawn(mycmd,free=1) + fixdbentries(origcp, newcp, mytmpdir) + #mycmd='/usr/lib/portage/bin/fixdbentries' + #mycmd=mycmd+' "'+origcp+'" ' + #mycmd=mycmd+' "'+newcp+'" ' + #mycmd=mycmd+' "'+mytmpdir+'" ' + #spawn(mycmd,free=1) catfile=open(mytmpdir+"/CATEGORY", "w") catfile.write(mynewcat+"\n") @@ -4046,11 +4065,12 @@ mylist=string.split(mylist) if mylist[0] != "move": continue - mycmd='/usr/lib/portage/bin/fixdbentries' - mycmd=mycmd+' "'+mylist[1]+'" ' - mycmd=mycmd+' "'+mylist[2]+'" ' - mycmd=mycmd+' "'+mytmpdir+'" ' - spawn(mycmd,free=1) + fixdbentries(mylist[1], mylist[2], mytmpdir) + #mycmd='/usr/lib/portage/bin/fixdbentries' + #mycmd=mycmd+' "'+mylist[1]+'" ' + #mycmd=mycmd+' "'+mylist[2]+'" ' + #mycmd=mycmd+' "'+mytmpdir+'" ' + #spawn(mycmd,free=1) mytbz2.recompose(mytmpdir,cleanup=1) return 1