Gentoo Websites Logo
Go to: Gentoo Home Documentation Forums Lists Bugs Planet Store Wiki Get Gentoo!
Bug 62273 - [PATCH] PORTAGE_QUIET= (suppress screen output for scripts)
Summary: [PATCH] PORTAGE_QUIET= (suppress screen output for scripts)
Status: RESOLVED FIXED
Alias: None
Product: Portage Development
Classification: Unclassified
Component: Core (show other bugs)
Hardware: All All
: High minor (vote)
Assignee: Portage team
URL:
Whiteboard:
Keywords: InVCS
Depends on:
Blocks: 115839
  Show dependency tree
 
Reported: 2004-08-30 10:19 UTC by solar (RETIRED)
Modified: 2006-05-13 15:27 UTC (History)
0 users

See Also:
Package list:
Runtime testing required: ---


Attachments
herds.py (herds.py,562 bytes, text/plain)
2004-09-21 18:13 UTC, solar (RETIRED)
Details
metadata.py (metadata.py,2.75 KB, text/plain)
2004-09-21 18:20 UTC, solar (RETIRED)
Details
quiet.patch (quiet.patch,1.89 KB, patch)
2005-12-26 12:31 UTC, solar (RETIRED)
Details | Diff
ebuild.sh patch (portage_quiet.patch,27.26 KB, patch)
2006-04-15 14:48 UTC, Simon Stelling (RETIRED)
Details | Diff
newer patch (portage_quiet.patch,27.26 KB, patch)
2006-04-16 12:25 UTC, Simon Stelling (RETIRED)
Details | Diff

Note You need to log in before you can comment on or make changes to this bug.
Description solar (RETIRED) gentoo-dev 2004-08-30 10:19:02 UTC
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.
Comment 1 solar (RETIRED) gentoo-dev 2004-09-08 23:24:22 UTC
sed s/PORTAGE_QUIET/PORTAGE_SCRIPT/g <-- sounds better
Comment 2 solar (RETIRED) gentoo-dev 2004-09-10 07:04:25 UTC
poke poke.. Can you/I commit this?
Comment 3 Nicholas Jones (RETIRED) gentoo-dev 2004-09-21 17:54:36 UTC
Would be better as a -qqq enhancement.
Comment 4 solar (RETIRED) gentoo-dev 2004-09-21 18:10:54 UTC
-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.
Comment 5 solar (RETIRED) gentoo-dev 2004-09-21 18:13:14 UTC
Created attachment 40140 [details]
herds.py

Exmaple which extracts people from herds from gentoo's herds.xml
Comment 6 solar (RETIRED) gentoo-dev 2004-09-21 18:20:33 UTC
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.
Comment 7 solar (RETIRED) gentoo-dev 2005-11-11 15:40:47 UTC
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")
Comment 8 solar (RETIRED) gentoo-dev 2005-12-26 12:08:31 UTC
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
Comment 9 solar (RETIRED) gentoo-dev 2005-12-26 12:11:27 UTC
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
Comment 10 solar (RETIRED) gentoo-dev 2005-12-26 12:31:13 UTC
Created attachment 75564 [details, diff]
quiet.patch

This is what I'm thinking of doing in places to reduce the noise.
Comment 11 solar (RETIRED) gentoo-dev 2005-12-27 15:49:26 UTC
Updates
http://article.gmane.org/gmane.linux.gentoo.portage.devel/1593
Comment 12 solar (RETIRED) gentoo-dev 2006-01-29 08:06:13 UTC
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
Comment 13 Simon Stelling (RETIRED) gentoo-dev 2006-04-15 14:48:16 UTC
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.
Comment 14 Simon Stelling (RETIRED) gentoo-dev 2006-04-16 12:25:30 UTC
Created attachment 84791 [details, diff]
newer patch

replaced eecho with vecho as it seems more appropriate and solar would have to change ~100 bashrcs ;)
Comment 15 Simon Stelling (RETIRED) gentoo-dev 2006-05-01 14:16:15 UTC
this is rev 3296
Comment 16 Zac Medico gentoo-dev 2006-05-13 15:27:32 UTC
This has been released in 2.1_rc1.