--- /usr/lib/portage/pym/portage.py.orig 2007-01-15 19:56:09.000000000 +0100 +++ /usr/lib/portage/pym/portage.py.orig 2007-01-15 22:19:31.000000000 +0100 @@ -5905,7 +5905,6 @@ mysymlinks = filter(os.path.islink, listdir(srcroot, recursive=1, filesonly=0, followSymlinks=False)) myfilelist.extend(mysymlinks) - stopmerge=False starttime=time.time() i=0 @@ -5924,6 +5923,7 @@ vartree=self.vartree)) print green("*")+" checking "+str(len(myfilelist))+" files for package collisions" + collidingfiles = [] for f in myfilelist: nocheck = False # listdir isn't intelligent enough to exclude symlinked dirs, @@ -5946,18 +5946,79 @@ break if not isowned: print "existing file "+f+" is not owned by this package" - stopmerge=True + collidingfiles.append(f) print green("*")+" spent "+str(time.time()-starttime)+" seconds checking for file collisions" - if stopmerge: + + stopmerge = False + # The three if-clauses could technically be combined and nested, + # However, practically the indentation depth gets to deep. + if collidingfiles: + # Check for qlist from app-portage/portage-utils + # FIXME: Currently only standard location /usr/bin/qlist supported + hasqfile = os.access('/usr/bin/qfile', os.X_OK) + print print red("*")+" This package is blocked because it wants to overwrite" - print red("*")+" files belonging to other packages (see messages above)." + print red("*")+" files possibly belonging to other packages (see messages above)." 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 red("*")+" as a bug for this package on http://bugs.gentoo.org." + if not "collision-protect-ask" in self.settings.features: + stopmerge = True + print + print red("*")+" To get some interactivity add collision-protect-ask" + print red("*")+" to your FEATURES list." + if not hasqfile: + print + print red("*")+" You might want to install app-portage/portage-utils" + print red("*")+" to get the qfile utility, it finds file owners and" + print red("*")+" helps to investigate the problem." + + if collidingfiles and "collision-protect-ask" in self.settings.features: + # User asks for interactivity + answered = False + while not answered: + # FIXME: This should not clutter the terminal buffer, + # but in case of not_answered be overwritten." + print + print green("*")+" You enabled the collision-protect-ask feature." + print green("*")+" What do you want to do?" + print green("*")+" 1. Overwrite those files and continue the merge," + print green("*")+" I checked that no package is owning them" + print green("*")+" (using e.g. qfile from app-portage/portage-utils)" + print green("*")+" or I know what I am doing!" + print red("*")+" Anyway, I will file a bug as asked for above." + print green("*")+" 2. Please find out, who is owning these files, I have" + print green("*")+" qfile from app-portage/portage-utils installed." + print green("*")+" 3. Abort merge! (the same, as if you would not have" + print green("*")+" set the collision-protect-ask feature)" + print green("*")+" (1/2/3)? ", + a = sys.stdin.readline().rstrip() + if a == '1': + # continue as if without collision + answered = True + elif a == '2': + # run qlist + if not hasqfile: + # FIXME: suggestion to user needs to be given + print + print red("*")+" NO, you don't have qfile installed." + else: + print + print green("*")+"Running qfile for colliding files:" + for f in collidingfiles: + print f+':' + res = os.system('/usr/bin/qfile '+f) + if res != 0: + print " Not owned by any package." + elif a == '3': + stopmerge = True + answered = True + + if stopmerge: print print red("package "+self.cat+"/"+self.pkg+" NOT merged") print # Why is the package already merged here db-wise? Shouldn't be the case - # only unmerge if it ia new package and has no contents + # only unmerge if it is a new package and has no contents if not self.getcontents(): self.unmerge(ldpath_mtimes=prev_mtimes) self.delete()