Lines 5664-5670
Link Here
|
5664 |
|
5664 |
|
5665 |
#process symlinks second-to-last, directories last. |
5665 |
#process symlinks second-to-last, directories last. |
5666 |
mydirs=[] |
5666 |
mydirs=[] |
5667 |
mysyms=[] |
|
|
5668 |
modprotect="/lib/modules/" |
5667 |
modprotect="/lib/modules/" |
5669 |
for obj in mykeys: |
5668 |
for obj in mykeys: |
5670 |
obj=os.path.normpath(obj) |
5669 |
obj=os.path.normpath(obj) |
Lines 5688-5694
Link Here
|
5688 |
|
5687 |
|
5689 |
lstatobj=os.lstat(obj) |
5688 |
lstatobj=os.lstat(obj) |
5690 |
lmtime=str(lstatobj[stat.ST_MTIME]) |
5689 |
lmtime=str(lstatobj[stat.ST_MTIME]) |
5691 |
if (pkgfiles[obj][0] not in ("dir","fif","dev","sym")) and (lmtime != pkgfiles[obj][1]): |
5690 |
if (pkgfiles[obj][0] not in ("dir","fif","dev")) and (lmtime != pkgfiles[obj][1]): |
5692 |
print "--- !mtime", pkgfiles[obj][0], obj |
5691 |
print "--- !mtime", pkgfiles[obj][0], obj |
5693 |
continue |
5692 |
continue |
5694 |
|
5693 |
|
Lines 5701-5707
Link Here
|
5701 |
if not os.path.islink(obj): |
5700 |
if not os.path.islink(obj): |
5702 |
print "--- !sym ","sym", obj |
5701 |
print "--- !sym ","sym", obj |
5703 |
continue |
5702 |
continue |
5704 |
mysyms.append(obj) |
5703 |
try: |
|
|
5704 |
os.unlink(obj) |
5705 |
print "<<< ","sym",obj |
5706 |
except (OSError,IOError),e: |
5707 |
print "!!! ","sym",obj |
5705 |
elif pkgfiles[obj][0]=="obj": |
5708 |
elif pkgfiles[obj][0]=="obj": |
5706 |
if not os.path.isfile(obj): |
5709 |
if not os.path.isfile(obj): |
5707 |
print "--- !obj ","obj", obj |
5710 |
print "--- !obj ","obj", obj |
Lines 5730-5772
Link Here
|
5730 |
elif pkgfiles[obj][0]=="dev": |
5733 |
elif pkgfiles[obj][0]=="dev": |
5731 |
print "--- ","dev",obj |
5734 |
print "--- ","dev",obj |
5732 |
|
5735 |
|
5733 |
#Now, we need to remove symlinks and directories. We'll repeatedly |
|
|
5734 |
#remove dead symlinks, then directories until we stop making progress. |
5735 |
#This is how we'll clean up directories containing symlinks pointing to |
5736 |
#directories that are now empty. These cases will require several |
5737 |
#iterations through our two-stage symlink/directory cleaning loop. |
5738 |
|
5739 |
#main symlink and directory removal loop: |
5740 |
|
5741 |
#progress -- are we making progress? Initialized to 1 so loop will start |
5736 |
#progress -- are we making progress? Initialized to 1 so loop will start |
5742 |
progress=1 |
5737 |
progress=1 |
5743 |
while progress: |
5738 |
while progress: |
5744 |
#let's see if we're able to make progress this iteration... |
5739 |
#let's see if we're able to make progress this iteration... |
5745 |
progress=0 |
5740 |
progress=0 |
5746 |
|
5741 |
|
5747 |
#step 1: remove all the dead symlinks we can... |
|
|
5748 |
|
5749 |
pos = 0 |
5742 |
pos = 0 |
5750 |
while pos<len(mysyms): |
|
|
5751 |
obj=mysyms[pos] |
5752 |
if os.path.exists(obj): |
5753 |
pos += 1 |
5754 |
else: |
5755 |
#we have a dead symlink; remove it from our list, then from existence |
5756 |
del mysyms[pos] |
5757 |
#we've made progress! |
5758 |
progress = 1 |
5759 |
try: |
5760 |
os.unlink(obj) |
5761 |
print "<<< ","sym",obj |
5762 |
except (OSError,IOError),e: |
5763 |
print "!!! ","sym",obj |
5764 |
#immutable? |
5765 |
pass |
5766 |
|
5767 |
#step 2: remove all the empty directories we can... |
5768 |
|
5769 |
pos = 0 |
5770 |
while pos<len(mydirs): |
5743 |
while pos<len(mydirs): |
5771 |
obj=mydirs[pos] |
5744 |
obj=mydirs[pos] |
5772 |
objld=listdir(obj) |
5745 |
objld=listdir(obj) |
Lines 5794-5817
Link Here
|
5794 |
except (OSError,IOError),e: |
5767 |
except (OSError,IOError),e: |
5795 |
#immutable? |
5768 |
#immutable? |
5796 |
pass |
5769 |
pass |
5797 |
#else: |
|
|
5798 |
# print "--- !empty","dir", obj |
5799 |
# continue |
5800 |
|
5770 |
|
5801 |
#step 3: if we've made progress, we'll give this another go... |
|
|
5802 |
|
5803 |
#step 4: otherwise, we'll print out the remaining stuff that we didn't unmerge (and rightly so!) |
5804 |
|
5805 |
#directories that aren't empty: |
5771 |
#directories that aren't empty: |
5806 |
for x in mydirs: |
5772 |
for x in mydirs: |
5807 |
print "--- !empty dir", x |
5773 |
print "--- !empty dir", x |
5808 |
|
5774 |
|
5809 |
#symlinks whose target still exists: |
|
|
5810 |
for x in mysyms: |
5811 |
print "--- !targe sym", x |
5812 |
|
5813 |
#step 5: well, removal of package objects is complete, now for package *meta*-objects.... |
5814 |
|
5815 |
#remove self from vartree database so that our own virtual gets zapped if we're the last node |
5775 |
#remove self from vartree database so that our own virtual gets zapped if we're the last node |
5816 |
db[self.myroot]["vartree"].zap(self.mycpv) |
5776 |
db[self.myroot]["vartree"].zap(self.mycpv) |
5817 |
|
5777 |
|