unmerge: never unmerge outside of EROOT
authorZac Medico <zmedico@gentoo.org>
Thu, 1 Sep 2011 06:45:01 +0000 (23:45 -0700)
committerZac Medico <zmedico@gentoo.org>
Thu, 1 Sep 2011 06:45:01 +0000 (23:45 -0700)
pym/portage/dbapi/vartree.py

index 1a38d421a993bd6c78844a84f0dc76b3a8333967..0c0ed6a64b15f23977004ea9f687e9912fb7965f 100644 (file)
@@ -1980,10 +1980,11 @@ class dblink(object):
                        unmerge_desc["!mtime"] = _("!mtime")
                        unmerge_desc["!obj"] = _("!obj")
                        unmerge_desc["!sym"] = _("!sym")
+                       unmerge_desc["!prefix"] = _("!prefix")
 
                        real_root = self.settings['ROOT']
                        real_root_len = len(real_root) - 1
-                       eroot_split_len = len(self.settings["EROOT"].split(os.sep)) - 1
+                       eroot = self.settings["EROOT"]
 
                        # These files are generated by emerge, so we need to remove
                        # them when they are the only thing left in a directory.
@@ -2023,6 +2024,12 @@ class dblink(object):
 
                                file_data = pkgfiles[objkey]
                                file_type = file_data[0]
+
+                               # don't try to unmerge the prefix offset itself
+                               if len(obj) <= len(eroot) or not obj.startswith(eroot):
+                                       show_unmerge("---", unmerge_desc["!prefix"], file_type, obj)
+                                       continue
+
                                statobj = None
                                try:
                                        statobj = os.stat(obj)