Gentoo Forums
Gentoo Forums
Gentoo Forums
Quick Search: in
New program from me !!!!
View unanswered posts
View posts from last 24 hours

 
Reply to topic    Gentoo Forums Forum Index Portage & Programming
View previous topic :: View next topic  
Author Message
Tanj
Tux's lil' helper
Tux's lil' helper


Joined: 17 Oct 2002
Posts: 79
Location: London Ontario Canada

PostPosted: Sat Mar 08, 2003 4:36 am    Post subject: New program from me !!!! Reply with quote

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.
Back to top
View user's profile Send private message
VanDan
Guru
Guru


Joined: 30 Sep 2002
Posts: 586
Location: Australia

PostPosted: Sat Mar 08, 2003 10:38 am    Post subject: Well done! Reply with quote

Crank on man!
That's pretty cool.
Back to top
View user's profile Send private message
Display posts from previous:   
Reply to topic    Gentoo Forums Forum Index Portage & Programming 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