summaryrefslogtreecommitdiffstats
path: root/pym
diff options
context:
space:
mode:
authorZac Medico <zmedico@gentoo.org>2007-11-28 03:45:40 +0000
committerZac Medico <zmedico@gentoo.org>2007-11-28 03:45:40 +0000
commit45b7bf2700534f59da469547a2d09848ed58ec2b (patch)
tree6be11dc4b5697562fc61befe77b02c00e1e13523 /pym
parenta467ad7d433e8b2309a1cecc312968479efcc3ec (diff)
downloadportage-45b7bf2700534f59da469547a2d09848ed58ec2b.tar.gz
portage-45b7bf2700534f59da469547a2d09848ed58ec2b.tar.bz2
portage-45b7bf2700534f59da469547a2d09848ed58ec2b.zip
Add a sanity check in dblink.treewalk() so that a broken ebuild
that doesn't install any files will not be able to replace a package in the same slot that really installs files. This check can be bypassed by manually unmerging the old package or by setting PORTAGE_PACKAGE_EMPTY_ABORT="0" in /etc/make.conf. svn path=/main/trunk/; revision=8720
Diffstat (limited to 'pym')
-rw-r--r--pym/portage/dbapi/vartree.py46
1 files changed, 41 insertions, 5 deletions
diff --git a/pym/portage/dbapi/vartree.py b/pym/portage/dbapi/vartree.py
index 89753f39c..29019a53b 100644
--- a/pym/portage/dbapi/vartree.py
+++ b/pym/portage/dbapi/vartree.py
@@ -1716,6 +1716,11 @@ class dblink(object):
if slot is None:
slot = ""
+ from portage.elog.messages import eerror as _eerror
+ def eerror(lines):
+ for l in lines:
+ _eerror(l, phase="preinst", key=self.settings.mycpv)
+
if slot != self.settings["SLOT"]:
writemsg("!!! WARNING: Expected SLOT='%s', got '%s'\n" % \
(self.settings["SLOT"], slot))
@@ -1781,6 +1786,42 @@ class dblink(object):
# to an infinite recursion loop.
mylinklist.append(file_path[len(srcroot):])
+ # If there are no files to merge, and an installed package in the same
+ # slot has files, it probably means that something went wrong.
+ if self.settings.get("PORTAGE_PACKAGE_EMPTY_ABORT") != "0" and \
+ not myfilelist and not mylinklist and others_in_slot:
+ installed_files = None
+ for other_dblink in others_in_slot:
+ installed_files = other_dblink.getcontents()
+ if not installed_files:
+ continue
+ from textwrap import wrap
+ wrap_width = 72
+ msg = []
+ d = (
+ self.mycpv,
+ other_dblink.mycpv
+ )
+ msg.extend(wrap(("The '%s' package will not install " + \
+ "any files, but the currently installed '%s'" + \
+ " package has the following files: ") % d, wrap_width))
+ msg.append("")
+ msg.extend(sorted(installed_files))
+ msg.append("")
+ msg.append("package %s NOT merged" % self.mycpv)
+ msg.append("")
+ msg.extend(wrap(
+ ("Manually run `emerge --unmerge =%s` " % \
+ other_dblink.mycpv) + "if you really want to " + \
+ "remove the above files. Set " + \
+ "PORTAGE_PACKAGE_EMPTY_ABORT=\"0\" in " + \
+ "/etc/make.conf if you do not want to " + \
+ "abort in cases like this.",
+ wrap_width))
+ eerror(msg)
+ if installed_files:
+ return 1
+
# Preserve old libs if they are still in use
if slot_matches and "preserve-libs" in self.settings.features:
self._preserve_libs(srcroot, destroot, myfilelist+mylinklist, counter)
@@ -1797,11 +1838,6 @@ class dblink(object):
self.settings, 0, 0, mydbapi)
prepare_build_dirs(destroot, self.settings, cleanup)
- from portage.elog.messages import eerror as _eerror
- def eerror(lines):
- for l in lines:
- _eerror(l, phase="preinst", key=self.settings.mycpv)
-
if collisions:
collision_protect = "collision-protect" in self.settings.features
msg = "This package will overwrite one or more files that" + \