From 56ca2d367ed8869141f4bc018bebdfe43667538e Mon Sep 17 00:00:00 2001 From: =?UTF-8?q?Micha=C5=82=20G=C3=B3rny?= Date: Fri, 9 Aug 2013 21:02:49 +0200 Subject: [PATCH 2/3] Accept COLLISION_IGNORE only on unowned files. It is an important QA violation if two packages install colliding files and do not block each other. At the same time, the main goal of COLLISION_IGNORE is to make FEATURES=collision-protect more friendly during python-r1 migration and with UNINSTALL_IGNORE. Both those goals are satisfied as well if COLLISION_IGNORE is applied only to unowned files, and it allows us to catch QA violations properly. --- pym/portage/dbapi/vartree.py | 46 +++++++++++++++++++++++++++----------------- 1 file changed, 28 insertions(+), 18 deletions(-) diff --git a/pym/portage/dbapi/vartree.py b/pym/portage/dbapi/vartree.py index c92a54a..33d8c95 100644 --- a/pym/portage/dbapi/vartree.py +++ b/pym/portage/dbapi/vartree.py @@ -3222,14 +3222,6 @@ class dblink(object): os = _os_merge - collision_ignore = [] - for x in portage.util.shlex_split( - self.settings.get("COLLISION_IGNORE", "")): - if os.path.isdir(os.path.join(self._eroot, x.lstrip(os.sep))): - x = normalize_path(x) - x += "/*" - collision_ignore.append(x) - # For collisions with preserved libraries, the current package # will assume ownership and the libraries will be unregistered. if self.vartree.dbapi._plib_registry is None: @@ -3330,13 +3322,7 @@ class dblink(object): isowned = True if not isowned: f_match = full_path[len(self._eroot)-1:] - stopmerge = True - for pattern in collision_ignore: - if fnmatch.fnmatch(f_match, pattern): - stopmerge = False - break - if stopmerge: - collisions.append(f) + collisions.append(f) return collisions, symlink_collisions, plib_collisions def _lstat_inode_map(self, path_iter): @@ -3951,9 +3937,33 @@ class dblink(object): abort = True msg = symlink_abort_msg % (self.settings.mycpv,) elif collision_protect: - abort = True - msg = _("Package '%s' NOT merged due to file collisions.") % \ - self.settings.mycpv + # if all files were unowned and in COLLISION_IGNORE + # let it merge + abort = bool(owners) + if not owners: + collision_ignore = [] + for x in portage.util.shlex_split( + self.settings.get("COLLISION_IGNORE", "")): + if os.path.isdir(os.path.join(self._eroot, x.lstrip(os.sep))): + x = normalize_path(x) + x += "/*" + collision_ignore.append(x) + + flat_owned_files = [i for l in owners.values() for i in l] + + for f in collisions: + if f not in flat_owned_files: + if not any([fnmatch.fnmatch(f, pattern) + for pattern in collision_ignore]): + abort = True + break + + if abort: + msg = _("Package '%s' NOT merged due to file collisions.") % \ + self.settings.mycpv + else: + msg = _("Package '%s' merged despite file collisions.") % \ + self.settings.mycpv elif protect_owned and owners: abort = True msg = _("Package '%s' NOT merged due to file collisions.") % \ -- 1.8.3.2