diff options
-rw-r--r-- | pym/portage/dbapi/vartree.py | 108 |
1 files changed, 55 insertions, 53 deletions
diff --git a/pym/portage/dbapi/vartree.py b/pym/portage/dbapi/vartree.py index e71fc1fae..2b5e6efbd 100644 --- a/pym/portage/dbapi/vartree.py +++ b/pym/portage/dbapi/vartree.py @@ -1580,45 +1580,6 @@ class dblink(object): break 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 " - print red("*")+" as a bug for this package on http://bugs.gentoo.org" - print - print red("package "+self.cat+"/"+self.pkg+" NOT merged") - print - print "Detected file collision(s):" - print - from portage.output import colorize - for f in collisions: - print " '%s'" % colorize("INFORM", - os.path.join(destroot, f.lstrip(os.path.sep))) - print - print "Searching all installed packages for file collisions..." - print "Press Ctrl-C to Stop" - print - found_owner = False - for cpv in self.vartree.dbapi.cpv_all(): - cat, pkg = catsplit(cpv) - mylink = dblink(cat, pkg, destroot, self.settings, - vartree=self.vartree) - mycollisions = [] - for f in collisions: - if mylink.isowner(f, destroot): - mycollisions.append(f) - if mycollisions: - found_owner = True - print " * %s:" % cpv - print - for f in mycollisions: - print " '%s'" % \ - os.path.join(destroot, f.lstrip(os.path.sep)) - print - if not found_owner: - print "None of the installed packages claim the above file(s)." - print - sys.exit(1) return collisions def _security_check(self, installed_instances): @@ -1804,11 +1765,22 @@ class dblink(object): use_cache=0, tree=self.treetype, mydbapi=mydbapi, vartree=self.vartree) + def eerror(lines): + cmd = "source '%s/isolated-functions.sh' ; " % PORTAGE_BIN_PATH + for line in lines: + cmd += "eerror \"%s\" ; " % line + from portage import process + process.spawn(["bash", "-c", cmd], + env=self.settings.environ()) + if collisions: + collision_protect = "collision-protect" in self.settings.features msg = "This package will 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." + " may belong to other packages (see list below)." + if not collision_protect: + msg += " Add \"collision-protect\" to FEATURES in" + \ + " make.conf if you would like the merge to abort" + \ + " in cases like this." if self.settings.get("PORTAGE_QUIET") != "1": msg += " You can use a command such as" + \ " \\`portageq owners / <filename>\\` to identify the" + \ @@ -1828,22 +1800,52 @@ class dblink(object): " completely understood the above message." 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 ; " + if collision_protect: + msg.append("") + msg.append("package %s NOT merged" % self.settings.mycpv) + msg.append("") + msg.append("Detected file collision(s):") + msg.append("") for f in collisions: - cmd += "eerror \" '%s'\" ; " % \ - os.path.join(destroot, f.lstrip(os.path.sep)) + msg.append(" '%s'" % \ + os.path.join(destroot, f.lstrip(os.path.sep))) - from portage import process - process.spawn(["bash", "-c", cmd], - env=self.settings.environ()) + eerror(msg) + + if collision_protect: + msg = [] + msg.append("") + msg.append("Searching all installed" + \ + " packages for file collisions...") + msg.append("") + msg.append("Press Ctrl-C to Stop") + msg.append("") + eerror(msg) + + found_owner = False + for cpv in self.vartree.dbapi.cpv_all(): + cat, pkg = catsplit(cpv) + mylink = dblink(cat, pkg, destroot, self.settings, + vartree=self.vartree) + mycollisions = [] + for f in collisions: + if mylink.isowner(f, destroot): + mycollisions.append(f) + if mycollisions: + found_owner = True + msg = [] + msg.append("%s" % cpv) + for f in mycollisions: + msg.append("\t%s" % os.path.join(destroot, + f.lstrip(os.path.sep))) + eerror(msg) + if not found_owner: + eerror(["None of the installed" + \ + " packages claim the file(s)."]) + return 1 # XXX: Decide how to handle failures here. if a != os.EX_OK: |