From 186a933c675c1cc8ac1ec075b6a6946a296a20c2 Mon Sep 17 00:00:00 2001 From: Fabian Groffen Date: Wed, 1 Nov 2006 12:02:45 +0000 Subject: [PATCH] Merged from trunk 4892:4903 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 | 6 ++++-- bin/dispatch-conf | 15 ++++++++++++--- pym/portage.py | 42 ++++++++++++++++++++++++++++++++++++++++-- 3 files changed, 56 insertions(+), 7 deletions(-) diff --git a/bin/archive-conf b/bin/archive-conf index 95e9135ed..6c8f007d1 100755 --- a/bin/archive-conf +++ b/bin/archive-conf @@ -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: diff --git a/bin/dispatch-conf b/bin/dispatch-conf index 03f8b4d5f..c5b27b728 100755 --- a/bin/dispatch-conf +++ b/bin/dispatch-conf @@ -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' diff --git a/pym/portage.py b/pym/portage.py index e95fa485c..6a822ba3d 100644 --- a/pym/portage.py +++ b/pym/portage.py @@ -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) -- 2.26.2