Bug #195527 - Unconditionally detect file collisions and log
authorZac Medico <zmedico@gentoo.org>
Fri, 12 Oct 2007 21:10:50 +0000 (21:10 -0000)
committerZac Medico <zmedico@gentoo.org>
Fri, 12 Oct 2007 21:10:50 +0000 (21:10 -0000)
them as eerror messages via elog. This will allow us to
collect more file collision data but it won't be quite as
annoying as enabling collision-protect by default would be.
(trunk r8085:8087)

svn path=/main/branches/2.1.2/; revision=8088

pym/portage.py

index e58188f7d11c6e69455c8eac325be40b46d6956d..dfd7ed0331cad87999ed4643b66254554d023e63 100644 (file)
@@ -7863,7 +7863,7 @@ class dblink:
                        self._installed_instance = max_dblnk
 
                # check for package collisions
-               if "collision-protect" in self.settings.features:
+               if True:
                        collision_ignore = set([normalize_path(myignore) for myignore in \
                                self.settings.get("COLLISION_IGNORE", "").split()])
                        myfilelist = listdir(srcroot, recursive=1, filesonly=1, followSymlinks=False)
@@ -7938,7 +7938,6 @@ class dblink:
                                                isowned = True
                                                break
                                if not isowned:
-                                       collisions.append(f)
                                        stopmerge=True
                                        if collision_ignore:
                                                if f in collision_ignore:
@@ -7948,8 +7947,9 @@ class dblink:
                                                                if f.startswith(myignore + os.path.sep):
                                                                        stopmerge = False
                                                                        break
-                       #print green("*")+" spent "+str(time.time()-starttime)+" seconds checking for file collisions"
-                       if stopmerge:
+                                       if stopmerge:
+                                               collisions.append(f)
+                       if stopmerge and "collision-protect" in self.settings.features:
                                print red("*")+" This package is blocked because it wants to overwrite"
                                print red("*")+" files belonging to other packages (see list below)."
                                print red("*")+" If you have no clue what this is all about report it "
@@ -8023,6 +8023,39 @@ class dblink:
                        use_cache=0, tree=self.treetype, mydbapi=mydbapi,
                        vartree=self.vartree)
 
+               if collisions:
+                       msg = "This package wants to overwrite one or more files that" + \
+                       " may belong to other packages (see list below)." + \
+                       " Add \"collision-protect\" to FEATURES in make.conf" + \
+                       " if you would like the merge to abort in cases like this." + \
+                       " If you have determined that one or more of the files" + \
+                       " actually belong to another installed package then" + \
+                       " go to http://bugs.gentoo.org and report it as a bug." + \
+                       " Be sure to identify both this package and the other" + \
+                       " installed package in the bug report. Use a command such as " + \
+                       " \\`equery belongs <filename>\\` to identify the installed" + \
+                       " package that owns a file. Do NOT file a bug without" + \
+                       " reporting exactly which two packages install the same file(s)."
+
+                       self.settings["EBUILD_PHASE"] = "preinst"
+                       cmd = "source '%s/isolated-functions.sh' ; " % PORTAGE_BIN_PATH
+                       from textwrap import wrap
+                       msg = wrap(msg, 70)
+                       for line in msg:
+                               cmd += "eerror \"%s\" ; " % line
+                       cmd += "eerror ; "
+                       cmd += "eerror \"Detected file collision(s):\" ; "
+                       cmd += "eerror ; "
+
+                       from output import colorize
+                       for f in collisions:
+                               cmd += "eerror \"     '%s'\" ; " % colorize("INFORM",
+                                       os.path.join(destroot, f.lstrip(os.path.sep)))
+
+                       portage_exec.spawn(["bash", "-c", cmd],
+                               env=self.settings.environ())
+                       elog_process(self.settings.mycpv, self.settings)
+
                # XXX: Decide how to handle failures here.
                if a != os.EX_OK:
                        writemsg("!!! FAILED preinst: "+str(a)+"\n", noiselevel=-1)