When we import portage as a normal user from misc scripts we often get the following screen. -------------------------------------------------------------------------------- *** You are not in the portage group. You may experience cache problems *** due to permissions preventing the creation of the on-disk cache. -------------------------------------------------------------------------------- The above must be redirected to /dev/stderr. Redirecting stderr is not always ideal and adding the current user to portage group is not ideal for simple scripts. So please consider the following patch which would allow script's to export PORTAGE_QUIET=1 before 'import portage' to keep this warning from showing up. Index: portage_data.py =================================================================== RCS file: /var/cvsroot/gentoo-src/portage/pym/portage_data.py,v retrieving revision 1.2 diff -u -b -B -w -p -r1.2 portage_data.py --- portage_data.py 18 Aug 2004 02:12:20 -0000 1.2 +++ portage_data.py 30 Aug 2004 16:58:17 -0000 @@ -74,6 +74,7 @@ except KeyError: writemsg("\n") if (uid!=0) and (portage_gid not in os.getgroups()): + if not os.environ.has_key("PORTAGE_QUIET"): writemsg("\n") writemsg(red("*** You are not in the portage group. You may experience cache problems\n")) writemsg(red("*** due to permissions preventing the creation of the on-disk cache.\n")) -------------------------------------------------------------------------------- If perhaps you would like to do this another way. Checking PORTAGE_CALLER fex I'm all open to it.
sed s/PORTAGE_QUIET/PORTAGE_SCRIPT/g <-- sounds better
poke poke.. Can you/I commit this?
Would be better as a -qqq enhancement.
-qqq ? The case for this is so that other scripts can import the portage module via python without having the writemsg() triggered. Not using the emerge interface at all. I'll attach those as examples in a min.
Created attachment 40140 [details] herds.py Exmaple which extracts people from herds from gentoo's herds.xml
Created attachment 40141 [details] metadata.py Example tool which extracts maintainer/longdescription/herd/email from a metadata.xml These two files are what allows me to have jeeves (your fav bot) display to irc !metadata <pkgname> !herd <herdname> But in the future if anybody upgrades portage on eagle without some way to supress output we would either have to reedit portage.py again or add the bot to the portage group which a bot should not really be in for security sake.
So back to the orig topic. Portage needs to be quiet for scripts. Perferable the answer the problem is not. sys.stderr=open("/dev/null","w")
Index: emerge =================================================================== --- emerge (revision 2482) +++ emerge (working copy) @@ -326,6 +326,7 @@ if ("--quiet" in myopts): update_spinner = update_quiet_spinner + os.environ["PORTAGE_QUIET"] = "1" # Always create packages if FEATURES=buildpkg # Imply --buildpkg if --buildpkgonly
r2483 has the above patch. calls from portage.py can now make use of this variable and we can now hush quite a few things up. I'll start working on an overall quiet mode for portage/emerge/ebuild.sh now
Created attachment 75564 [details, diff] quiet.patch This is what I'm thinking of doing in places to reduce the noise.
Updates http://article.gmane.org/gmane.linux.gentoo.portage.devel/1593
The portage/python parts are in. ebuild.sh itself has not been made quiet. The easy way todo that in ebuild.sh is to add a wrapper function for general non critical error msgs
Created attachment 84739 [details, diff] ebuild.sh patch hope this is what you were after. sample output: $ emerge -q gcc-config >>> Emerging (1 of 1) sys-devel/gcc-config-1.3.13-r1 to / * Switching native-compiler to x86_64-pc-linux-gnu-3.4.5 ... [ ok ] >>> No packages selected for removal by clean. >>> Auto-cleaning packages... >>> No outdated packages were found on your system. With that patch, pretty much everything that isn't critical gets suppressed.
Created attachment 84791 [details, diff] newer patch replaced eecho with vecho as it seems more appropriate and solar would have to change ~100 bashrcs ;)
this is rev 3296
This has been released in 2.1_rc1.