View previous topic :: View next topic |
Author |
Message |
TrueDFX Retired Dev
Joined: 02 Jun 2004 Posts: 1348
|
Posted: Tue Oct 05, 2004 7:52 pm Post subject: Meet used, my ufed replacement |
|
|
Don't forget to back up your make.conf yourself.
Although this program backs it up too, and runs without problems for me, I can't promise it will for you.
Main differences from ufed, not counting minor ufed bugs:
- Automatically removes invalid USE flags
- Doesn't give any explanation of the general concept of USE flags
- Doesn't need to be run as root
- Shows which USE flags affect any currently installed package
- Supports custom USE flags for ebuilds in your overlay directories
- New: No need to see the whole list of USE flags
I posted an older version a couple of days ago, without much interest, but hopefully this update will be more interesting.
I'm hoping to get some feedback, and I'd especially like to hear about any bugs you can find.
Code: | #!/usr/bin/perl -w
use strict;
sub readsh
{
my ($name, $env) = @_;
if(open FILE, $name) {
while(<FILE>) {
s/#.*//;
$_ .= <FILE> || last while(s/\\\n$// or m/^([^"]*|"[^"]*")*"[^"]*$/);
s/"//g;
if(s/^[ \t]*(\w+)=//) {
my $name = $1;
chomp;
s/(?<!\\)\${(\w+)}/$env->{$1}/g;
$env->{$name} = $_;
}
}
close FILE;
}
}
my @portdirs;
my %makeconfuse;
my $makeconfonly;
{
my %env = (
'PORTDIR' => '/usr/portage',
'PORTDIR_OVERLAY' => '',
'USE' => '' );
readsh '/etc/make.conf', \%env;
push @portdirs, $_ for(split ' ', "$env{PORTDIR} $env{PORTDIR_OVERLAY}");
for(split ' ', $env{'USE'}) {
if(m/^\-\*$/) { %makeconfuse = () ;
$makeconfonly = 1 }
elsif(s/^\-//) { $makeconfuse{$_} = 0 }
elsif(s/^\+//) { $makeconfuse{$_} = 1 }
else { $makeconfuse{$_} = 1 }
}
}
my (%iuse, @packages);
{
opendir PKG, "/var/db/pkg" or next;
for my $cat (readdir PKG) {
opendir CAT, "/var/db/pkg/$cat" or next;
for my $pkg (readdir CAT) {
if(open IUSE, "/var/db/pkg/$cat/$pkg/IUSE") {
while(<IUSE>) {
for(split)
{ $iuse{$_} = 1 }
}
close IUSE;
}
if(open PROV, "/var/db/pkg/$cat/$pkg/PROVIDE") {
while(<PROV>) {
for(split) {
s/-\d+(\.\d+)*\w?(_\w+\d*)?(-r\d+)?$//;
push @packages, $_;
}
}
close PROV;
}
$pkg =~ s/-\d+(\.\d+)*\w?(_\w+\d*)?(-r\d+)?$// and
push @packages, "$cat/$pkg";
}
closedir CAT;
}
closedir PKG;
}
my (%packageuse, %profileuse, @usemask);
sub readprofile;
sub readprofile {
my $profile = $_[0];
if(open FILE, "$profile/parent") {
my @parent;
while(<FILE>) {
chomp;
s/#.*//;
if($_ ne '')
{ push @parent, $_ }
}
close FILE;
readprofile "$profile/$_" for(@parent);
}
if(open FILE, "$profile/use.mask") {
while(<FILE>) {
s/#.*//;
for(split) {
if(s/^-//)
{ @usemask = grep(!/^\Q$_\E$/, @usemask) }
else
{ push @usemask, $_ }
}
}
close FILE;
}
if(open FILE, "$profile/use.defaults") {
while(<FILE>) {
s/#.*//;
my ($use, @pkgs) = split;
for my $pkg (@pkgs)
{ do { $packageuse{$use} = 1 if $pkg eq $_ } for(@packages) }
}
close FILE;
}
my %env = ( 'USE' => '' );
if(readsh "$profile/make.defaults", \%env) {
for(split ' ', $env{'USE'}) {
if(m/^\-\*$/) { %profileuse = () }
elsif(s/^\-//) { $profileuse{$_} = 0 }
elsif(s/^\+//) { $profileuse{$_} = 1 }
else { $profileuse{$_} = 1 }
}
}
}
readprofile '/etc/make.profile';
my %flag;
{
for my $portdir (@portdirs) {
if(open FILE, "$portdir/profiles/use.desc") {
while(<FILE>) {
s/#.*//;
m/(.*?) +- +(.*)/ or next;
my $on = 'off';
if(defined $profileuse{$1})
{ if($profileuse{$1}) { $_ ='(+' ; $on = 'on' }
else { $_ ='(-' ; $on = 'off' } }
else { $_ ='( ' }
if(defined $packageuse{$1}) { $_.= '+' ; $on = 'on' }
else { $_.= ' ' }
if(defined $makeconfuse{$1})
{ if($makeconfuse{$1}) { $_.= '+)'; $on = 'on' }
else { $_.= '-)'; $on = 'off' } }
elsif($makeconfonly) { $_.= '-)'; $on = 'off' }
else { $_.= ' )'; }
if(defined $iuse{$1}) { $_.= ' *'}
else { $_.= ' '}
$flag{$1}{'Global'} = [ "$_ $2", $on ];
$flag{$1}{'Global'}[0] =~ s/'/'\\''/g;
}
close FILE;
}
if(open FILE, "$portdir/profiles/use.local.desc") {
while(<FILE>) {
s/#.*//;
m!((.*?)-(.*?)/.*?):(.*?) +- +(.*)! or next;
my $on = 'off';
if(defined $profileuse{$4})
{ if($profileuse{$4}) { $_ ='(+' ; $on = 'on' }
else { $_ ='(-' ; $on = 'off' } }
else { $_ ='( ' ; }
if(defined $packageuse{$4}) { $_.= '+' ; $on = 'on' }
else { $_.= ' ' ; }
if(defined$makeconfuse{$4})
{ if($makeconfuse{$4}) { $_.= '+)'; $on = 'on' }
else { $_.= '-)'; $on = 'off' } }
elsif($makeconfonly) { $_.= '-)'; $on = 'off' }
else { $_.= ' )'; }
if(defined $iuse{$4}) { $_.= ' *'}
else { $_.= ' '}
$flag{$4}{$2} = [ "$_ $5 ($1)", $on, $3 ];
$flag{$4}{$2}[0] =~ s/'/'\\''/g;
}
close FILE;
}
}
}
delete $flag{$_} for(@usemask);
do {
my $warn = 0;
for(sort keys %makeconfuse) {
if(!defined $flag{$_})
{ print "Flag `", $_, "' unrecognised.\n" }
elsif(!defined $iuse{$_})
{ print "Flag `", $_, "' unused.\n" }
else
{ next }
$warn = 1;
}
<STDIN> if $warn;
} if 0;
sub checklist(;$) {
my ($cat) = @_;
my $dialog = "dialog --separate-output --ok-label 'Save & Return' --cancel-label 'Return' "
. "--item-help --no-shadow --stdout --checklist 'USEd: Gentoo Linux USE flag editor' 0 0 0";
for(sort{lc $a cmp lc $b}grep { !$cat or defined $flag{$_}{$cat} } keys %flag) {
$dialog .= " '$_'";
$_ = $flag{$_};
$dialog .= " '$$_{$cat}[0]'";
$dialog .= " '$$_{$cat}[1]'";
$dialog .= " '" . substr($$_{$cat}[0], 8) . "'";
}
$_ = `$dialog`;
return if $?;
for my $f(grep { !$cat or defined $flag{$_}{$cat} } keys %flag)
{ $flag{$f}{$_}[1] = 'off' for(keys %{$flag{$f}}) }
for my $f(split)
{ $flag{$f}{$_}[1] = 'on' for(keys %{$flag{$f}}) }
}
{
my $dialog = "dialog --ok-label 'Select' --extra-button --extra-label 'Save & Exit' --cancel-label 'Exit' "
. "--item-help --no-shadow --stdout --menu 'USEd: Gentoo Linux USE flag editor' 0 0 0";
my %hash;
for(keys %flag) {
for my $cat(keys %{$flag{$_}})
{ $hash{$cat}{$flag{$_}{$cat}[2]} = 1 if defined $flag{$_}{$cat}[2] }
}
$hash{Global} = 'Global USE flags';
for(keys %hash)
{ $hash{$_} = join(', ', sort keys %{$hash{$_}}) if(defined(%{$hash{$_}})) }
for(sort {$a cmp $b} keys %hash)
{ $dialog .= " '$_' '$hash{$_}' '$hash{$_}'" }
for(;;) {
$_ = `$dialog`;
if($? == 0<<8) { checklist($_) }
elsif($? == 3<<8) { last }
else { print "Nothing to save!\n" and exit }
}
}
my @newuse;
{
if($makeconfonly) {
@newuse = ('-*', sort grep { my(undef,$flag)=%{$flag{$_}}; $$flag[1] eq 'on' } keys %flag);
} else {
my (@disabled, @enabled);
for(sort keys %flag) {
my(undef,$flag)=%{$flag{$_}};
my $selected = $$flag[1] eq 'on';
if($selected != (defined $profileuse{$_} or defined $packageuse{$_}))
{ if($selected) { push @enabled , "$_" }
else { push @disabled, "-$_" } }
}
@newuse = (@enabled, @disabled);
}
}
my $newuse;
{
$newuse="USE=\"";
my $len = 0;
for(@newuse) {
if($len + length() >= 73) {
$newuse =~ s/ $/\n /;
$len = 0;
}
$newuse .= "$_ ";
$len += length() + 1;
}
$newuse =~ s/ ?$/"\n/;
}
undef $/;
{
open FILE, '/etc/make.conf';
$_ = <FILE>;
close FILE;
open FILE, '>/etc/make.conf.old' and print FILE and close FILE or die "Couldn't back up make.conf!";
my $set = 0;
s/^[ \t]*USE=("[^"]*"|[^"\\\n]+|\\.)*\n/ $set ? ( '' ) : ( $set = 1, $newuse ) /emsg;
$_ .= $newuse if not $set;
open FILE, '>/etc/make.conf' and print FILE and close FILE or die "Couldn't save make.conf!";
} |
Old update: You can now edit only global flags, or only flags used by category groups (app-*/*)
Old update: Hopefully fix the bug where some flags are removed from make.conf.
New update: Renamed subject, and changed the description. No changes to the script.
Last edited by TrueDFX on Fri Jun 10, 2005 1:45 pm; edited 6 times in total |
|
Back to top |
|
|
TrueDFX Retired Dev
Joined: 02 Jun 2004 Posts: 1348
|
Posted: Sun Oct 10, 2004 12:46 am Post subject: |
|
|
There must be someone here who'll give it a try... or at least comment on what's wrong with it to not even do that much... right? |
|
Back to top |
|
|
elykyllek Tux's lil' helper
Joined: 16 Sep 2002 Posts: 103 Location: Halifax, Nova Scotia, Canada
|
Posted: Mon Oct 11, 2004 4:03 am Post subject: |
|
|
I think the problem is with it being perl. |
|
Back to top |
|
|
Pythonhead Developer
Joined: 16 Dec 2002 Posts: 1801 Location: Redondo Beach, Republic of Calif.
|
Posted: Mon Oct 11, 2004 4:39 am Post subject: Re: Meet used, my ufed replacement - it needs testers |
|
|
TrueDFX wrote: |
- Doesn't need to be run as root
|
How does that work? It can't write to /etc
Does the asterisk mean a package is using the USE flag? |
|
Back to top |
|
|
Genone Retired Dev
Joined: 14 Mar 2003 Posts: 9538 Location: beyond the rim
|
Posted: Mon Oct 11, 2004 4:43 am Post subject: |
|
|
elykyllek wrote: | I think the problem is with it being perl. |
Yep, that's the same problem ufed has |
|
Back to top |
|
|
manywele l33t
Joined: 12 Jul 2003 Posts: 739 Location: Inside
|
Posted: Mon Oct 11, 2004 4:44 am Post subject: |
|
|
TrueDFX,
I tried it out when you posted it. It worked. Didn't kill my make.conf. Looks just like ufed. Forgot to post about it. Happy now? |
|
Back to top |
|
|
TrueDFX Retired Dev
Joined: 02 Jun 2004 Posts: 1348
|
Posted: Mon Oct 11, 2004 5:34 am Post subject: Re: Meet used, my ufed replacement - it needs testers |
|
|
Pythonhead wrote: | TrueDFX wrote: |
- Doesn't need to be run as root
|
How does that work? It can't write to /etc |
It does need write permission to /etc/make.conf and /etc/make.conf.old, but not /etc, because it modifies make.conf and make.conf.old instead of deleting and recreating them. On my system I made these files writeable for the portage group, but you can choose to make them writeable for one user only instead, of course.
Quote: | Does the asterisk mean a package is using the USE flag? |
Yup.
manywele wrote: | I tried it out when you posted it. It worked. Didn't kill my make.conf. Looks just like ufed. Forgot to post about it. Happy now? |
Heh, yup
And as for the Perl comments: it's either Perl or C/C++ for me, and Perl is much better for something like this. I don't know Python... |
|
Back to top |
|
|
TrueDFX Retired Dev
Joined: 02 Jun 2004 Posts: 1348
|
Posted: Thu Nov 11, 2004 4:00 am Post subject: |
|
|
Major update: USE flags are split into groups. I need some texts to display in the main menu. Any recommendations? |
|
Back to top |
|
|
rhill Retired Dev
Joined: 22 Oct 2004 Posts: 1629 Location: sk.ca
|
Posted: Thu Nov 11, 2004 6:57 am Post subject: |
|
|
Quote: | Doesn't give any explanation of what USE flags are |
pretty much the only reason i use ufed instead of manually editing make.conf is because it does give you those definitions.
do you mean group by application type or by flag type? i think the first one would cause you a lot of grief since there's not many global USE flags that are program category specific. you'd basically end up having a near identical list for each group. but, the latter would be cool.
maybe something like
"programing language bindings" - perl, python, ruby, etc
"gnome" - gtk, gtk2, hal, eds
"cryptography/security" - crypt, gnutls, pam, pwdb, kerberos
"networking" - ipv6, tcpwrapper, tcpd
"graphics" - jpeg, png, tiff, gif
yada yada yada...
just an idea. |
|
Back to top |
|
|
TrueDFX Retired Dev
Joined: 02 Jun 2004 Posts: 1348
|
Posted: Thu Nov 11, 2004 7:09 am Post subject: |
|
|
dirtyepic wrote: | Quote: | Doesn't give any explanation of what USE flags are |
pretty much the only reason i use ufed instead of manually editing make.conf is because it does give you those definitions. |
You should probably first give it a try It does give you the description of the individual USE flags, it just doesn't give you a description of how USE flags work (i.e. what you see when you choose "What are USE flags?/Help" in ufed).
Quote: | do you mean group by application type or by flag type? i think the first one would cause you a lot of grief since there's not many global USE flags that are program category specific. you'd basically end up having a near identical list for each group. but, the latter would be cool. |
All global USE flags are displayed in the 'Global' category. All local USE flags for, for example, sys-devel/gcc, are displayed in the 'sys' category. If a local USE flag is used by programs in multiple categories, or if it's for some reason listed as both a global and local USE flag (not my fault), the flag shows up multiple categories. This way it should be easy to find a flag after you've just run emerge -pv package to see which flags are supported.
Quote: | maybe something like
"programing language bindings" - perl, python, ruby, etc
"gnome" - gtk, gtk2, hal, eds
"cryptography/security" - crypt, gnutls, pam, pwdb, kerberos
"networking" - ipv6, tcpwrapper, tcpd
"graphics" - jpeg, png, tiff, gif
yada yada yada...
just an idea. |
That's an interesting idea, but it wouldn't work well since USE flags can get added and removed at any time, and there's no way for any program to automatically group them in such categories. |
|
Back to top |
|
|
rhill Retired Dev
Joined: 22 Oct 2004 Posts: 1629 Location: sk.ca
|
Posted: Thu Nov 11, 2004 7:13 am Post subject: |
|
|
TrueDFX wrote: |
You should probably first give it a try It does give you the description of the individual USE flags, it just doesn't give you a description of how USE flags work (i.e. what you see when you choose "What are USE flags?/Help" in ufed).
|
ha. busted.
alright, i'll give it shot then. |
|
Back to top |
|
|
rhill Retired Dev
Joined: 22 Oct 2004 Posts: 1629 Location: sk.ca
|
Posted: Sat Nov 13, 2004 8:41 pm Post subject: |
|
|
i like the layout. and the sorted categories really work well.
i'm getting an error whenever i hit save & exit, even when i haven't made any changes.
Quote: | Not an ARRAY reference at /usr/local/bin/used line 226. |
which would be.. this guy
Code: | 223 my @newuse;
224 {
225 if($makeconfonly) {
226 @newuse = ('-*', sort grep { $flag{$_}[0][2] eq 'on' } keys %flag);
227 } else {
228 my (@disabled, @enabled);
229 for(sort keys %flag) {
230 my(undef,$flag)=%{$flag{$_}};
231 my $selected = $$flag[1] eq 'on';
232 if($selected != (defined $profileuse{$_} or defined $packageuse{$_}))
233 { if($selected) { push @enabled , "$_" }
234 else { push @disabled, "-$_" } }
235 }
236 @newuse = (@enabled, @disabled);
237 }
238 }
|
here's my USE flags. i'm looking suspiciously at the -*.
Code: | USE="-* aalib alsa bash-completion berkdb cdr crypt divx4linux eds gdbm gif gnome gnutls gpm gstreamer gtk gtk2 gtkhtml hal imlib java jpeg libcaca mad matroska mmx mozilla mpeg ncurses no_wxgtk1 nptl odbc oggvorbis opengl oss pam perl pic png pwdb python quicktime readline real rtc ruby sdl sse ssl tcpd truetype unicode userlocales X xml xml2 xv xvid zlib" |
--de.
[edit - yep, error disappears when i remove -* from make.conf] |
|
Back to top |
|
|
TrueDFX Retired Dev
Joined: 02 Jun 2004 Posts: 1348
|
Posted: Sat Nov 13, 2004 8:51 pm Post subject: |
|
|
dirtyepic wrote: | Quote: | Not an ARRAY reference at /usr/local/bin/used line 226. |
| Oops. I updated the script; it should work now. |
|
Back to top |
|
|
rhill Retired Dev
Joined: 22 Oct 2004 Posts: 1629 Location: sk.ca
|
Posted: Sat Nov 13, 2004 8:55 pm Post subject: |
|
|
working great now. |
|
Back to top |
|
|
rab n00b
Joined: 23 Dec 2003 Posts: 19 Location: Switzerland
|
Posted: Sun Nov 14, 2004 1:14 am Post subject: |
|
|
It seems to work perfect.
I really like the categories, they make it much simpler to clear the mess in my useflags |
|
Back to top |
|
|
nephros Advocate
Joined: 07 Feb 2003 Posts: 2139 Location: Graz, Austria (Europe - no kangaroos.)
|
Posted: Sun Nov 14, 2004 1:31 am Post subject: |
|
|
Agreed.
Good work! _________________ Please put [SOLVED] in your topic if you are a moron. |
|
Back to top |
|
|
needlern1 Guru
Joined: 16 Jul 2002 Posts: 376 Location: Marietta, Ga 30068
|
Posted: Mon Nov 15, 2004 4:04 pm Post subject: |
|
|
Good timing on my part. I was having problems with starting ufed and discovered this slick app. Looks very nice. I like the groupings. Thanks for your good efforts.
Please explain:
Code: | [ ] eds ( +) * Enable Evolution Data Server (EDS) ... |
what the ( +) * ... mean? I just checked my make.conf file and eds is a listed USE flag. Shoud the check box, next to 'eds' also be checked? If not, will it remain as a make.conf USE flag? Hopefully this isn't too much of a muddled question on my part Bill |
|
Back to top |
|
|
TrueDFX Retired Dev
Joined: 02 Jun 2004 Posts: 1348
|
Posted: Tue Nov 16, 2004 2:03 am Post subject: |
|
|
needlern1 wrote: | Good timing on my part. I was having problems with starting ufed and discovered this slick app. Looks very nice. I like the groupings. Thanks for your good efforts.
Please explain:
Code: | [ ] eds ( +) * Enable Evolution Data Server (EDS) ... |
what the ( +) * ... mean? I just checked my make.conf file and eds is a listed USE flag. |
( +) means that your profile doesn't turn on eds, you don't have a package that turns on eds, but your make.conf does turn on eds (just like in ufed). The * means that you have installed a package that uses this flag. Quote: | Shoud the check box, next to 'eds' also be checked? If not, will it remain as a make.conf USE flag? Hopefully this isn't too much of a muddled question on my part Bill | If you turn it off, it will be removed from your USE flags. I don't know if you want that |
|
Back to top |
|
|
tigerike n00b
Joined: 10 Apr 2002 Posts: 9 Location: seattle, wa
|
Posted: Thu Nov 18, 2004 3:23 am Post subject: |
|
|
The script worked great for me. I just wasted arounf an hour trying to get ufed to work with no luck.
Thank you! |
|
Back to top |
|
|
hielvc Advocate
Joined: 19 Apr 2002 Posts: 2805 Location: Oceanside, Ca
|
|
Back to top |
|
|
iplayfast l33t
Joined: 08 Jul 2002 Posts: 642 Location: Cambridge On,CA
|
Posted: Thu Nov 18, 2004 5:55 am Post subject: |
|
|
Looks good. The categories are excellent. I don't know if it's possible (and I'm being nit picky) but when the line scrolls past the edge of the screen it would be better to have it wrap. You can see the full line on the bottom of the screen though so that's probably good enough. Also pam says Code: | "Adds support PAM (Pluggable Authentication Modules) - DANGEROUS to arbitrarily" |
I wonder what it's dangerous to arbitrarily do?
Something that I would like is an explanation of what (++ ) * means. It's not obvious to me. The [X] is obvious. It means that the flag is in the USE string.
Overall I'd say better then ufed (especially now since ufed has died on me). |
|
Back to top |
|
|
TrueDFX Retired Dev
Joined: 02 Jun 2004 Posts: 1348
|
Posted: Thu Nov 18, 2004 6:32 am Post subject: |
|
|
iplayfast wrote: | Looks good. The categories are excellent. I don't know if it's possible (and I'm being nit picky) but when the line scrolls past the edge of the screen it would be better to have it wrap. You can see the full line on the bottom of the screen though so that's probably good enough. | Sorry. used, like ufed, uses dialog to display its checklist. Until dialog supports this or I find a good replacement for dialog, I can't do that. Quote: | Also pam says Code: | "Adds support PAM (Pluggable Authentication Modules) - DANGEROUS to arbitrarily" |
I wonder what it's dangerous to arbitrarily do? | The missing word is "flip". If you change the pam flag, you should make absolutely sure that all packages that use this flag are rebuilt. You can use emerge's --newuse option for this. Quote: | Something that I would like is an explanation of what (++ ) * means. It's not obvious to me. The [X] is obvious. It means that the flag is in the USE string. | The first [+- ] specifies whether your profile enables/disables the flag. The second [+ ] specifies whether your profile enabled this flag when you installed a particular package. (Example: if you install blackdown-jre, the java flag will get turned on, unless you have -java in make.conf.) The third [+- ] specifies whether your current make.conf enables/disables the flag. The * means you have installed a package that uses this flag. Quote: | Overall I'd say better then ufed (especially now since ufed has died on me). | Thanks! |
|
Back to top |
|
|
plate Bodhisattva
Joined: 25 Jul 2002 Posts: 1663 Location: Berlin
|
Posted: Thu Nov 18, 2004 8:24 am Post subject: |
|
|
Just for the record, ufed isn't quite dead, it just needs two patches to work.
Patch #1
Patch #2 |
|
Back to top |
|
|
tropicalhandler n00b
Joined: 09 Apr 2003 Posts: 14 Location: Austin, TX
|
Posted: Thu Nov 18, 2004 11:23 am Post subject: |
|
|
Theres been talk about grouping USE flags on and off for quite sometime. Glad to see someone do it. Very nice replacement, thank you! |
|
Back to top |
|
|
morbus Tux's lil' helper
Joined: 10 May 2004 Posts: 139 Location: Munich
|
Posted: Fri Nov 19, 2004 1:19 pm Post subject: |
|
|
Good job! Main reason for me to change was that the two ufed patches don't work for me, so I'm very glad that I found this. Thank you! |
|
Back to top |
|
|
|
|
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
|
|