diff options
author | Jason Stubbs <jstubbs@gentoo.org> | 2005-12-24 09:17:34 +0000 |
---|---|---|
committer | Jason Stubbs <jstubbs@gentoo.org> | 2005-12-24 09:17:34 +0000 |
commit | c10c25b95db2ba66096f64574f41d1f25cc5e49f (patch) | |
tree | a0fa1ee18b0e746210549870d4bef63fba400bf3 | |
parent | 32e51b4db1a412cd7c24bef61769efba08935d2e (diff) | |
download | portage-c10c25b95db2ba66096f64574f41d1f25cc5e49f.tar.gz portage-c10c25b95db2ba66096f64574f41d1f25cc5e49f.tar.bz2 portage-c10c25b95db2ba66096f64574f41d1f25cc5e49f.zip |
Treat symlinks similar to regular files when unmerging and remove them if the
mtime matches rather than only removing them if the target is no longer valid.
svn path=/main/trunk/; revision=2445
-rw-r--r-- | pym/portage.py | 52 |
1 files changed, 6 insertions, 46 deletions
diff --git a/pym/portage.py b/pym/portage.py index 851dab39c..42008e857 100644 --- a/pym/portage.py +++ b/pym/portage.py @@ -5664,7 +5664,6 @@ class dblink: #process symlinks second-to-last, directories last. mydirs=[] - mysyms=[] modprotect="/lib/modules/" for obj in mykeys: obj=os.path.normpath(obj) @@ -5688,7 +5687,7 @@ class dblink: lstatobj=os.lstat(obj) lmtime=str(lstatobj[stat.ST_MTIME]) - if (pkgfiles[obj][0] not in ("dir","fif","dev","sym")) and (lmtime != pkgfiles[obj][1]): + if (pkgfiles[obj][0] not in ("dir","fif","dev")) and (lmtime != pkgfiles[obj][1]): print "--- !mtime", pkgfiles[obj][0], obj continue @@ -5701,7 +5700,11 @@ class dblink: if not os.path.islink(obj): print "--- !sym ","sym", obj continue - mysyms.append(obj) + try: + os.unlink(obj) + print "<<< ","sym",obj + except (OSError,IOError),e: + print "!!! ","sym",obj elif pkgfiles[obj][0]=="obj": if not os.path.isfile(obj): print "--- !obj ","obj", obj @@ -5730,42 +5733,12 @@ class dblink: elif pkgfiles[obj][0]=="dev": print "--- ","dev",obj - #Now, we need to remove symlinks and directories. We'll repeatedly - #remove dead symlinks, then directories until we stop making progress. - #This is how we'll clean up directories containing symlinks pointing to - #directories that are now empty. These cases will require several - #iterations through our two-stage symlink/directory cleaning loop. - - #main symlink and directory removal loop: - #progress -- are we making progress? Initialized to 1 so loop will start progress=1 while progress: #let's see if we're able to make progress this iteration... progress=0 - #step 1: remove all the dead symlinks we can... - - pos = 0 - while pos<len(mysyms): - obj=mysyms[pos] - if os.path.exists(obj): - pos += 1 - else: - #we have a dead symlink; remove it from our list, then from existence - del mysyms[pos] - #we've made progress! - progress = 1 - try: - os.unlink(obj) - print "<<< ","sym",obj - except (OSError,IOError),e: - print "!!! ","sym",obj - #immutable? - pass - - #step 2: remove all the empty directories we can... - pos = 0 while pos<len(mydirs): obj=mydirs[pos] @@ -5794,24 +5767,11 @@ class dblink: except (OSError,IOError),e: #immutable? pass - #else: - # print "--- !empty","dir", obj - # continue - - #step 3: if we've made progress, we'll give this another go... - - #step 4: otherwise, we'll print out the remaining stuff that we didn't unmerge (and rightly so!) #directories that aren't empty: for x in mydirs: print "--- !empty dir", x - #symlinks whose target still exists: - for x in mysyms: - print "--- !targe sym", x - - #step 5: well, removal of package objects is complete, now for package *meta*-objects.... - #remove self from vartree database so that our own virtual gets zapped if we're the last node db[self.myroot]["vartree"].zap(self.mycpv) |