Re: [gentoo-user] USE flags, command line and packages.use

2005-12-21 Thread Michael Kjorling
On 2005-12-21 16:35 -0200, [EMAIL PROTECTED] wrote:
 modifying the default USE for them, but I did that at command line
 (yeah, yeah, I know, don't tell me), now, is there some easy way to
 put the CURRENT USE flags that the packages in world are using at
 packages.use? I am afraid that an emerge -u world would download A

I would have a look at the shell command history.
 
-- 
Michael Kjörling, [EMAIL PROTECTED] - http://michael.kjorling.com/
* ASCII Ribbon Campaign: Against HTML Mail, Proprietary Attachments *
* . No bird soars too high if he soars with his own wings . *


pgpcpuWi73Na3.pgp
Description: PGP signature


Re: [gentoo-user] USE flags, command line and packages.use

2005-12-21 Thread Daniel da Veiga
On 12/21/05, Michael Kjorling [EMAIL PROTECTED] wrote:
 On 2005-12-21 16:35 -0200, [EMAIL PROTECTED] wrote:
  modifying the default USE for them, but I did that at command line
  (yeah, yeah, I know, don't tell me), now, is there some easy way to
  put the CURRENT USE flags that the packages in world are using at
  packages.use? I am afraid that an emerge -u world would download A

 I would have a look at the shell command history.


Well, got the last packages, but the older ones (from 1 or 2 days ago)
are not there, any other suggestion? (oh yeah, I noticed this after
almost a week emerging stuff, every installation is a learning
process, next time, I'll keep track of these USEs)

 --
 Michael Kjörling, [EMAIL PROTECTED] - http://michael.kjorling.com/
 * ASCII Ribbon Campaign: Against HTML Mail, Proprietary Attachments *
 * . No bird soars too high if he soars with his own wings . *





--
Daniel da Veiga
Computer Operator - RS - Brazil
-BEGIN GEEK CODE BLOCK-
Version: 3.1
GCM/IT/P/O d-? s:- a? C++$ UBLA++ P+ L++ E--- W+++$ N o+ K- w O M- V-
PS PE Y PGP- t+ 5 X+++ R+* tv b+ DI+++ D+ G+ e h+ r+ y++
--END GEEK CODE BLOCK--

-- 
gentoo-user@gentoo.org mailing list



Re: [gentoo-user] USE flags, command line and packages.use

2005-12-21 Thread Richard Fish
On 12/21/05, Daniel da Veiga [EMAIL PROTECTED] wrote:
 Hello list,

 Sorry if this is a silly question and/or if there is no easy way to
 fix the mess on my system, here is the problem: I installed
 everything, configured some stuff and started building apps, the only
 unstalbe package would be Xorg (because I need some drivers related to
 unichrome), and almost all apps passed an emerge -pv in order to
 check USE flags, the case is that I customized most of the packages,
 modifying the default USE for them, but I did that at command line
 (yeah, yeah, I know, don't tell me), now, is there some easy way to
 put the CURRENT USE flags that the packages in world are using at
 packages.use? I am afraid that an emerge -u world would download A
 LOT of unnecessary stuff using the default USE for each package, and
 causing a mess on my filesystem.


You are lucky this problem looked interesting to me! ;-

Here is a script that will:

1. Scan the package database
2. Examine the USE flags from when packages were merged, the USE flags
that the package knows about, and the current global USE flags.
3. Output package names and the use flag settings that need to be in
/etc/portage/package.use to account for the difference between the
global flags and what was in effect when the package was merged.

Save it as mkpkguse.sh and run it with sh mkpkguse.sh.

Disclaimer: I think this works correctly, but I don't guarantee
anything.  If it breaks, you get to keep the pieces.

-Richard

#!/bin/bash

idx_in_array() {
local item array i
item=$1
array=($2)

i=0
while test -n ${array[$i]}; do
if test ${array[$i]} = $item; then
echo $i
return 0
fi
i=$(($i + 1))
done
echo -1
return -1
}

cd /var/db/pkg
eval `emerge --info | grep ^USE=`
USE=($USE)

for pkg in */*; do
pkg_flags=(`cat $pkg/IUSE`)
used_flags=(`cat $pkg/USE`)
eval `bzcat $pkg/environment.bz2 | grep ^PN=`
category=`dirname $pkg`
i=0;
while test -n ${pkg_flags[$i]}; do
flag=${pkg_flags[$i]}
use_idx=`idx_in_array $flag ${USE[*]}`
pkg_idx=`idx_in_array $flag ${used_flags[*]}`
if test $pkg_idx -lt 0 -a $use_idx -ge 0; then
# flag in current USE, but not when pkg
merged, use -flag
flag=-${flag}
elif test $pkg_idx -ge 0 -a $use_idx -lt 0; then
# flag not in current USE, but was when pkg
merged, use +flag
flag=+${flag}
else
# no change in flag
flag=
fi

pkg_flags[$i]=$flag
i=$(($i + 1))
done

flags=${pkg_flags[*]}
if test -n $flags; then
echo $category/$PN $flags
fi
done

-- 
gentoo-user@gentoo.org mailing list



Re: [gentoo-user] USE flags, command line and packages.use

2005-12-21 Thread Boyd Stephen Smith Jr.
On Wednesday 21 December 2005 12:35, Daniel da Veiga 
[EMAIL PROTECTED] wrote about '[gentoo-user] USE flags, command 
line and packages.use':
 Is there some easy way to 
 put the CURRENT USE flags that the packages in world are using at
 packages.use?

for pkg in $(cat /var/lib/portage/world); do
FAKE_USE=$(equery u $pkg)
USE=
for use in $FAKE_USE; do
USE=$USE ${use##+}
done
echo $pkg$USE;
done  /etc/portage/package.use

Or something like that.

-- 
Boyd Stephen Smith Jr.
[EMAIL PROTECTED]
ICQ: 514984 YM/AIM: DaTwinkDaddy
-- 
gentoo-user@gentoo.org mailing list



Re: [gentoo-user] USE flags, command line and packages.use

2005-12-21 Thread Boyd Stephen Smith Jr.
On Wednesday 21 December 2005 14:50, Boyd Stephen Smith Jr. 
[EMAIL PROTECTED] wrote about 'Re: [gentoo-user] USE flags, command 
line and packages.use':
 for pkg in $(cat /var/lib/portage/world); do
   FAKE_USE=$(equery u $pkg)
   USE=
   for use in $FAKE_USE; do
   USE=$USE ${use##+}
   done
   echo $pkg$USE;
 done  /etc/portage/package.use

 Or something like that.

Not that this is bash-golf or anything, but I think it's better to do it 
like this:

for pkg in $(cat /var/lib/portage/world); do
echo $pkg$(echo $(equery u $pkg) | sed -re 's/(^|[[:space:]])\+/ 
/g');
done  /etc/portage/package.use

-- 
Boyd Stephen Smith Jr.
[EMAIL PROTECTED]
ICQ: 514984 YM/AIM: DaTwinkDaddy
-- 
gentoo-user@gentoo.org mailing list



Re: [gentoo-user] USE flags, command line and packages.use

2005-12-21 Thread Daniel da Veiga
On 12/21/05, Boyd Stephen Smith Jr. [EMAIL PROTECTED] wrote:
 On Wednesday 21 December 2005 14:50, Boyd Stephen Smith Jr.
 [EMAIL PROTECTED] wrote about 'Re: [gentoo-user] USE flags, command
 line and packages.use':
  for pkg in $(cat /var/lib/portage/world); do
FAKE_USE=$(equery u $pkg)
USE=
for use in $FAKE_USE; do
USE=$USE ${use##+}
done
echo $pkg$USE;
  done  /etc/portage/package.use
 
  Or something like that.

 Not that this is bash-golf or anything, but I think it's better to do it
 like this:

 for pkg in $(cat /var/lib/portage/world); do
 echo $pkg$(echo $(equery u $pkg) | sed -re 's/(^|[[:space:]])\+/ 
 /g');
 done  /etc/portage/package.use

 --
 Boyd Stephen Smith Jr.
 [EMAIL PROTECTED]
 ICQ: 514984 YM/AIM: DaTwinkDaddy
 --
 gentoo-user@gentoo.org mailing list



Gotta love when scripters like one of your problems, gonna test all of
the scripts, benchmark them in my system and post the results righ
after to this thread, thank you guys, if I step into trouble I may add
something to it and we could publish it as part of Gentoo, so if one
use the command line to set USEs, it could rebuild package.use after a
few emerges or before an update.

Thanks again, I'll get back later (christmas shopping with girlfriend,
hate that)

--
Daniel da Veiga
Computer Operator - RS - Brazil
-BEGIN GEEK CODE BLOCK-
Version: 3.1
GCM/IT/P/O d-? s:- a? C++$ UBLA++ P+ L++ E--- W+++$ N o+ K- w O M- V-
PS PE Y PGP- t+ 5 X+++ R+* tv b+ DI+++ D+ G+ e h+ r+ y++
--END GEEK CODE BLOCK--

-- 
gentoo-user@gentoo.org mailing list



Re: [gentoo-user] USE flags, command line and packages.use

2005-12-21 Thread Christoph Eckert
Hi,


 You are lucky this problem looked interesting to me! ;-

I'm also lucky it did ;-) .

 Here is a script that will:

 1. Scan the package database
 2. Examine the USE flags from when packages were merged, the USE
 flags that the package knows about, and the current global USE flags.
 3. Output package names and the use flag settings that need to be in
 /etc/portage/package.use to account for the difference between the
 global flags and what was in effect when the package was merged.

 Save it as mkpkguse.sh and run it with sh mkpkguse.sh.

thanks a bunch for sharing. That's really nice of you!

 Disclaimer: I think this works correctly, but I don't guarantee
 anything.  If it breaks, you get to keep the pieces.

I promise I will not complain if it wipes my hard drive :) .


Thanks  best regards


ce

-- 
gentoo-user@gentoo.org mailing list