@@ -, +, @@ --- pym/portage/dbapi/vartree.py | 46 +++++++++++++++++++++++++++----------------- 1 file changed, 28 insertions(+), 18 deletions(-) --- a/pym/portage/dbapi/vartree.py +++ a/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.") % \ --