Gentoo Forums
Gentoo Forums
Gentoo Forums
Quick Search: in
How to find more packages then "emerge --deep"
View unanswered posts
View posts from last 24 hours

 
Reply to topic    Gentoo Forums Forum Index Documentation, Tips & Tricks
View previous topic :: View next topic  
Author Message
garo
Bodhisattva
Bodhisattva


Joined: 15 Jul 2002
Posts: 860
Location: Edegem,BELGIUM

PostPosted: Wed May 07, 2003 1:33 pm    Post subject: How to find more packages then "emerge --deep" Reply with quote

THIS SCRIPT HAS NOW BECOME USELESS, IF YOU HAVE A UP-TO-DATE VERSION OF PORTAGE, YOU CAN DO THE SAME THING WITH "EMERGE DEPCLEAN","EMERCE CLEAN" AND "EMERGE PRUNE"

You probably use "emerge -u world" or "emerge -u --deep world" to update your system.
But there are some problems with that...

Take the following example:
-You install package "foo", but "foo" needs "bar" so "bar" is also installed.
-The next day you realize you don't want "foo", so you remove it but" bar" is left behind and isn't found with "emerge" or "emerge --deep".
-if you do like the "bar" package, it is never updated because it's not in the world file and it's not a dependency of a package in the world file
-If you don't like "bar", it's still on the disk without you knowing.

How can you solve these problems ?
With the following perl script (The comments in the source are in Dutch because that's my language but the script is in English):
Code:
#!/usr/bin/perl -w
#check of we root zijn en of alle progs er zijn (installeer ze anders)
if($< ne "0"){die "You have to be root to execute this script...\n";}
unless(-x "/usr/bin/emerge"){die "PORTAGE NOT FOUND:\n\tSo This is not a Gentoo system...\n";}
unless(-x "/usr/bin/epm"){system("emerge epm");}
unless(-x "/usr/bin/find"){system("emerge findutils");}
unless(-x "/bin/grep"){system("emerge grep");}
unless(-x "/usr/bin/sort"){system("emerge textutils");}
unless(-x "/usr/bin/uniq"){system("emerge textutils");}
#zoek welke architectuur dit systeem heeft (zie ook of het stabiel is)
$arch=`grep ACCEPT_KEYWORDS /etc/make.conf | grep -v ^#`;
$arch=~s/ACCEPT_KEYWORDS="(.*)"\n/$1/;
if($arch eq ""){
  print "You didn't set ACCEPT_KEYWORDS in \"/etc/make.conf\",\n";
  print "so i am taking the default (x86) for ACCEPT_KEYWORDS...\n\n";
  $arch="x86";
}
@arch=split(//,$arch);
if($arch[0] eq "~"){
  $stabiel="nee";
}else{
  $stabiel="ja";
  print "You have a stable system,\n";
  print "Do you also want to see the (installed) masked packages ? (y/N) :";
  $antwoord=<STDIN>;if($antwoord =~ /[jJyY]/){$alles="ja";}else{$alles="nee";}
}
print "\nSearching... (This can take a while)\n";
#zoek alle packages die volgens epm op het systeem zijn
@epm=split(/\n/,`/usr/bin/epm -qa`);
#zet alles wat --deep vind in @emerge (ik vraag emerge om te doen of
#het systeem leeg is en alles te installeren wat in world staat, dus de deps
#worden ook gevonden
@emerge=split(/\n/,`/usr/bin/emerge world -p -e`);
#zet @emerge in hetzelfde formaat als @epm
foreach(@emerge){
  $_=~s/.*\/(\S*)\s*/$1/;
}
#print alle packages die bestaan maar niet in "world" zitten
$totmask=0;
for($teller=0;$teller!=@epm;$teller++){
  $inworld="nee";
  foreach(@emerge){
    if($_ eq $epm[$teller]){
      $inworld="ja";
      last;
    }
  }
  if($inworld eq "nee"){
    #zet de packags die emerge niet vind in @vergeten,zet de naam in world-formaat in @vergworld,
    #zet "ja" in @masked als het masked is en zet andere versies van dit package in @andere
    push(@vergeten,$epm[$teller]);
    $world=`/usr/bin/find /usr/portage | /bin/grep $epm[$teller].ebuild\$`;
    $masked="nee";
    if($stabiel eq "ja"){
      $keywords=`grep ^KEYWORDS $world`;
      $keywords=~s/KEYWORDS="(.*)"/$1/;
      @keywords=split(/ /,$keywords);
      foreach(@keywords){
        if($_ eq "~$arch"){$masked="ja";$totmask++;last;}
      }
    }
    push(@masked,$masked);
    $world=~s/\/usr\/portage\/(.*)\/\Q$epm[$teller]\E\.ebuild\n/$1/;
    push(@vergworld,$world);
    $world=~s/.*\///;
    $world=`/usr/bin/epm -q $world`;
    $world=~s/\Q$epm[$teller]\E\n//;
    push(@andere,$world);
  }
}
if($alles eq "ja"){$vergeten=@vergeten;}else{$vergeten=@vergeten - $totmask;}
print "\nThere are $vergeten \"forgotten\" packages, here they come:\n";
for($teller=0;$teller!=@vergeten;$teller++){
  unless($masked[$teller] eq "ja" and $alles eq "nee"){
    print "\n$vergeten[$teller] is found, I can:\n";
    print "1) Unmerge it\n";
    print "2) Put it in the world file\n";
    print "   (This has no effect if a other version of this package is in the world file)\n";
    print "3) ignore it\n\n";
    unless($andere[$teller] eq ""){
      print "PS: There are also other versions of this package installed:\n$andere[$teller]\n";
    }
    if($masked[$teller] eq "ja"){print "PS: This is a masked package (and you have a stable system).\n\n";}
    print "What do I have to do ? (default=3): ";
    $invoer=<STDIN>;
    if($invoer =~ /1/){system("/usr/bin/emerge -C $vergeten[$teller]");}
    elsif($invoer =~ /2/){
      open(WORLD,">>/var/cache/edb/world");
      print WORLD "$vergworld[$teller]\n";
      close(WORLD);
    }
  }
}
#filter dubbele lijnen
system("/usr/bin/sort /var/cache/edb/world > tijdelijk && /usr/bin/uniq tijdelijk > /var/cache/edb/world");


EDIT: Fixed the problem with masked packages on a stable system
EDIT 2: Improved the reading of /etc/make.conf + some extra checks for errors
EDIT 3: The script now also works if you didn't configured ACCEPT_KEYWORDS in your "/etc/make.conf" + The output changed a little (empty lines between different sections).

PS: If you don't know how to execute this script, this is how you do it :
1) Put this code in a file, (for example "thescript.pl")
2) Make it executable (give the command "chmod +x thescript.pl")
3) Login as root and try it...

Before posting problems, check if you have the newest version of perl:
Code:
emerge rsync && emerge -u perl
[/b]
_________________
My favorite links this month:
- Surf Random
- Web-based SSH
- Stop Spam


Last edited by garo on Sat May 10, 2003 6:40 pm; edited 7 times in total
Back to top
View user's profile Send private message
BonezTheGoon
Bodhisattva
Bodhisattva


Joined: 14 Jun 2002
Posts: 1398
Location: Albuquerque, NM -- birthplace of Microsoft and Gentoo

PostPosted: Wed May 07, 2003 4:01 pm    Post subject: Reply with quote

A related thread has been created for any support related issues or questions about this topic. Please do not post any questions or support related issues in this thread given it is in the Documentation, Tips and Tricks forum.

Support for Howto find more packages than emerge -D

Thanks,
BonezTheGoon
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
Page 1 of 1

 
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