Tanj Tux's lil' helper
Joined: 17 Oct 2002 Posts: 79 Location: London Ontario Canada
|
Posted: Sat Mar 08, 2003 4:36 am Post subject: New program from me !!!! |
|
|
This is the first usefull program that i have writen in Perl.
What it does is takes the list of ebuilds from the file made by
Code: | emerge -p world > file.txt |
world can be an other ebuild or what ever
it then takes that file and strips it down from this
Code: | file.txt
These are the packages that I would merge, in order:
Calculating world dependencies
*** Package in world file is not installed: kde-base/kde
...done!
[ebuild U ] media-sound/alsa-utils-0.9.0_rc8-r1 [0.9.0_rc8]
[ebuild U ] sys-apps/file-3.41 [3.39]
[ebuild U ] net-print/hpijs-1.3.1 [1.3]
[ebuild U ] sys-apps/console-tools-0.3.2 [0.2.3-r4]
[ebuild U ] media-sound/alsa-driver-0.9.0_rc8-r1 [0.9.0_rc8] |
to this Code: | packlist.txt
media-sound/alsa-utils
sys-apps/file
net-print/hpijs
sys-apps/console-tools
media-sound/alsa-driver |
this makes it possible to manually select files to be emerged with Code: |
emerge `cat packlist.txt` |
those are tildes `
so without further ado
Code: | #!/usr/bin/perl
#this program was created by John teBokkel aka Tanj
#the program is used to remove "[ebuild N ]" from
#the dependency list from `emerge -p packageName > file.txt`
#also it removes version information from the end of the ebuild name
use strict;
our($garbage,$line,$string,$newline,$file,$newfile,$num);
$file=$ARGV[0];
$newfile=$ARGV[1];
unless($file and $newfile) {
die "missing argument\ncommand [original file] [destination file]\n";
}
open(FILE,"$file") || die "no such file\n";
open(WORK,">$newfile") || die "could not create file\n";
$newline="\n";
#$num=0;
while(<RESUME>) {
$garbage=s/\[ebuild[\w||\s][\w||\s][\w||\s][\w||\s][\w||\s][\w||\s]\]\s//;
$line=s/\-\d/|/;
($_,$line)=split(/\|/);
$string=$_ . $newline;
if($garbage==1) {
print WORK "$string";
}
}
close FILE;
close WORK;
print "done\n"; |
copy and paste this into a file and name it (mines call "emergelist.pl")
then
Code: | chmod +x emergelist.pl |
then after this the script will work.
syntax like this
Code: | ./emergelist.pl file.txt packlist.txt |
file.txt is the file to be worked on and packlist.txt is the destination file
tips and feedback welcome. |
|