Gentoo Websites Logo
Go to: Gentoo Home Documentation Forums Lists Bugs Planet Store Wiki Get Gentoo!
Bug 23358 - PORTAGE_DEBUG should output USE flags in use()
Summary: PORTAGE_DEBUG should output USE flags in use()
Status: RESOLVED FIXED
Alias: None
Product: Portage Development
Classification: Unclassified
Component: Core - Ebuild Support (show other bugs)
Hardware: All All
: High enhancement (vote)
Assignee: Portage team
URL:
Whiteboard:
Keywords:
Depends on:
Blocks:
 
Reported: 2003-06-24 00:43 UTC by Wout Mertens (RETIRED)
Modified: 2005-02-18 20:13 UTC (History)
1 user (show)

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


Attachments

Note You need to log in before you can comment on or make changes to this bug.
Description Wout Mertens (RETIRED) gentoo-dev 2003-06-24 00:43:29 UTC
Hi, 
 
in the xfree-4.3.0-r3 ebuild, if you didn't define USE=debug, you will get a non-fatal 
bash error about use expecting a unary argument. 
 
Here's the fix: 
 
--- xfree-4.3.0-r3.ebuild.orig  2003-06-24 09:38:32.000000000 +0200 
+++ xfree-4.3.0-r3.ebuild       2003-06-24 09:38:54.000000000 +0200 
@@ -447,7 +447,7 @@ 
                done 
        fi 
 
-       if [ use debug ] 
+       if use debug 
        then 
                sed -i 's|libidriver.a: $(SUBDIRS)|libidriver.a: all.subdirs|' \ 
                        programs/Xserver/hw/xfree86/input/Makefile 
 
 
Alternative, which seems to be used throughout, is if [ "`use debug`" ], but this is: 
- harder to type 
- slower because it starts a subshell 
- harder to read 
 
So I also propose that all the [ "`use foo`" ] statements are converted to use foo. 
I'd be happy to do it, I have cvs commit access, I just didn't want to step on your toes.
Comment 1 Seemant Kulleen (RETIRED) gentoo-dev 2003-06-27 06:32:02 UTC
this line doesn't seem to exist in -r3 any more.

as for the subshell thing, you are quite right -- I think the reason of the if [ "``"] syntax is that the use flag itself is not output to stdout during emerge.  I guess a use blah &>/dev/null syntax might solve that?
Comment 2 Martin Schlemmer (RETIRED) gentoo-dev 2003-06-30 14:14:25 UTC
Yep.  Alternatively we might do something like:

-----------------------------------------
use_debug () {
    if [ -z "$1" ]; then
        return 0
    fi

    if [ ! -z "${PORTAGE_DEBUG}" ]; then
        use $* &> /dev/null
        return $?
    else
        use $*
        return &?
    fi
}
----------------------------------

Might be a nice feature to portage, as then you could
just use:

  if use_debug foo; then .....

and it will print the use flags if you have PORTAGE_DEBUG set ...

Thoughts ?
Comment 3 Seemant Kulleen (RETIRED) gentoo-dev 2003-06-30 14:21:14 UTC
I like that, actually -- I always thought it rather silly that portage just outputs the USE flags.
Comment 4 Wout Mertens (RETIRED) gentoo-dev 2003-10-07 23:06:22 UTC
I'd like to propose a 3-phase plan for this change:1 use_debug is written,
all ebuild authors are told to use it instead of use, in the way    outlined
above2 use() is deprecated, with the function reporting an error so that
all ebuilds are   fixed3 use_debug is renamed to use and we do a sed pass
over all ebuilds.Or is this too much work?Another possibility is to make
use() silent and fix all broken ebuilds by adding USE_DEBUG=1 to the beginning...
Comment 5 Nicholas Jones (RETIRED) gentoo-dev 2003-10-08 00:33:18 UTC
use_debug is not a reasonable name to move to.
And use() works fine.
Adding more debug to it is possible, but don't you
see that when you use 'emerge --debug' ?
Comment 6 Wout Mertens (RETIRED) gentoo-dev 2003-10-08 02:01:29 UTC
Sorry about the badly formatted comment above.

Ok, I must admit that use() works fine, and there is truth in "If it isn't
broken, don't fix it".

On the other side, ebuilds now contain horrors like 'if [ "`use foo`" ]'.
This means that you cannot make use() be silent until you fix those ebuilds
to use 'if use foo'.

So the main question is: Do we dislike the fact that the use flags are echoed
to the user enough to fix it?

I vote yes.

Here's my latest proposal:
- change skel.ebuild to explain how to test for a use flag (if use foo)
- add USE_SILENT=1 to skel.ebuild
- change use so it doesn't echo when USE_SILENT is set to 1, and echo always
if USE_DEBUG=1.

Then, in a year or so, we can look at all ebuilds that don't have USE_SILENT
in them, change them to contain USE_DEBUG=1, and remove USE_SILENT from everywhere.

Seems like the least amount of work and it will give us prettier ebuilds.
Comment 7 Nicholas Jones (RETIRED) gentoo-dev 2003-12-28 22:28:31 UTC
Prettiness really shouldn't be a factor.

Supporting both sides of this coin is to allow things to
ease a few actions regarding the use of use flags in expantions.

I very much dislike [ "" ] syntax. The output isn't hurting anyone
and is only visible if it's printing on your primary terminal. Turn
logging on and you won't see it very often.

If all the instances of `use` are removed from all the ebuilds, I can
probably kill that functionality in the near future.
Comment 8 SpanKY gentoo-dev 2003-12-28 22:42:52 UTC
i sometimes use the fact it echos the flag in code ...
for example:
for disp in `use X` `use sdl` `use svga` ; do
    echo $disp
done
Comment 9 Marius Mauch (RETIRED) gentoo-dev 2004-02-04 20:20:57 UTC
we now have a first step with use (always verbose) and useq (silent), next step is to get everyone to use useq and add the debug logic to it.
Comment 10 SpanKY gentoo-dev 2005-02-18 20:13:42 UTC
use -> quiet
usev -> verbose
useq -> quiet