From c10c25b95db2ba66096f64574f41d1f25cc5e49f Mon Sep 17 00:00:00 2001 From: Jason Stubbs Date: Sat, 24 Dec 2005 09:17:34 +0000 Subject: [PATCH] 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 --- pym/portage.py | 52 ++++++-------------------------------------------- 1 file 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