Index: pym/portage_util.py =================================================================== --- pym/portage_util.py (revision 2485) +++ pym/portage_util.py (working copy) @@ -6,13 +6,20 @@ import sys,string,shlex,os.path noiselimit = 0 -def writemsg(mystr,noiselevel=0): + +def writemsg(mystr,noiselevel=0,fd=None): """Prints out warning and debug messages based on the noiselimit setting""" global noiselimit + if fd is None: + fd = sys.stderr if noiselevel <= noiselimit: - sys.stderr.write(mystr) - sys.stderr.flush() + fd.write(mystr) + fd.flush() +def writemsg_stdout(mystr,noiselevel=0): + """Prints messages stdout based on the noiselimit setting""" + writemsg(mystr, noiselevel=noiselevel, fd=sys.stdout) + def grabfile(myfilename, compat_level=0, recursive=0): """This function grabs the lines in a file, normalizes whitespace and returns lines in a list; if a line begins with a #, it is ignored, as are empty lines""" Index: pym/portage.py =================================================================== --- pym/portage.py (revision 2485) +++ pym/portage.py (working copy) @@ -90,7 +90,7 @@ import portage_util from portage_util import grab_multiple, grabdict, grabdict_package, grabfile, grabfile_package, \ grabints, map_dictlist_vals, pickle_read, pickle_write, stack_dictlist, stack_dicts, stack_lists, \ - unique_array, varexpand, writedict, writeints, writemsg, getconfig, dump_traceback + unique_array, varexpand, writedict, writeints, writemsg, getconfig, dump_traceback, writemsg_stdout import portage_exception import portage_gpg import portage_locks @@ -2293,7 +2293,7 @@ print return 0 else: - print ">>> checksums "+note+" ;-)",x + writemsg_stdout(">>> checksums "+note+" ;-) %s\n" % x) return 1 @@ -2493,6 +2493,9 @@ mysettings["PV"] = mysplit[1] mysettings["PR"] = mysplit[2] + if portage_util.noiselimit < 0: + mysettings["PORTAGE_QUIET"] = "1" + if mydo != "depend": try: mysettings["INHERITED"], mysettings["RESTRICT"] = db[root][tree].dbapi.aux_get( \ @@ -5704,7 +5707,7 @@ #we skip this if we're dealing with a symlink #because os.path.exists() will operate on the #link target rather than the link itself. - print "--- !found "+str(pkgfiles[obj][0]), obj + writemsg_stdout("--- !found "+str(pkgfiles[obj][0])+ " %s\n" % obj) continue # next line includes a tweak to protect modules from being unmerged, # but we don't protect modules from being overwritten if they are @@ -5712,56 +5715,56 @@ # functionality for /lib/modules. For portage-ng both capabilities # should be able to be independently specified. if self.isprotected(obj) or ((len(obj) > len(modprotect)) and (obj[0:len(modprotect)]==modprotect)): - print "--- cfgpro "+str(pkgfiles[obj][0]), obj + writemsg_stdout("--- cfgpro %s %s\n" % (pkgfiles[obj][0], obj)) continue lstatobj=os.lstat(obj) lmtime=str(lstatobj[stat.ST_MTIME]) if (pkgfiles[obj][0] not in ("dir","fif","dev")) and (lmtime != pkgfiles[obj][1]): - print "--- !mtime", pkgfiles[obj][0], obj + writemsg_stdout("--- !mtime %s %s\n" % (pkgfiles[obj][0], obj)) continue if pkgfiles[obj][0]=="dir": if not os.path.isdir(obj): - print "--- !dir ","dir", obj + writemsg_stdout("--- !dir %s %s\n" % ("dir", obj)) continue mydirs.append(obj) elif pkgfiles[obj][0]=="sym": if not os.path.islink(obj): - print "--- !sym ","sym", obj + writemsg_stdout("--- !sym %s %s\n" % ("sym", obj)) continue try: os.unlink(obj) - print "<<< ","sym",obj + writemsg_stdout("<<< %s %s\n" % ("sym",obj)) except (OSError,IOError),e: - print "!!! ","sym",obj + writemsg_stdout("!!! %s %s\n" % ("sym",obj)) elif pkgfiles[obj][0]=="obj": if not os.path.isfile(obj): - print "--- !obj ","obj", obj + writemsg_stdout("--- !obj %s %s\n" % ("obj", obj)) continue mymd5=portage_checksum.perform_md5(obj, calc_prelink=1) # string.lower is needed because db entries used to be in upper-case. The # string.lower allows for backwards compatibility. if mymd5 != string.lower(pkgfiles[obj][2]): - print "--- !md5 ","obj", obj + writemsg_stdout("--- !md5 %s %s\n" % ("obj", obj)) continue try: os.unlink(obj) except (OSError,IOError),e: pass - print "<<< ","obj",obj + writemsg_stdout("<<< %s %s\n" % ("obj",obj)) elif pkgfiles[obj][0]=="fif": if not stat.S_ISFIFO(lstatobj[stat.ST_MODE]): - print "--- !fif ","fif", obj + writemsg_stdout("--- !fif %s %s\n" % ("fif", obj)) continue try: os.unlink(obj) except (OSError,IOError),e: pass - print "<<< ","fif",obj + writemsg_stdout("<<< %s %s\n" % ("fif",obj)) elif pkgfiles[obj][0]=="dev": - print "--- ","dev",obj + writemsg_stdout("--- %s %s\n" % ("dev",obj)) mydirs.sort() mydirs.reverse() @@ -5771,14 +5774,14 @@ if not last_non_empty.startswith(obj) and not listdir(obj): try: os.rmdir(obj) - print "<<< ","dir",obj + writemsg_stdout("<<< %s %s\n" % ("dir",obj)) last_non_empty = "" continue except (OSError,IOError),e: #immutable? pass - print "--- !empty dir", obj + writemsg_stdout("--- !empty dir %s\n" % obj) last_non_empty = obj continue @@ -5942,7 +5945,7 @@ if not os.path.exists(self.dbtmpdir): os.makedirs(self.dbtmpdir) - print ">>> Merging",self.mycpv,"to",destroot + writemsg_stdout(">>> Merging %s %s %s\n" % (self.mycpv,"to",destroot)) # run preinst script if myebuild: @@ -6025,11 +6028,11 @@ outfile.close() if (oldcontents): - print ">>> Safely unmerging already-installed instance..." + writemsg_stdout(">>> Safely unmerging already-installed instance...\n") self.dbdir = self.dbpkgdir self.unmerge(oldcontents,trimworld=0) self.dbdir = self.dbtmpdir - print ">>> original instance of package unmerged safely." + writemsg_stdout(">>> original instance of package unmerged safely.\n") # We hold both directory locks. self.dbdir = self.dbpkgdir @@ -6085,7 +6088,7 @@ global dircache if dircache.has_key(self.dbcatdir): del dircache[self.dbcatdir] - print ">>>",self.mycpv,"merged." + writemsg_stdout(">>> %s %s\n" % (self.mycpv,"merged.")) # Process ebuild logfiles elog_process(self.mycpv, self.settings) @@ -6219,7 +6222,7 @@ if stat.S_ISLNK(mydmode) or stat.S_ISDIR(mydmode): # a symlink to an existing directory will work for us; keep it: - print "---",mydest+"/" + writemsg_stdout("--- %s\n" % mydest+"/") if bsd_chflags: bsd_chflags.lchflags(mydest, dflags) else: @@ -6237,7 +6240,7 @@ bsd_chflags.lchflags(mydest, dflags) os.chmod(mydest,mystat[0]) os.chown(mydest,mystat[4],mystat[5]) - print ">>>",mydest+"/" + writemsg_stdout(">>> %s\n" % mydest+"/") else: #destination doesn't exist if selinux_enabled: @@ -6249,7 +6252,7 @@ if bsd_chflags: bsd_chflags.lchflags(mydest, bsd_chflags.lgetflags(mysrc)) os.chown(mydest,mystat[4],mystat[5]) - print ">>>",mydest+"/" + writemsg_stdout(">>> %s\n" % mydest+"/") outfile.write("dir "+myrealdest+"\n") # recurse and merge this directory if self.mergeme(srcroot,destroot,outfile,secondhand,offset+x+"/",cfgfiledict,thismtime): @@ -6266,7 +6269,7 @@ if stat.S_ISDIR(mydmode): # install of destination is blocked by an existing directory with the same name moveme=0 - print "!!!",mydest + writemsg_stdout("!!! %s\n" % mydest) elif stat.S_ISREG(mydmode) or (stat.S_ISLNK(mydmode) and os.path.exists(mydest) and stat.S_ISREG(os.stat(mydest)[stat.ST_MODE])): cfgprot=0 # install of destination is blocked by an existing regular file, @@ -6370,7 +6373,7 @@ if mymtime!=None: zing=">>>" outfile.write("obj "+myrealdest+" "+mymd5+" "+str(mymtime)+"\n") - print zing,mydest + writemsg_stdout("%s %s\n" % (zing,mydest)) else: # we are merging a fifo or device node zing="!!!" @@ -6384,7 +6387,7 @@ outfile.write("fif "+myrealdest+"\n") else: sys.exit(1) - print zing+" "+mydest + writemsg_stdout(zing+" "+mydest+"\n") def merge(self,mergeroot,inforoot,myroot,myebuild=None,cleanup=0): return self.treewalk(mergeroot,myroot,inforoot,myebuild,cleanup=cleanup) @@ -6466,7 +6469,7 @@ shutil.rmtree(tmploc+"/"+mypkg,1) os.makedirs(pkgloc) os.makedirs(infloc) - print ">>> extracting info" + writemsg_stdout(">>> extracting info\n") xptbz2.unpackinfo(infloc) # run pkg_setup early, so we can bail out early # (before extracting binaries) if there's a problem @@ -6475,7 +6478,7 @@ mysettings.configdict["pkg"]["CATEGORY"] = mycat; a=doebuild(myebuild,"setup",myroot,mysettings,tree="bintree") - print ">>> extracting",mypkg + writemsg_stdout(">>> extracting %s\n" % mypkg) notok=spawn("bzip2 -dqc -- '"+mytbz2+"' | tar xpf -",mysettings,free=1) if notok: print "!!! Error extracting",mytbz2 Index: bin/prepstrip =================================================================== --- bin/prepstrip (revision 2482) +++ bin/prepstrip (working copy) @@ -13,7 +13,11 @@ PORTAGE_STRIP_FLAGS=${PORTAGE_STRIP_FLAGS:---strip-unneeded} -banner=1 +if [ "${PORTAGE_QUIET}" == "" ]; then + banner=0 +else + banner=1 +fi save_elf_debug() { local x=$1 @@ -36,11 +40,11 @@ [ -z "${f}" ] && continue if [[ ${f} == *"current ar archive"* ]] ; then - echo " ${x:${#D}:${#x}}" + [ "${PORTAGE_QUIET}" == "" ] && echo " ${x:${#D}:${#x}}" ${STRIP} -g "${x}" fi if [[ ${f} == *"SB executable"* || ${f} == *"SB shared object"* ]] ; then - echo " ${x:${#D}:${#x}}" + [ "${PORTAGE_QUIET}" == "" ] && echo " ${x:${#D}:${#x}}" save_elf_debug "${x}" ${STRIP} ${PORTAGE_STRIP_FLAGS} "${x}" fi Index: bin/emerge =================================================================== --- bin/emerge (revision 2483) +++ bin/emerge (working copy) @@ -326,7 +326,7 @@ if ("--quiet" in myopts): update_spinner = update_quiet_spinner - os.environ["PORTAGE_QUIET"] = "1" + portage_util.noiselimit = -1 # Always create packages if FEATURES=buildpkg # Imply --buildpkg if --buildpkgonly @@ -2318,11 +2318,11 @@ numselected=numselected+1 #ok, now the last-merged package is protected, and the rest are selected if global_unmerge and not numselected: - print "\n>>> No outdated packages were found on your system.\n" + portage_util.writemsg_stdout("\n>>> No outdated packages were found on your system.\n") return 0 if not numselected: - print "\n>>>",unmerge_action+": No packages selected for removal.\n" + portage_util.writemsg_stdout("\n>>> %s\n" % unmerge_action+": No packages selected for removal.\n") return 0 for x in pkgmap.keys(): @@ -3348,6 +3348,6 @@ if portage.mtimedb.has_key("resume"): del portage.mtimedb["resume"] if portage.settings["AUTOCLEAN"] and "yes"==portage.settings["AUTOCLEAN"]: - print ">>> Auto-cleaning packages ..." + portage_util.writemsg_stdout(">>> Auto-cleaning packages ...\n") unmerge("clean", ["world"]) post_emerge() Index: bin/ebuild.sh =================================================================== --- bin/ebuild.sh (revision 2482) +++ bin/ebuild.sh (working copy) @@ -340,7 +340,7 @@ [ -z "$*" ] && die "Nothing passed to the 'unpack' command" for x in "$@"; do - echo ">>> Unpacking ${x} to ${PWD}" + [ "${PORTAGE_QUIET}" == "" ] && echo ">>> Unpacking ${x} to ${PWD}" y=${x%.*} y=${y##*.} @@ -562,19 +562,19 @@ src_test() { addpredict / if emake -j1 check -n &> /dev/null; then - echo ">>> Test phase [check]: ${CATEGORY}/${PF}" + [ "${PORTAGE_QUIET}" == "" ] && echo ">>> Test phase [check]: ${CATEGORY}/${PF}" if ! emake -j1 check; then hasq test $FEATURES && die "Make check failed. See above for details." hasq test $FEATURES || eerror "Make check failed. See above for details." fi elif emake -j1 test -n &> /dev/null; then - echo ">>> Test phase [test]: ${CATEGORY}/${PF}" + [ "${PORTAGE_QUIET}" == "" ] && echo ">>> Test phase [test]: ${CATEGORY}/${PF}" if ! emake -j1 test; then hasq test $FEATURES && die "Make test failed. See above for details." hasq test $FEATURES || eerror "Make test failed. See above for details." fi else - echo ">>> Test phase [none]: ${CATEGORY}/${PF}" + [ "${PORTAGE_QUIET}" == "" ] && echo ">>> Test phase [none]: ${CATEGORY}/${PF}" fi SANDBOX_PREDICT="${SANDBOX_PREDICT%:/}" } @@ -656,10 +656,10 @@ install -m0700 -d "${WORKDIR}" || die "Failed to create dir '${WORKDIR}'" [ -d "$WORKDIR" ] && cd "${WORKDIR}" - echo ">>> Unpacking source..." + [ "${PORTAGE_QUIET}" == "" ] && echo ">>> Unpacking source..." src_unpack touch "${PORTAGE_BUILDDIR}/.unpacked" || die "IO Failure -- Failed 'touch .unpacked' in BUILDIR" - echo ">>> Source unpacked." + [ "${PORTAGE_QUIET}" == "" ] && echo ">>> Source unpacked." cd "${PORTAGE_BUILDDIR}" [ "$(type -t post_src_unpack)" == "function" ] && post_src_unpack @@ -903,9 +903,9 @@ #some packages use an alternative to $S to build in, cause #our libtool to create problematic .la files export PWORKDIR="$WORKDIR" - echo ">>> Compiling source in ${srcdir} ..." + [ "${PORTAGE_QUIET}" == "" ] && echo ">>> Compiling source in ${srcdir} ..." src_compile - echo ">>> Source compiled." + [ "${PORTAGE_QUIET}" == "" ] && echo ">>> Source compiled." #|| abort_compile "fail" cd "${PORTAGE_BUILDDIR}" touch .compiled @@ -934,9 +934,11 @@ } dyn_package() { + local tflags="" trap "abort_package" SIGINT SIGQUIT cd "${PORTAGE_BUILDDIR}/image" - tar cpvf - ./ | bzip2 -f > ../bin.tar.bz2 || die "Failed to create tarball" + [[ -n "${PORTAGE_QUIET}" ]] || tflags="v" + tar cp${tflags}f - ./ | bzip2 -f > ../bin.tar.bz2 || die "Failed to create tarball" cd .. xpak build-info inf.xpak tbz2tool join bin.tar.bz2 inf.xpak "${PF}.tbz2" @@ -946,7 +948,7 @@ install -d "${PKGDIR}/${CATEGORY}" fi ln -sf "../All/${PF}.tbz2" "${PKGDIR}/${CATEGORY}/${PF}.tbz2" || die "Failed to create symlink in ${PKGDIR}/${CATEGORY}" - echo ">>> Done." + [ "${PORTAGE_QUIET}" == "" ] && echo ">>> Done." cd "${PORTAGE_BUILDDIR}" touch .packaged || die "Failed to 'touch .packaged' in ${PORTAGE_BUILDDIR}" trap SIGINT SIGQUIT @@ -966,9 +968,9 @@ fi if hasq test $RESTRICT; then ewarn "Skipping make test/check due to ebuild restriction." - echo ">>> Test phase [explicitly disabled]: ${CATEGORY}/${PF}" + [ "${PORTAGE_QUIET}" == "" ] && echo ">>> Test phase [explicitly disabled]: ${CATEGORY}/${PF}" elif ! hasq test $FEATURES; then - echo ">>> Test phase [not enabled]: ${CATEGORY}/${PF}" + [ "${PORTAGE_QUIET}" == "" ] && echo ">>> Test phase [not enabled]: ${CATEGORY}/${PF}" else src_test fi @@ -991,8 +993,10 @@ if [ -d "${S}" ]; then cd "${S}" fi - echo - echo ">>> Install ${PF} into ${D} category ${CATEGORY}" + if [ "${PORTAGE_QUIET}" == "" ]; then + echo + echo ">>> Install ${PF} into ${D} category ${CATEGORY}" + fi #our custom version of libtool uses $S and $D to fix #invalid paths in .la files export S D @@ -1190,8 +1194,10 @@ fi touch "${PORTAGE_BUILDDIR}/.installed" - echo ">>> Completed installing ${PF} into ${D}" - echo + if [ "${PORTAGE_QUIET}" == "" ]; then + echo ">>> Completed installing ${PF} into ${D}" + echo + fi cd ${PORTAGE_BUILDDIR} [ "$(type -t post_src_install)" == "function" ] && post_src_install trap SIGINT SIGQUIT @@ -1219,7 +1225,7 @@ set -o noglob for no_inst in ${INSTALL_MASK}; do set +o noglob - einfo "Removing ${no_inst}" + [ "${PORTAGE_QUIET}" == "" ] && einfo "Removing ${no_inst}" # normal stuff rm -Rf ${IMAGE}/${no_inst} >&/dev/null