Lines 5743-5781
Link Here
|
5743 |
myc.close() |
5743 |
myc.close() |
5744 |
pos=1 |
5744 |
pos=1 |
5745 |
for line in mylines: |
5745 |
for line in mylines: |
5746 |
mydat = string.split(line) |
5746 |
if line[-1] == "\n": |
|
|
5747 |
mydat = line[:-1].split("\t") |
5748 |
else: |
5749 |
mydat = line.split("\t") |
5750 |
|
5747 |
# we do this so we can remove from non-root filesystems |
5751 |
# we do this so we can remove from non-root filesystems |
5748 |
# (use the ROOT var to allow maintenance on other partitions) |
5752 |
# (use the ROOT var to allow maintenance on other partitions) |
5749 |
try: |
5753 |
try: |
5750 |
mydat[1]=os.path.normpath(root+mydat[1][1:]) |
5754 |
#for whatever goofy reason, this can return //blah/tmp |
|
|
5755 |
#hence this fix |
5756 |
mydat[1]=os.path.normpath(root + mydat[1]).replace('//','/') |
5751 |
if mydat[0]=="obj": |
5757 |
if mydat[0]=="obj": |
5752 |
#format: type, mtime, md5sum |
5758 |
#format: type, md5sum, mtime |
5753 |
pkgfiles[string.join(mydat[1:-2]," ")]=[mydat[0], mydat[-1], mydat[-2]] |
5759 |
pkgfiles[str(mydat[1])]=[mydat[0], mydat[3], mydat[2]] |
5754 |
elif mydat[0]=="dir": |
5760 |
elif mydat[0]=="dir": |
5755 |
#format: type |
5761 |
#format: type |
5756 |
pkgfiles[string.join(mydat[1:])]=[mydat[0] ] |
5762 |
pkgfiles[str(mydat[1])]=[mydat[0]] |
5757 |
elif mydat[0]=="sym": |
5763 |
elif mydat[0] == "sym": |
5758 |
#format: type, mtime, dest |
5764 |
#format: type, mtime, dest |
5759 |
x=len(mydat)-1 |
5765 |
pkgfiles[mydat[1]] = [mydat[0], mydat[3], mydat[2]] |
5760 |
if (x >= 13) and (mydat[-1][-1]==')'): # Old/Broken symlink entry |
5766 |
elif mydat[0] in ["dev", "fif"]: |
5761 |
mydat = mydat[:-10]+[mydat[-10:][ST_MTIME][:-1]] |
|
|
5762 |
writemsg("FIXED SYMLINK LINE: %s\n" % mydat, 1) |
5763 |
x=len(mydat)-1 |
5764 |
splitter=-1 |
5765 |
while(x>=0): |
5766 |
if mydat[x]=="->": |
5767 |
splitter=x |
5768 |
break |
5769 |
x=x-1 |
5770 |
if splitter==-1: |
5771 |
return None |
5772 |
pkgfiles[string.join(mydat[1:splitter]," ")]=[mydat[0], mydat[-1], string.join(mydat[(splitter+1):-1]," ")] |
5773 |
elif mydat[0]=="dev": |
5774 |
#format: type |
5767 |
#format: type |
5775 |
pkgfiles[string.join(mydat[1:]," ")]=[mydat[0] ] |
5768 |
pkgfiles[mydat[1]]=[mydat[0]] |
5776 |
elif mydat[0]=="fif": |
|
|
5777 |
#format: type |
5778 |
pkgfiles[string.join(mydat[1:]," ")]=[mydat[0]] |
5779 |
else: |
5769 |
else: |
5780 |
return None |
5770 |
return None |
5781 |
except (KeyError,IndexError): |
5771 |
except (KeyError,IndexError): |
Lines 5871-5877
Link Here
|
5871 |
#we skip this if we're dealing with a symlink |
5861 |
#we skip this if we're dealing with a symlink |
5872 |
#because os.path.exists() will operate on the |
5862 |
#because os.path.exists() will operate on the |
5873 |
#link target rather than the link itself. |
5863 |
#link target rather than the link itself. |
5874 |
print "--- !found "+str(pkgfiles[obj][0]), obj |
5864 |
print "--- !found %s '%s'" % (str(pkgfiles[obj][0]), str(obj)) |
5875 |
continue |
5865 |
continue |
5876 |
# next line includes a tweak to protect modules from being unmerged, |
5866 |
# next line includes a tweak to protect modules from being unmerged, |
5877 |
# but we don't protect modules from being overwritten if they are |
5867 |
# but we don't protect modules from being overwritten if they are |
Lines 5879-5930
Link Here
|
5879 |
# functionality for /lib/modules. For portage-ng both capabilities |
5869 |
# functionality for /lib/modules. For portage-ng both capabilities |
5880 |
# should be able to be independently specified. |
5870 |
# should be able to be independently specified. |
5881 |
if self.isprotected(obj) or ((len(obj) > len(modprotect)) and (obj[0:len(modprotect)]==modprotect)): |
5871 |
if self.isprotected(obj) or ((len(obj) > len(modprotect)) and (obj[0:len(modprotect)]==modprotect)): |
5882 |
print "--- cfgpro "+str(pkgfiles[obj][0]), obj |
5872 |
print "--- cfgpro %s '%s'" % (str(pkgfiles[obj][0]), str(obj)) |
5883 |
continue |
5873 |
continue |
5884 |
|
5874 |
|
5885 |
lstatobj=os.lstat(obj) |
5875 |
lstatobj=os.lstat(obj) |
5886 |
lmtime=str(lstatobj[ST_MTIME]) |
5876 |
lmtime=str(lstatobj[ST_MTIME]) |
|
|
5877 |
|
5887 |
if (pkgfiles[obj][0] not in ("dir","fif","dev","sym")) and (lmtime != pkgfiles[obj][1]): |
5878 |
if (pkgfiles[obj][0] not in ("dir","fif","dev","sym")) and (lmtime != pkgfiles[obj][1]): |
5888 |
print "--- !mtime", pkgfiles[obj][0], obj |
5879 |
print "--- !mtime %s '%s'" % (str(pkgfiles[obj][0]), str(obj)) |
5889 |
continue |
5880 |
continue |
5890 |
|
5881 |
|
5891 |
if pkgfiles[obj][0]=="dir": |
5882 |
if pkgfiles[obj][0]=="dir": |
5892 |
if not os.path.isdir(obj): |
5883 |
if not os.path.isdir(obj): |
5893 |
print "--- !dir ","dir", obj |
5884 |
print "--- !dir dir '%s'" % str(obj) |
5894 |
continue |
5885 |
continue |
5895 |
mydirs.append(obj) |
5886 |
mydirs.append(obj) |
5896 |
elif pkgfiles[obj][0]=="sym": |
5887 |
elif pkgfiles[obj][0]=="sym": |
5897 |
if not os.path.islink(obj): |
5888 |
if not os.path.islink(obj): |
5898 |
print "--- !sym ","sym", obj |
5889 |
print "--- !sym sym '%s'" % str(obj) |
5899 |
continue |
5890 |
continue |
5900 |
mysyms.append(obj) |
5891 |
mysyms.append(obj) |
5901 |
elif pkgfiles[obj][0]=="obj": |
5892 |
elif pkgfiles[obj][0]=="obj": |
5902 |
if not os.path.isfile(obj): |
5893 |
if not os.path.isfile(obj): |
5903 |
print "--- !obj ","obj", obj |
5894 |
print "--- !obj obj '%s'" % str(obj) |
5904 |
continue |
5895 |
continue |
5905 |
mymd5=perform_md5(obj, calc_prelink=1) |
5896 |
mymd5=perform_md5(obj, calc_prelink=1) |
5906 |
|
5897 |
|
5907 |
# string.lower is needed because db entries used to be in upper-case. The |
5898 |
# string.lower is needed because db entries used to be in upper-case. The |
5908 |
# string.lower allows for backwards compatibility. |
5899 |
# string.lower allows for backwards compatibility. |
5909 |
if mymd5 != string.lower(pkgfiles[obj][2]): |
5900 |
if mymd5 != string.lower(pkgfiles[obj][2]): |
5910 |
print "--- !md5 ","obj", obj |
5901 |
print "--- !md5 obj '%s'" % str(obj) |
5911 |
continue |
5902 |
continue |
5912 |
try: |
5903 |
try: |
5913 |
os.unlink(obj) |
5904 |
os.unlink(obj) |
5914 |
except (OSError,IOError),e: |
5905 |
except (OSError,IOError),e: |
5915 |
pass |
5906 |
pass |
5916 |
print "<<< ","obj",obj |
5907 |
print "<<< obj '%s'" % str(obj) |
5917 |
elif pkgfiles[obj][0]=="fif": |
5908 |
elif pkgfiles[obj][0]=="fif": |
5918 |
if not S_ISFIFO(lstatobj[ST_MODE]): |
5909 |
if not S_ISFIFO(lstatobj[ST_MODE]): |
5919 |
print "--- !fif ","fif", obj |
5910 |
print "--- !fif fif '%s'" % str(obj) |
5920 |
continue |
5911 |
continue |
5921 |
try: |
5912 |
try: |
5922 |
os.unlink(obj) |
5913 |
os.unlink(obj) |
5923 |
except (OSError,IOError),e: |
5914 |
except (OSError,IOError),e: |
5924 |
pass |
5915 |
pass |
5925 |
print "<<< ","fif",obj |
5916 |
print "<<< fif '%s'" % str(obj) |
5926 |
elif pkgfiles[obj][0]=="dev": |
5917 |
elif pkgfiles[obj][0]=="dev": |
5927 |
print "--- ","dev",obj |
5918 |
print "--- dev '%s'" % str(obj) |
5928 |
|
5919 |
|
5929 |
#Now, we need to remove symlinks and directories. We'll repeatedly |
5920 |
#Now, we need to remove symlinks and directories. We'll repeatedly |
5930 |
#remove dead symlinks, then directories until we stop making progress. |
5921 |
#remove dead symlinks, then directories until we stop making progress. |
Lines 5954-5962
Link Here
|
5954 |
progress = 1 |
5945 |
progress = 1 |
5955 |
try: |
5946 |
try: |
5956 |
os.unlink(obj) |
5947 |
os.unlink(obj) |
5957 |
print "<<< ","sym",obj |
5948 |
print "<<< sym '%s'" % str(obj) |
5958 |
except (OSError,IOError),e: |
5949 |
except (OSError,IOError),e: |
5959 |
print "!!! ","sym",obj |
5950 |
print "!!! sym '%s'" %str(obj) |
5960 |
#immutable? |
5951 |
#immutable? |
5961 |
pass |
5952 |
pass |
5962 |
|
5953 |
|
Lines 5984-5995
Link Here
|
5984 |
progress = 1 |
5975 |
progress = 1 |
5985 |
try: |
5976 |
try: |
5986 |
os.rmdir(obj) |
5977 |
os.rmdir(obj) |
5987 |
print "<<< ","dir",obj |
5978 |
print "<<< dir '%s'" % str(obj) |
5988 |
except (OSError,IOError),e: |
5979 |
except (OSError,IOError),e: |
5989 |
#immutable? |
5980 |
#immutable? |
5990 |
pass |
5981 |
pass |
5991 |
#else: |
5982 |
#else: |
5992 |
# print "--- !empty","dir", obj |
5983 |
# print "--- !empty dir '%s'" % str(obj) |
5993 |
# continue |
5984 |
# continue |
5994 |
|
5985 |
|
5995 |
#step 3: if we've made progress, we'll give this another go... |
5986 |
#step 3: if we've made progress, we'll give this another go... |
Lines 5998-6008
Link Here
|
5998 |
|
5989 |
|
5999 |
#directories that aren't empty: |
5990 |
#directories that aren't empty: |
6000 |
for x in mydirs: |
5991 |
for x in mydirs: |
6001 |
print "--- !empty dir", x |
5992 |
print "--- !empty dir '%s'" % str(x) |
6002 |
|
5993 |
|
6003 |
#symlinks whose target still exists: |
5994 |
#symlinks whose target still exists: |
6004 |
for x in mysyms: |
5995 |
for x in mysyms: |
6005 |
print "--- !targe sym", x |
5996 |
print "--- !targe sym '%s'" % str(x) |
6006 |
|
5997 |
|
6007 |
#step 5: well, removal of package objects is complete, now for package *meta*-objects.... |
5998 |
#step 5: well, removal of package objects is complete, now for package *meta*-objects.... |
6008 |
|
5999 |
|
Lines 6041-6047
Link Here
|
6041 |
a=doebuild(myebuildpath,"postrm",self.myroot,self.settings,use_cache=0) |
6032 |
a=doebuild(myebuildpath,"postrm",self.myroot,self.settings,use_cache=0) |
6042 |
# XXX: Decide how to handle failures here. |
6033 |
# XXX: Decide how to handle failures here. |
6043 |
if a != 0: |
6034 |
if a != 0: |
6044 |
writemsg("!!! FAILED postrm: "+str(a)+"\n") |
6035 |
writemsg("!!! FAILED postrm: '%s'\n" % str(a)) |
6045 |
sys.exit(123) |
6036 |
sys.exit(123) |
6046 |
|
6037 |
|
6047 |
self.unlockdb() |
6038 |
self.unlockdb() |
Lines 6407-6417
Link Here
|
6407 |
# unlinking no longer necessary; "movefile" will overwrite symlinks atomically and correctly |
6398 |
# unlinking no longer necessary; "movefile" will overwrite symlinks atomically and correctly |
6408 |
mymtime=movefile(mysrc,mydest,thismtime,mystat, mysettings=self.settings) |
6399 |
mymtime=movefile(mysrc,mydest,thismtime,mystat, mysettings=self.settings) |
6409 |
if mymtime!=None: |
6400 |
if mymtime!=None: |
6410 |
print ">>>",mydest,"->",myto |
6401 |
print ">>> '%s' -> '%s'" % (str(mydest), str(myto)) |
6411 |
outfile.write("sym "+myrealdest+" -> "+myto+" "+str(mymtime)+"\n") |
6402 |
outfile.write("sym\t"+myrealdest+"\t->\t "+myto+"\t"+str(mymtime)+"\n") |
6412 |
else: |
6403 |
else: |
6413 |
print "!!! Failed to move file." |
6404 |
print "!!! Failed to move file." |
6414 |
print "!!!",mydest,"->",myto |
6405 |
print "!!! '%s' -> '%s'" (str(mydest), str(myto)) |
6415 |
sys.exit(1) |
6406 |
sys.exit(1) |
6416 |
elif S_ISDIR(mymode): |
6407 |
elif S_ISDIR(mymode): |
6417 |
# we are merging a directory |
6408 |
# we are merging a directory |
Lines 6428-6434
Link Here
|
6428 |
|
6419 |
|
6429 |
if S_ISLNK(mydmode) or S_ISDIR(mydmode): |
6420 |
if S_ISLNK(mydmode) or S_ISDIR(mydmode): |
6430 |
# a symlink to an existing directory will work for us; keep it: |
6421 |
# a symlink to an existing directory will work for us; keep it: |
6431 |
print "---",mydest+"/" |
6422 |
print "--- '%s/'" % mydest |
6432 |
else: |
6423 |
else: |
6433 |
# a non-directory and non-symlink-to-directory. Won't work for us. Move out of the way. |
6424 |
# a non-directory and non-symlink-to-directory. Won't work for us. Move out of the way. |
6434 |
if movefile(mydest,mydest+".backup", mysettings=self.settings) == None: |
6425 |
if movefile(mydest,mydest+".backup", mysettings=self.settings) == None: |
Lines 6438-6451
Link Here
|
6438 |
os.mkdir(mydest) |
6429 |
os.mkdir(mydest) |
6439 |
os.chmod(mydest,mystat[0]) |
6430 |
os.chmod(mydest,mystat[0]) |
6440 |
os.chown(mydest,mystat[4],mystat[5]) |
6431 |
os.chown(mydest,mystat[4],mystat[5]) |
6441 |
print ">>>",mydest+"/" |
6432 |
print ">>> '%s/'" % mydest |
6442 |
else: |
6433 |
else: |
6443 |
#destination doesn't exist |
6434 |
#destination doesn't exist |
6444 |
os.mkdir(mydest) |
6435 |
os.mkdir(mydest) |
6445 |
os.chmod(mydest,mystat[0]) |
6436 |
os.chmod(mydest,mystat[0]) |
6446 |
os.chown(mydest,mystat[4],mystat[5]) |
6437 |
os.chown(mydest,mystat[4],mystat[5]) |
6447 |
print ">>>",mydest+"/" |
6438 |
print ">>> '%s/'" % mydest |
6448 |
outfile.write("dir "+myrealdest+"\n") |
6439 |
outfile.write("dir\t"+myrealdest+"\n") |
6449 |
# recurse and merge this directory |
6440 |
# recurse and merge this directory |
6450 |
if self.mergeme(srcroot,destroot,outfile,secondhand,offset+x+"/",cfgfiledict,thismtime): |
6441 |
if self.mergeme(srcroot,destroot,outfile,secondhand,offset+x+"/",cfgfiledict,thismtime): |
6451 |
return 1 |
6442 |
return 1 |
Lines 6461-6467
Link Here
|
6461 |
if S_ISDIR(mydmode): |
6452 |
if S_ISDIR(mydmode): |
6462 |
# install of destination is blocked by an existing directory with the same name |
6453 |
# install of destination is blocked by an existing directory with the same name |
6463 |
moveme=0 |
6454 |
moveme=0 |
6464 |
print "!!!",mydest |
6455 |
print "!!! '%s'" % mydest |
6465 |
elif S_ISREG(mydmode): |
6456 |
elif S_ISREG(mydmode): |
6466 |
cfgprot=0 |
6457 |
cfgprot=0 |
6467 |
# install of destination is blocked by an existing regular file; |
6458 |
# install of destination is blocked by an existing regular file; |
Lines 6522-6529
Link Here
|
6522 |
zing="---" |
6513 |
zing="---" |
6523 |
if mymtime!=None: |
6514 |
if mymtime!=None: |
6524 |
zing=">>>" |
6515 |
zing=">>>" |
6525 |
outfile.write("obj "+myrealdest+" "+mymd5+" "+str(mymtime)+"\n") |
6516 |
outfile.write("obj\t"+myrealdest+"\t"+mymd5+"\t"+str(mymtime)+"\n") |
6526 |
print zing,mydest |
6517 |
print "%s '%s'" % (zing,mydest) |
6527 |
else: |
6518 |
else: |
6528 |
# we are merging a fifo or device node |
6519 |
# we are merging a fifo or device node |
6529 |
zing="!!!" |
6520 |
zing="!!!" |
Lines 6534-6543
Link Here
|
6534 |
if S_ISFIFO(mymode): |
6525 |
if S_ISFIFO(mymode): |
6535 |
# we don't record device nodes in CONTENTS, |
6526 |
# we don't record device nodes in CONTENTS, |
6536 |
# although we do merge them. |
6527 |
# although we do merge them. |
6537 |
outfile.write("fif "+myrealdest+"\n") |
6528 |
outfile.write("fif\t"+myrealdest+"\n") |
6538 |
else: |
6529 |
else: |
6539 |
sys.exit(1) |
6530 |
sys.exit(1) |
6540 |
print zing+" "+mydest |
6531 |
print "%s '%s'" % (zing, mydest) |
6541 |
|
6532 |
|
6542 |
def merge(self,mergeroot,inforoot,myroot,myebuild=None,cleanup=0): |
6533 |
def merge(self,mergeroot,inforoot,myroot,myebuild=None,cleanup=0): |
6543 |
return self.treewalk(mergeroot,myroot,inforoot,myebuild,cleanup=cleanup) |
6534 |
return self.treewalk(mergeroot,myroot,inforoot,myebuild,cleanup=cleanup) |