Gentoo Forums
Gentoo Forums
Gentoo Forums
Quick Search: in
howto: reorder your /etc/make.conf USE flags alphabetically
View unanswered posts
View posts from last 24 hours

Goto page 1, 2  Next  
Reply to topic    Gentoo Forums Forum Index Documentation, Tips & Tricks
View previous topic :: View next topic  
Author Message
libero
Tux's lil' helper
Tux's lil' helper


Joined: 26 Mar 2004
Posts: 86
Location: Tokyo

PostPosted: Thu Dec 01, 2005 2:15 am    Post subject: howto: reorder your /etc/make.conf USE flags alphabetically Reply with quote

hi

Objective: USE flags get cluttered, hard to read, jumbled order. Here is a way to clean them up. Descriptions in /usr/portage/profiles/use.desc and on the gentoo docs are alphabetized, so it's handy to scan and examine them.

First the code:
Code:

user@system% cat /etc/make.conf | grep "USE=" | grep -v "^#" | awk '{ for (i = NF; i >= 2; i-- )  print $i}' | grep -v '^"$' | sort | xargs echo

New [updated], the slightly improved code:
Code:

user@system% cat /etc/make.conf | grep "USE=" | grep -v "^#" | awk '{ for (i = (NF -1); i >= 2; i-- )  print $i}' | sort | xargs echo


Notes:
Depending on where you put your ["] (quotation) marks around all the flags, you may need to tweak or hand-edit something. In my case, the line looks like:
Code:
USE=" some flag terms "

so that the first quotation is contiguous with USE= and the last one is separated by whitespace.

If you are worried that something is redundant, you could add a |uniq | command before the "xargs echo" but I prefer to view any redundancies just in case they disagree in direction (+ vs. -)

The second grep eliminates any commented-out lines, so you're sure to be only working with your real "USE" flags (on an uncommented line).

The output is just the ordered USE flags themselves. You'll need to cut-and-paste or otherwise insert them into /etc/make.conf after [USE="] and followed by a final [ " ]

[update] Added because you can take the final [ " ] quote mark out just by setting the awk params one item shorter, since we always know the order of the awk items.

My USE flags going in:
Code:

user@system% cat /etc/make.conf | grep "USE="                      1:50AM ~
USE=" -3dfx -3dnow X acl -acpi -aim -arts -apache2  berkdb -bluetooth canna cjk -doc dbm -divx4linux -dv -dvd -dvdr  -emacs -alsa expat -flac flatfile freewnn ftp -gb  gif iconv  -icq -ieee1394 -ipv6  java  javascript  jpeg kde -ldap -leim   libwww -motif mime  mozilla -mp3  mpeg mysql ncurses  nls -oci8  opengl -pcmcia  pdflib perl php png qt bindist python rage128 simplexml spl  tcltk tiff tokenizer truetype unicode -vcd -videos -vorbis -wifi  xml2 xsl -xvid  yahoo ssl -afs xv -msn -mule -oscar -matrox  -pda -gnome -gtk -cdr x86 "
# USE="X -gtk -gnome qt kde -dvd -alsa -cdr -emacs"


and then I run the command:

Code:

user@system% cat /etc/make.conf | grep "USE=" | grep -v "^#" | awk '{ for (i = NF; i >= 2; i-- )  print $i}' | grep -v '^"$' | sort | xargs echo
-3dfx -3dnow acl -acpi -afs -aim -alsa -apache2 -arts berkdb bindist -bluetooth canna -cdr cjk dbm -divx4linux -doc -dv -dvd -dvdr -emacs expat -flac flatfile freewnn ftp -gb gif -gnome -gtk iconv -icq -ieee1394 -ipv6 java javascript jpeg kde -ldap -leim libwww -matrox mime -motif mozilla -mp3 mpeg -msn -mule mysql ncurses nls -oci8 opengl -oscar -pcmcia -pda pdflib perl php png python qt rage128 simplexml spl ssl tcltk tiff tokenizer truetype unicode -vcd -videos -vorbis -wifi X x86 xml2 xsl xv -xvid yahoo


have fun

Leo


Last edited by libero on Sat Dec 03, 2005 2:26 pm; edited 1 time in total
Back to top
View user's profile Send private message
Aries-Belgium
l33t
l33t


Joined: 08 Jul 2005
Posts: 730
Location: Willebroek, Belgium

PostPosted: Thu Dec 01, 2005 2:28 am    Post subject: Reply with quote

Thanks, just what I was looking for. Now I don't have to check eveytime if they are still in the good order.
Back to top
View user's profile Send private message
Cintra
Advocate
Advocate


Joined: 03 Apr 2004
Posts: 2111
Location: Norway

PostPosted: Sun Dec 04, 2005 11:52 am    Post subject: Reply with quote

I ran ufed-0.40 instead
..it got rid of quite a few unnecessary flags, and left me with
Code:

USE="a52 aac cddb cdparanoia dvd dvdr dvdread hddtemp javascript live
     lm_sensors mmx network nptl ppds real rtc sse sse2 theora win32codecs
     -avi -fortran -gnome -gtk"

;-)
_________________
"I am not bound to please thee with my answers" W.S.
Back to top
View user's profile Send private message
rojaro
l33t
l33t


Joined: 06 May 2002
Posts: 732

PostPosted: Mon Dec 05, 2005 6:46 pm    Post subject: Reply with quote

Hi there,

nice idea, but here my little improved version with which you dont have to care about quotes and formatting :)
Code:
# echo $(source /etc/make.conf && echo $USE | awk '{ for(i=NF;i>0;i--) print $i }' | sort)

- rojaro -
_________________
A mathematician is a machine for turning coffee into theorems. ~ Alfred Renyi (*1921 - †1970)
Back to top
View user's profile Send private message
thdrcat
n00b
n00b


Joined: 30 Mar 2004
Posts: 43

PostPosted: Tue Dec 06, 2005 12:51 am    Post subject: Reply with quote

thanks!

alternitivly you could emerge the program "ufed"

Ufed offers a terminal psuedo gui to make changes to your use flags.

What I use it for a lot is to order use flags and remove extra use flags. i.e. it is in my make.conf AND is on by default.
Back to top
View user's profile Send private message
libero
Tux's lil' helper
Tux's lil' helper


Joined: 26 Mar 2004
Posts: 86
Location: Tokyo

PostPosted: Tue Dec 06, 2005 3:22 am    Post subject: Reply with quote

hi

I realize they are only opinions, just like yours and mine, but the opinions of ufed on this site:
http://www.gentoo-portage.com/app-portage/ufed
were less than positive.

Maybe it is because ufed only considers the packages you have currently installed, and it's unable to consider the future packages you plan to install, for which you have already selected some USE flags.

I agree ufed will probably be useful for some people, but for others who think about future USE flags, there are these cool tools ;-)

L
Back to top
View user's profile Send private message
revertex
l33t
l33t


Joined: 23 Apr 2003
Posts: 806

PostPosted: Tue Dec 06, 2005 10:07 am    Post subject: Reply with quote

Sweet!
My useflags are almost alfabetically orderer but files under /etc/portage/package.whatever is a big mess.

Ufed is nice, but not so usefull until it not handle local use flags.
Back to top
View user's profile Send private message
Cintra
Advocate
Advocate


Joined: 03 Apr 2004
Posts: 2111
Location: Norway

PostPosted: Tue Dec 06, 2005 10:13 am    Post subject: Reply with quote

libero wrote:
hi

I realize they are only opinions, just like yours and mine, but the opinions of ufed on this site:
http://www.gentoo-portage.com/app-portage/ufed
were less than positive. L

There have been versions with bugs, and I would certainly not use it without taking precautions based on earlier experience..
;-)
_________________
"I am not bound to please thee with my answers" W.S.
Back to top
View user's profile Send private message
Arno
Tux's lil' helper
Tux's lil' helper


Joined: 19 Oct 2002
Posts: 126
Location: France

PostPosted: Wed Dec 07, 2005 12:36 am    Post subject: Reply with quote

My /etc/make.conf USE flags start with USE="-* , which remove all flags set by default. I then don't need to a have lenghty list of - flags.
For instance:
Code:
USE="-* X 3dnow alsa ..."

I then add additional per package flags in /etc/portage/package.use.
Back to top
View user's profile Send private message
destr0yr
Tux's lil' helper
Tux's lil' helper


Joined: 29 Nov 2003
Posts: 80
Location: Kelowna, BC.

PostPosted: Wed Dec 07, 2005 7:00 am    Post subject: Reply with quote

Code:

* app-portage/flagedit
     Available versions:  0.0.2 [M]0.0.3 [M]0.0.4 0.0.5
     Installed:           0.0.5
     Homepage:            http://damz.net/flagedit/
     Description:         CLI use flags and keyword editor, for system wide or /etc/portage files

emerge flagedit

Great little app. ufed rocks too.
Back to top
View user's profile Send private message
libero
Tux's lil' helper
Tux's lil' helper


Joined: 26 Mar 2004
Posts: 86
Location: Tokyo

PostPosted: Mon Jan 23, 2006 4:57 am    Post subject: Reply with quote

aha

another twist. According to the Gentoo Newsletter, of Jan 16, 2006, they are beginning to migrate away from the "auto-use" feature, in favor of manual control of USE flags. An excerpt from the newsletter:

Quote:

The change will happen in one of the next Portage 2.1 releases - it is in the tree and marked ~ARCH on almost all arches. "Stable" users will stay unaffected for some time since Portage 2.0.x will not change its behaviour, but upgrades can and will change USE flags. If you just upgraded to a portage 2.1 release you will probably want to look at the "emerge -DuvpN world" output and add flags that you want to keep enabled to make.conf if they show up as "-foo*".


And a link to the full newsletter page (English): http://www.gentoo.org/news/en/gwn/20060116-newsletter.xml

So more of the USE flag management tips in this thread will be of value to more of us.
To summarize:
-an awk-based flag handling script
-app-portage/flagedit
-app-portage/ufed

Leo
Back to top
View user's profile Send private message
ilm
Guru
Guru


Joined: 29 Jun 2006
Posts: 310
Location: Brisbane, Australia

PostPosted: Sat Sep 30, 2006 8:17 am    Post subject: Reply with quote

I just found this bit of code, but I've got a couple of problems/questions with it:

1) When I run it, it only outputs the interior flags of the first line, i.e. it outputs:
Quote:
a52 aac aalib acpi audiofile bash-completion bcmath bidi

whilst the first line of USE flags in make.conf is:
Quote:
Xaw3d a52 aac aalib acpi audiofile bash-completion bcmath bidi bindist


2) How can I set this up to use for an alias or shell script? Whenever I do something like that, it thinks the output is a series of commands and tries to run them.

Otherwise, thanks for this!!! My USE flags were getting a bit out of control (I'm slowly pruning them down as I work out what they do and what I need).
Back to top
View user's profile Send private message
Akkara
Administrator
Administrator


Joined: 28 Mar 2006
Posts: 6631
Location: &akkara

PostPosted: Sat Sep 30, 2006 10:33 am    Post subject: Reply with quote

It appears to be sensitive to whether there is space between the double-quotes and the use flags.

Here's a somewhat shorter script that I think avoids that problem:
Code:
sed -n 's/^USE=" *\(.*\) *"/\1/p' </etc/make.conf | tr ' ' '\n' | sort | xargs echo
Back to top
View user's profile Send private message
ilm
Guru
Guru


Joined: 29 Jun 2006
Posts: 310
Location: Brisbane, Australia

PostPosted: Sat Sep 30, 2006 2:26 pm    Post subject: Reply with quote

Akkara: I can't seem to get your script to do anything.

I find that the problem with these scripts is that they work only if USE is defined on the one line, but after running the first one, it got split up onto multiple lines, so it will no longer work.

Edit: Rojaro's script works with the entire USE variable, but only outputs the result to the terminal, not back to /etc/make.conf
Back to top
View user's profile Send private message
ppurka
Advocate
Advocate


Joined: 26 Dec 2004
Posts: 3256

PostPosted: Sat Sep 30, 2006 4:03 pm    Post subject: Reply with quote

ilm wrote:
Edit: Rojaro's script works with the entire USE variable, but only outputs the result to the terminal, not back to /etc/make.conf
Yes, it works. But you just need to copy and paste :roll:
Back to top
View user's profile Send private message
ilm
Guru
Guru


Joined: 29 Jun 2006
Posts: 310
Location: Brisbane, Australia

PostPosted: Sun Oct 01, 2006 3:25 am    Post subject: Reply with quote

Well, Libero's script (the second one at least) changed the make.conf file ordering of the USE flags (without me knowing about it...), so I was wondering what would be required to do the same with Rojaro's.
Back to top
View user's profile Send private message
ppurka
Advocate
Advocate


Joined: 26 Dec 2004
Posts: 3256

PostPosted: Sun Oct 01, 2006 4:50 am    Post subject: Reply with quote

ilm wrote:
Well, Libero's script (the second one at least) changed the make.conf file ordering of the USE flags (without me knowing about it...), so I was wondering what would be required to do the same with Rojaro's.
You sure? I don't see any of the commands in the original post writing back to /etc/make.conf
Back to top
View user's profile Send private message
ilm
Guru
Guru


Joined: 29 Jun 2006
Posts: 310
Location: Brisbane, Australia

PostPosted: Sun Oct 01, 2006 5:53 am    Post subject: Reply with quote

ppurka wrote:
You sure? I don't see any of the commands in the original post writing back to /etc/make.conf


Neither did I, and that's what confused me for a bit as well :wink:. However, I know that I originally had all my USE flags in one big long line, and after running that set of commands it was on multiple lines, and some of the ordering had changed (e.g. placing Xaw3d up the front, all the - flags at the end).
Back to top
View user's profile Send private message
ppurka
Advocate
Advocate


Joined: 26 Dec 2004
Posts: 3256

PostPosted: Sun Oct 01, 2006 5:58 am    Post subject: Reply with quote

ilm wrote:
ppurka wrote:
You sure? I don't see any of the commands in the original post writing back to /etc/make.conf


Neither did I, and that's what confused me for a bit as well :wink:. However, I know that I originally had all my USE flags in one big long line, and after running that set of commands it was on multiple lines, and some of the ordering had changed (e.g. placing Xaw3d up the front, all the - flags at the end).
I think you ran ufed at some point, which rearranged all the USE flags. The scripts in the original post will not rearrange the -flags to the end.
Back to top
View user's profile Send private message
ilm
Guru
Guru


Joined: 29 Jun 2006
Posts: 310
Location: Brisbane, Australia

PostPosted: Sun Oct 01, 2006 6:01 am    Post subject: Reply with quote

Ahhh, yes, that must have been it :wink:
Back to top
View user's profile Send private message
Non_E
Apprentice
Apprentice


Joined: 17 Jan 2006
Posts: 160
Location: Czech Republic

PostPosted: Sun Oct 01, 2006 8:26 pm    Post subject: Lost use flags Reply with quote

Something probably went wrong:
Code:
radek@linwood ~ $ cat /etc/make.conf | grep "USE=" | grep -v "^#" | awk '{ for (i = (NF -1); i >= 2; i-- )  print $i}' | sort | xargs echo |  wc -w
75
radek@linwood ~ $ cat /etc/make.conf | grep "USE=" | wc -w
77


Rojaro's script returns 77 use flags which is the same as in original. I suggest using his script.
Back to top
View user's profile Send private message
GimmeFuel
n00b
n00b


Joined: 13 Mar 2003
Posts: 14
Location: Bellingham, WA, USA

PostPosted: Mon Oct 02, 2006 3:58 am    Post subject: Reply with quote

I like it much better if you pass -d to sort. This causes sort to ignore to - in front of disabled flags, and puts them in true dictionary order.

Code:
~ # cat /etc/make.conf | grep "USE=" | grep -v "^#" | awk '{ for (i = (NF -1); i >= 2; i-- )  print $i}' | sort | xargs echo
-apache -apm -arts -berkdb -curl -eds -emboss -esd -fam -firefox -gcj -gdbm -gnome -gstreamer -ipv6 -kde -ldap -motif -nls -oss -qt -qt3 -qt4 X aac aalib acpi alsa apache2 audacious bash-completion bzip2 cdr crypt cups dvd dvdr dvdread encode fbcon ffmpeg flac foomaticdb gimpprint glut gmp gtk gtk2 imagemagick java joystick libcaca logrotate matroska mikmod mmx mmxext mozilla mplayer msn mysql nptl nptlonly nsplugin offensive ogg oggvorbis pcre php pic ppds real ruby samba seamonkey session silc speex sqlite sse startup-notification tcltk theora tiff usb vorbis win32codecs x264 xslt

~ # cat /etc/make.conf | grep "USE=" | grep -v "^#" | awk '{ for (i = (NF -1); i >= 2; i-- )  print $i}' | sort -d | xargs echo
X aac aalib acpi alsa -apache apache2 -apm -arts audacious bash-completion -berkdb bzip2 cdr crypt cups -curl dvd dvdr dvdread -eds -emboss encode -esd -fam fbcon ffmpeg -firefox flac foomaticdb -gcj -gdbm gimpprint glut gmp -gnome -gstreamer gtk gtk2 imagemagick -ipv6 java joystick -kde -ldap libcaca logrotate matroska mikmod mmx mmxext -motif mozilla mplayer msn mysql -nls nptl nptlonly nsplugin offensive ogg oggvorbis -oss pcre php pic ppds -qt -qt3 -qt4 real ruby samba seamonkey session silc speex sqlite sse startup-notification tcltk theora tiff usb vorbis win32codecs x264 xslt

_________________
live(free) || die;
Back to top
View user's profile Send private message
libero
Tux's lil' helper
Tux's lil' helper


Joined: 26 Mar 2004
Posts: 86
Location: Tokyo

PostPosted: Mon Oct 02, 2006 10:04 am    Post subject: Reply with quote

hi everybody,

thanks for the feedback and enhancements.

Couple of notes:

- the original scripts have an unfortunate dependency on whitespace surrounding the " [quote marks] around the actual USE flags. If you get 2 fewer items in your list than you should have, it's because the first and last in the line are being discarded along with the quote marks. Just make sure each quote mark is separated by whitespace from any flags. Or try Akkara's or rojaro's script. Yeah I should fix my original script sometime. ;-)

- GimmeFuel's point is a good one. But to get the same results as his "sort -d" I don't need anything: just default "sort" works that way already on my box. So remember that your mileage may vary: even awk is known to be slightly different here and there.

- the original scripts do *not* attempt to re-write the /etc/make.conf file itself. To do that usually requires root, and is slightly more dangerous than I intended. My recommendation: run the script, view the output, make any tweaks you want, run the script again if you need, then paste back to /etc/make.conf and save.
Back to top
View user's profile Send private message
libero
Tux's lil' helper
Tux's lil' helper


Joined: 26 Mar 2004
Posts: 86
Location: Tokyo

PostPosted: Thu May 01, 2008 3:09 am    Post subject: Reply with quote

more USE flags tips just posted here:

https://forums.gentoo.org/viewtopic-t-669944-start-0-postdays-0-postorder-asc-highlight-.html

I like this one, posted by PopeJohnPaulII who says to organize by groups to remember what was for what in USE flags:
Code:

# Use Flags
USE="" # Not needed, just added to look neater.
USE="$USE -gnome" # Disable GNOME
USE="$USE -qt3 -qt4 -kde -arts" # Disable KDE
USE="$USE -ipv6" # Disable IPv6
USE="$USE symlink" # Kernel
USE="$USE lm_sensors mmx pmu sse sse2" # CPU
USE="$USE acpi apm" # Battery/Power Managment
USE="$USE aac alsa dts esd flac lame mp3 ogg vorbis wavpack" # Audio
USE="$USE exif gif imagemagick jpeg png svg tiff" # Image
USE="$USE cups pdf spell truetype unicode" # Text/Fonts/Printing
USE="$USE fbcon gpm mplayer opengl" # Video
USE="$USE encode ffmpeg matroska mpeg quicktime win32codecs xvid" # Video Codecs
USE="$USE ftp imap samba ssl vnc" # Internet Protocols
USE="$USE avahi wifi zeroconf" # Wireless
USE="$USE joystick pcmcia usb" # Misc Hardware

USE="$USE X" # Xorg
USE="$USE bzip2 cracklib crypt" # Encryption/Decryption/Compression/Decompression
USE="$USE java javascript" # Programing Languages
USE="$USE firefox thunderbird" # Mozilla
USE="$USE bash-completion branding cdr dbus dvd dvdr gtk hal libnotify xscreensaver" # Linux


this however would defeat the purpose of this posting's script. So a variation would be to just put #Comments in your make.conf after the main line of USE, which just shows why each flag is set.
Back to top
View user's profile Send private message
SeaTiger
l33t
l33t


Joined: 22 Nov 2007
Posts: 603
Location: Toronto, Ontario, Canada

PostPosted: Fri May 16, 2008 3:13 am    Post subject: Reply with quote

Personally I use profuse to manage USE flag. Like ufed, it will always arrange flag alphabetically.

However I do very much prefer to arrange them in group like the previous post.
Back to top
View user's profile Send private message
Display posts from previous:   
Reply to topic    Gentoo Forums Forum Index Documentation, Tips & Tricks All times are GMT
Goto page 1, 2  Next
Page 1 of 2

 
Jump to:  
You cannot post new topics in this forum
You cannot reply to topics in this forum
You cannot edit your posts in this forum
You cannot delete your posts in this forum
You cannot vote in polls in this forum