--- orig/portage.py 2006-05-28 12:07:01.000000000 +0200 +++ portage.py 2006-05-29 00:29:45.000000000 +0200 @@ -471,7 +471,7 @@ and not msgtype.lower() in mysettings["PORTAGE_ELOG_CLASSES"].split(): continue if msgfunction not in portage_const.EBUILD_PHASES: - print "!!! can't process invalid log file: %s" % f + writemsg("!!! can't process invalid log file: %s" % f) continue if not msgfunction in mylogentries: mylogentries[msgfunction] = [] @@ -503,10 +503,10 @@ m = getattr(logmodule, "mod_"+s) m.process(mysettings, cpv, mylogentries, fulllog) except (ImportError, AttributeError), e: - print "!!! Error while importing logging modules while loading \"mod_%s\":" % s - print e + writemsg("!!! Error while importing logging modules while loading \"mod_%s\":" % s) + writemsg(e) except portage_exception.PortageException, e: - print e + writemsg(e) #parse /etc/env.d and generate /etc/profile.env @@ -1854,6 +1854,10 @@ if droppriv and not uid and portage_gid and portage_uid: keywords.update({"uid":portage_uid,"gid":portage_gid,"groups":[portage_gid],"umask":002}) + if settings["PORTAGE_QUIET"]: + print brown(" [ " + mystring + " ] ") + mystring = mystring + " > /dev/null" + if not free: free=((droppriv and "usersandbox" not in features) or \ (not droppriv and "sandbox" not in features and "usersandbox" not in features)) @@ -1887,7 +1891,7 @@ if ("mirror" in features) and ("lmirror" not in features): # lmirror should allow you to bypass mirror restrictions. # XXX: This is not a good thing, and is temporary at best. - print ">>> \"mirror\" mode desired and \"mirror\" restriction found; skipping fetch." + writemsg(">>> \"mirror\" mode desired and \"mirror\" restriction found; skipping fetch.") return 1 thirdpartymirrors = mysettings.thirdpartymirrors() @@ -1973,11 +1977,11 @@ noiselevel=-1) gotit=0 if not gotit: - print - print "!!!",mysettings["CATEGORY"]+"/"+mysettings["PF"],"has fetch restriction turned on." - print "!!! This probably means that this ebuild's files must be downloaded" - print "!!! manually. See the comments in the ebuild for more information." - print + writemsg("\n") + writemsg("!!!",mysettings["CATEGORY"]+"/"+mysettings["PF"],"has fetch restriction turned on.\n") + writemsg("!!! This probably means that this ebuild's files must be downloaded\n") + writemsg("!!! manually. See the comments in the ebuild for more information.\n") + writemsg("\n") spawn(EBUILD_SH_BINARY+" nofetch",mysettings) return 0 return 1 @@ -2076,7 +2080,7 @@ if not os.access(mysettings["DISTDIR"]+"/",os.W_OK): if not fetch_to_ro: - print "!!! No write access to %s" % mysettings["DISTDIR"]+"/" + writemsg("!!! No write access to %s" % mysettings["DISTDIR"]+"/") can_fetch=False else: if use_locks and locks_in_subdir: @@ -2131,7 +2135,7 @@ # Verify checksums at each fetch for fetchonly. verified_ok,reason = portage_checksum.verify_all(mysettings["DISTDIR"]+"/"+myfile, mydigests[myfile]) if not verified_ok: - print reason + writemsg(reason+"\n") writemsg("!!! Previously fetched file: "+str(myfile)+"\n", noiselevel=-1) writemsg("!!! Reason: "+reason[0]+"\n", noiselevel=-1) writemsg("!!! Got: %s\n!!! Expected: %s\n" % \ @@ -2256,7 +2260,7 @@ # from another mirror... verified_ok,reason = portage_checksum.verify_all(mysettings["DISTDIR"]+"/"+myfile, mydigests[myfile]) if not verified_ok: - print reason + writemsg(reason+"\n") writemsg("!!! Fetched file: "+str(myfile)+" VERIFY FAILED!\n", noiselevel=-1) writemsg("!!! Reason: "+reason[0]+"\n", @@ -2922,7 +2926,7 @@ else: os.unlink(edpath) except OSError: - print "!!! Failed reseting ebuild distdir path, " + edpath + writemsg("!!! Failed reseting ebuild distdir path, "+edpath+"\n") raise os.mkdir(edpath) apply_secpass_permissions(edpath, gid=portage_gid, mode=0775) @@ -2930,7 +2934,8 @@ for file in aalist: os.symlink(os.path.join(orig_distdir, file), os.path.join(edpath, file)) except OSError: - print "!!! Failed symlinking in '%s' to ebuild distdir" % file + writemsg("!!! Failed symlinking in '%s' to ebuild distdir" % file) + writemsg("\n") raise #initial dep checks complete; time to process main commands @@ -2973,7 +2978,7 @@ elif mydo=="qmerge": #check to ensure install was run. this *only* pops up when users forget it and are using ebuild if not os.path.exists(mysettings["PORTAGE_BUILDDIR"]+"/.installed"): - print "!!! mydo=qmerge, but install phase hasn't been ran" + writemsg("!!! mydo=qmerge, but install phase hasn't been ran \n") sys.exit(1) # qmerge is a special phase that implies noclean. if "noclean" not in mysettings.features: @@ -2993,7 +2998,7 @@ myebuild=mysettings["EBUILD"], mytree=tree, mydbapi=mydbapi, vartree=vartree, prev_mtimes=prev_mtimes) else: - print "!!! Unknown mydo:",mydo + writemsg("!!! Unknown mydo:"+mydo+"\n") sys.exit(1) # Make sure that DISTDIR is restored to it's normal value before we return! @@ -3029,8 +3034,8 @@ except SystemExit, e: raise except Exception, e: - print "!!! Stating source file failed... movefile()" - print "!!!",e + writemsg("!!! Stating source file failed... movefile()\n") + writemsg("!!!"+e+"\n") return None destexists=1 @@ -3099,9 +3104,9 @@ except SystemExit, e: raise except Exception, e: - print "!!! failed to properly create symlink:" - print "!!!",dest,"->",target - print "!!!",e + writemsg("!!! failed to properly create symlink:\n") + writemsg("!!!"+dest+"->"+target+"\n") + writemsg("!!!"+e+"\n") return None renamefailed=1 @@ -3117,8 +3122,8 @@ except Exception, e: if e[0]!=errno.EXDEV: # Some random error. - print "!!! Failed to move",src,"to",dest - print "!!!",e + writemsg("!!! Failed to move"+src+"to"+dest+"\n") + writemsg("!!!"+e+"\n") return None # Invalid cross-device-link 'bind' mounted or actually Cross-Device if renamefailed: @@ -3135,8 +3140,8 @@ except SystemExit, e: raise except Exception, e: - print '!!! copy',src,'->',dest,'failed.' - print "!!!",e + writemsg('!!! copy'+src+'->'+dest+"failed.\n") + writemsg("!!!"+e+"\n") return None else: #we don't yet handle special, so we need to fall back to /bin/mv @@ -3145,9 +3150,9 @@ else: a=commands.getstatusoutput(MOVE_BINARY+" -f "+"'"+src+"' '"+dest+"'") if a[0]!=0: - print "!!! Failed to move special file:" - print "!!! '"+src+"' to '"+dest+"'" - print "!!!",a + writemsg("!!! Failed to move special file:\n") + writemsg("!!! '"+src+"' to '"+dest+"'\n") + writemsg("!!!"+a+"\n") return None # failure try: if didcopy: @@ -3160,9 +3165,9 @@ except SystemExit, e: raise except Exception, e: - print "!!! Failed to chown/chmod/unlink in movefile()" - print "!!!",dest - print "!!!",e + writemsg("!!! Failed to chown/chmod/unlink in movefile()\n") + writemsg("!!!"+dest+"\n") + writemsg("!!!"+e+"\n") return None if newmtime: @@ -4383,14 +4388,14 @@ try: counter=long(cfile.readline()) except ValueError: - print "portage: COUNTER for",mycpv,"was corrupted; resetting to value of 0" + writemsg("portage: COUNTER for"+mycpv+"was corrupted; resetting to value of 0\n") counter=long(0) corrupted=1 cfile.close() elif os.path.exists(cdir): mys = pkgsplit(mycpv) myl = self.match(mys[0],use_cache=0) - print mys,myl + writemsg(mys+myl+"\n") if len(myl) == 1: try: # Only one package... Counter doesn't matter. @@ -4670,11 +4675,9 @@ except SystemExit, e: raise except Exception, e: - print - print "Check " + self.root+VDB_PATH+"/"+mycpv+"/PROVIDE and USE." - print "Possibly Invalid: " + str(mylines) - print "Exception: "+str(e) - print + writemsg("\nCheck "+self.root+VDB_PATH+"/"+mycpv+"/PROVIDE and USE.\n") + writemsg("Possibly Invalid: " + str(mylines) + "\n") + writemsg("Exception: "+str(e)+"\n\n") return [] def get_all_provides(self): @@ -5118,7 +5121,7 @@ try: myuris = self.aux_get(mypkg, ["SRC_URI"], mytree=mytree)[0] except (IOError,KeyError): - print red("getfetchlist():")+" aux_get() error reading "+mypkg+"; aborting." + writemsg(red("getfetchlist():")+" aux_get() error reading "+mypkg+"; aborting.\n") sys.exit(1) if useflags is None: @@ -5142,7 +5145,7 @@ mf = Manifest(pkgdir, self.mysettings["DISTDIR"]) checksums = mf.getDigests() if not checksums: - if debug: print "[empty/missing/bad digest]: "+mypkg + if debug: writemsg("[empty/missing/bad digest]: "+mypkg+"\n") return None filesdict={} if useflags is None: @@ -5307,7 +5310,7 @@ #match *all* visible *and* masked packages myval=match_from_list(mydep,self.cp_list(mykey)) else: - print "ERROR: xmatch doesn't handle",level,"query!" + writemsg("ERROR: xmatch doesn't handle"+level+"query!\n") raise KeyError if self.frozen and (level not in ["match-list","bestmatch-list"]): self.xcache[level][mydep]=myval @@ -5328,7 +5331,7 @@ cpv=catpkgsplit(mykey) if not cpv: #invalid cat/pkg-v - print "visible(): invalid cat/pkg-v:",mykey + writemsg("visible(): invalid cat/pkg-v:"+mykey+"\n") return [] mycp=cpv[0]+"/"+cpv[1] maskdict=self.mysettings.pmaskdict @@ -5338,7 +5341,7 @@ mymatches=self.xmatch("match-all",x) if mymatches is None: #error in package.mask file; print warning and continue: - print "visible(): package.mask entry \""+x+"\" is invalid, ignoring..." + writemsg("visible(): package.mask entry \""+x+"\" is invalid, ignoring...\n") continue for y in mymatches: unmask=0 @@ -5363,7 +5366,7 @@ mymatches=self.xmatch("match-list",x,mylist=newlist) if mymatches is None: #error in packages file; print warning and continue: - print "emerge: visible(): profile packages entry \""+x+"\" is invalid, ignoring..." + writemsg("emerge: visible(): profile packages entry \""+x+"\" is invalid, ignoring...\n") continue pos=0 while pos>>",mydest,"->",myto + writemsg_stdout(">>>"+mydest+"->"+myto) outfile.write("sym "+myrealdest+" -> "+myto+" "+str(mymtime)+"\n") else: - print "!!! Failed to move file." - print "!!!",mydest,"->",myto + writemsg("!!! Failed to move file.\n") + writemsg("!!!"+mydest+"->"+myto+"\n") sys.exit(1) elif stat.S_ISDIR(mymode): # we are merging a directory @@ -6470,7 +6470,7 @@ # a non-directory and non-symlink-to-directory. Won't work for us. Move out of the way. if movefile(mydest,mydest+".backup", mysettings=self.settings) is None: sys.exit(1) - print "bak",mydest,mydest+".backup" + writemsg("bak"+mydest+mydest+".backup\n") #now create our directory if self.settings.selinux_enabled(): sid = selinux.get_sid(mysrc) @@ -6524,7 +6524,7 @@ if cfgfiledict.has_key(myrealdest): if destmd5 in cfgfiledict[myrealdest]: #cycle - print "cycle" + writemsg_stdout("cycle\n") del cfgfiledict[myrealdest] cycled=1 if mymd5==destmd5: @@ -6722,14 +6722,14 @@ if vartree is None: vartree = db[myroot]["vartree"] if mytbz2[-5:]!=".tbz2": - print "!!! Not a .tbz2 file" + writemsg("!!! Not a .tbz2 file") return None mypkg=os.path.basename(mytbz2)[:-5] xptbz2=xpak.tbz2(mytbz2) pkginfo={} mycat=xptbz2.getfile("CATEGORY") if not mycat: - print "!!! CATEGORY info missing from info chunk, aborting..." + writemsg("!!! CATEGORY info missing from info chunk, aborting...") return None mycat=mycat.strip() mycatpkg=mycat+"/"+mypkg @@ -6756,7 +6756,7 @@ writemsg_stdout(">>> Extracting %s\n" % mypkg) notok=spawn("bzip2 -dqc -- '"+mytbz2+"' | tar xpf -",mysettings,free=1) if notok: - print "!!! Error Extracting",mytbz2 + writemsg("!!! Error Extracting "+mytbz2) cleanup_pkgmerge(mypkg,origdir) return None @@ -6985,8 +6985,7 @@ # Update progress above is indicated by characters written to stdout so # we print a couple new lines here to separate the progress output from # what follows. - print - print + writemsg_stdout("\n\n") #make sure our internal databases are consistent; recreate our virts and vartree do_vartree(mysettings, trees=trees)