Ik heb een perl script geschreven dat broncode kan downloaden van de Ubuntu repositories, samen met de patches. Het is inderdaad vrij simpel om dit zelf te doen, en ze dan zelf te md5'en, maar vb "spkg binutils" typen is toch heel wat gemakkelijker als het zelf helemaal downloaden. Ik weet dat apt-get heel goed is en zo, maar ik wil de broncodepakketten hebben, want ik heb dit geschreven omdat ik zelf een Linux-disto aan het brouwen ben (als ik resultaat heb hoor je er meer over) en heel veel broncodepakketen moet downloaden. Ik baseer mijn distro op Ubuntu (lang leve de kracht van de GPL), dus is het script geschreven voor Ubuntu-repo's. Maar je kan iedere debian-gebaseerde repo (.deb pakketten) gebruiken, gewoonweg de regels $SourceSite = en $SourcesFileLoc = aanpassen
Ik ga mogelijk in latere versies het mogelijk maken om broncode direct te installeren, broncode te deinstalleren, .deb pakketten maken, repositories en pakketlijsten te maken.
Hieronder dan het script (valt onder de GPL versie 3)
#!/usr/bin/perl
$VERSION = "1.0";
#check for arguments and show help if user asks to
if ($#ARGV + 1 != 1 or $ARGV[0] eq '-help' or $ARGV[0] eq '--help' or $ARGV[0] eq '-h') {
printhelp();
}
#show version if user asks to
if ($ARGV[0] eq '-v' or $ARGV[0] eq '-version' or $ARGV[0] eq '--version') { print "SPkg version $VERSION\n"; exit 0;}
# print help when user asks or user doesn't supply the right input
sub printhelp {
print "SPkg version $VERSION\n";
print "Usage: spkg ([-h | -help | --help ] [-v | -version | --version ] | packagename)\n";
print "where -h (or equivalents) = show this message\n";
print " -v (or equivalents) = show version\n";
print " packagename = the name of the package you want to dowload\n\n";
print "This program will help you downloading sources from the Ubuntu\n";
print "website (or other websites if you modify it). It will download\n";
print "it, and check it\'s checksum which it will download too.\n\n";
print " Copyright (C) 2007 SeySayux\n\n";
print " This program is free software: you can redistribute it and/or modify\n";
print " it under the terms of the GNU General Public License as published by\n";
print " the Free Software Foundation, either version 3 of the License, or\n";
print " (at your option) any later version.\n\n";
print " This program is distributed in the hope that it will be useful,\n";
print " but WITHOUT ANY WARRANTY; without even the implied warranty of\n";
print " MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the\n";
print " GNU General Public License for more details.\n\n";
print " You should have received a copy of the GNU General Public License\n";
print " along with this program. If not, see .\n";
exit 0;
}
#define the repositories...
$SourceSite = 'http://archive.ubuntu.com/ubuntu/';
$SourcesFileLoc = $SourceSite . 'dists/gutsy/main/source/Sources.gz';
#get the file and gunzip it
$SourcesFile = `wget -q $SourcesFileLoc -O- | gunzip`;
# now we gunzipped it, lets do what we actually have to do
@PkgDescr = ();
@AllPkgs = split(/\n/, $SourcesFile);
$startpush = 0;
foreach $line (@AllPkgs) {
if ($line eq "Package: $ARGV[0]") {
$startpush = 1; #begin pushing
}
if (($line =~ /Package: /) and !($line eq "Package: $ARGV[0]")) {
$startpush = 0; # stop pushing
}
if ($startpush == 1) { push(@PkgDescr, $line); } # push when necessary
}
#now all info about the packet is in @PkgDescr, so lets parse it!
$File; $Patch; $Path; $FileMD5; $PatchMD5;
foreach $pkgline (@PkgDescr) {
if ($pkgline =~ /Directory: /) { # the directory where to find the files
$Path = $pkgline;
$Path =~ s/Directory: //g;
}
if ($pkgline =~ / [a-f0-9]{32} [0-9]+ .+/ ) { # any of the md5sums
if ($pkgline =~ /orig/) { # the tarball
$FileMD5 = $pkgline;
$FileMD5 =~ s/ [0-9]+ / /;
$FileMD5 =~ s/^ //;
$File = $FileMD5;
$File =~ s/[a-f0-9]{32} //; # the filename can be determined from the md5sum
}
if ($pkgline =~ /diff/) { # the patch
$PatchMD5 = $pkgline;
$PatchMD5 =~ s/ [0-9]+ / /;
$PatchMD5 =~ s/^ //;
$Patch = $PatchMD5;
$Patch =~ s/[a-f0-9]{32} //; # the filename can be determined from the md5sum
}
}
}
#good, the shell does the rest
system("wget -nv $SourceSite"."$Path/$File; echo '$FileMD5' | md5sum -c -; wget -nv $SourceSite"."$Path/$Patch; echo '$PatchMD5' | md5sum -c -");
print "All files downloaded!\n";
#that was all, folks!
exit 0;
- SeySayux