Merged from trunk 4892:4903
authorFabian Groffen <grobian@gentoo.org>
Wed, 1 Nov 2006 12:02:45 +0000 (12:02 -0000)
committerFabian Groffen <grobian@gentoo.org>
Wed, 1 Nov 2006 12:02:45 +0000 (12:02 -0000)
For bug #153295, make load_infodir ignore files that contain null bytes.

For bug #153282, automatically find the owner package(s) in the event of
a fatal file collision (since the collision is fatal, the performance
hit doesn't matter).

For bug #129670, skip the replace-cvs and replace-wscomments tests if
the diff exit code indicates two two binary files that differ.

For bug #116616, only run the post_process phase if necessary.

svn path=/main/branches/prefix/; revision=4905

bin/archive-conf
bin/dispatch-conf
pym/portage.py

index 95e9135ed8ac111b27116db967141e3b291a62ec..6c8f007d10756cc7ca8006e5d2c889e47c4ccd9b 100755 (executable)
@@ -93,10 +93,12 @@ def archive_conf():
         archive = os.path.join(options['archive-dir'], conf.lstrip('/'))
         if options['use-rcs'] == 'yes':
             dispatch_conf.rcs_archive(archive, conf, md5_match_hash[conf], '')
-            dispatch_conf.rcs_archive_post_process(archive)
+            if md5_match_hash[conf]:
+                dispatch_conf.rcs_archive_post_process(archive)
         else:
             dispatch_conf.file_archive(archive, conf, md5_match_hash[conf], '')
-            dispatch_conf.file_archive_post_process(archive)
+            if md5_match_hash[conf]:
+                dispatch_conf.file_archive_post_process(archive)
 
 # run
 if len(sys.argv) > 1:
index 03f8b4d5fbe9f69725e0a295021cc057f4940071..c5b27b728b040e43b0a4fd702836c844a3a58b34 100755 (executable)
@@ -139,9 +139,18 @@ class dispatch:
             else:
                 newconf = conf['new']
 
-            same_file = len(commands.getoutput (DIFF_CONTENTS   % (conf ['current'], newconf))) == 0
-            same_cvs  = len(commands.getoutput (DIFF_CVS_INTERP % (conf ['current'], newconf))) == 0
-            same_wsc  = len(commands.getoutput (DIFF_WSCOMMENTS % (conf ['current'], newconf))) == 0
+            mystatus, myoutput = commands.getstatusoutput(
+                DIFF_CONTENTS  % (conf ['current'], newconf))
+            same_file = 0 == len(myoutput)
+            if mystatus >> 8 == 2:
+                # Binary files differ
+                same_cvs = False
+                same_wsc = False
+            else:
+                same_cvs = 0 == len(commands.getoutput(
+                    DIFF_CVS_INTERP % (conf ['current'], newconf)))
+                same_wsc = 0 == len(commands.getoutput(
+                    DIFF_WSCOMMENTS % (conf ['current'], newconf)))
 
             # Do options permit?
             same_cvs = same_cvs and self.options['replace-cvs'] == 'yes'
index e95fa485c4f6973f02fc73ebe1787ab04895593a..6a822ba3d2f5de4f7863be1a8823f2cfb9211891 100644 (file)
@@ -1499,11 +1499,17 @@ class config:
                                self.configdict["pkg"]["PORT_ENV_FILE"] = infodir+"/environment"
 
                        myre = re.compile('^[A-Z]+$')
+                       null_byte = "\0"
                        for filename in listdir(infodir,filesonly=1,EmptyOnError=1):
                                if myre.match(filename):
                                        try:
-                                               mydata = string.strip(open(infodir+"/"+filename).read())
+                                               file_path = os.path.join(infodir, filename)
+                                               mydata = open(file_path).read().strip()
                                                if len(mydata) < 2048 or filename == "USE":
+                                                       if null_byte in mydata:
+                                                               writemsg("!!! Null byte found in metadata " + \
+                                                                       "file: '%s'\n" % file_path, noiselevel=-1)
+                                                               continue
                                                        if filename == "USE":
                                                                binpkg_flags = "-* " + mydata
                                                                self.configdict["pkg"][filename] = binpkg_flags
@@ -6376,6 +6382,8 @@ class dblink:
                                                dblink(self.cat, v, destroot, self.settings,
                                                        vartree=self.vartree))
 
+                       collisions = []
+
                        print green("*")+" checking "+str(len(myfilelist))+" files for package collisions"
                        for f in myfilelist:
                                nocheck = False
@@ -6398,7 +6406,8 @@ class dblink:
                                                isowned = True
                                                break
                                if not isowned:
-                                       print "existing file "+ f +" is not owned by this package"
+                                       collisions.append(f)
+                                       print "existing file "+f+" is not owned by this package"
                                        stopmerge=True
                                        if collision_ignore:
                                                if f in collision_ignore:
@@ -6423,6 +6432,35 @@ class dblink:
                                        self.unmerge(ldpath_mtimes=prev_mtimes)
                                        self.delete()
                                self.unlockdb()
+                               print
+                               print "Searching all installed packages for file collisions..."
+                               print "Press Ctrl-C to Stop"
+                               print
+                               """ Note: The isowner calls result in a stat call for *every*
+                               single installed file, since the inode numbers are used to work
+                               around the problem of ambiguous paths caused by symlinked files
+                               and/or directories.  Though it is slow, it is as accurate as
+                               possible."""
+                               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)
                        try:
                                os.chdir(mycwd)