make sure we only remove files that were previously preserved
authorMarius Mauch <genone@gentoo.org>
Tue, 4 Dec 2007 09:28:00 +0000 (09:28 -0000)
committerMarius Mauch <genone@gentoo.org>
Tue, 4 Dec 2007 09:28:00 +0000 (09:28 -0000)
svn path=/main/trunk/; revision=8837

pym/portage/dbapi/vartree.py

index 8162b9d11afa3e94f4432106e8e38928aa0a2480..ee71bb855003cc8c17c71c4524735cfe4e42c283 100644 (file)
@@ -1159,7 +1159,11 @@ class dblink(object):
                                                        break
                                                else:
                                                        unlink_list.append(f)
-                                                       f = os.readlink(f)
+                                                       # only follow symlinks if the target is also a preserved lib object
+                                                       if os.readlink(f) in plib_dict[cpv]:
+                                                               f = os.readlink(f)
+                                                       else:
+                                                               break
                                        if not os.path.islink(f) and not os.path.basename(f) in self.vartree.dbapi.libmap.get():
                                                unlink_list.append(f)
                                        for obj in unlink_list:
@@ -1168,8 +1172,8 @@ class dblink(object):
                                                                obj_type = "sym"
                                                        else:
                                                                obj_type = "obj"
-                                                       writemsg_stdout("<<< !needed   %s %s\n" % (obj_type, obj))
                                                        os.unlink(obj)
+                                                       writemsg_stdout("<<< !needed   %s %s\n" % (obj_type, obj))
                                                except OSError, e:
                                                        if e.errno == errno.ENOENT:
                                                                pass