Nieuws:

Welkom, Gast. Alsjeblieft inloggen of registreren.
Heb je de activerings-mail niet ontvangen?

Auteur Topic: SPkg (Source Package Manager)  (gelezen 2617 keer)

SPkg (Source Package Manager)
« Gepost op: 2007/12/11, 17:11:52 »
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
I use a Unix-based system, that means I'll get laid as often as I have to reboot.
LibSylph
SeySayux.net

Offline SWAT

  • Administrator
SPkg (Source Package Manager)
« Reactie #1 Gepost op: 2007/12/11, 17:20:26 »
net zoals "apt-get source " dus?

SPkg (Source Package Manager)
« Reactie #2 Gepost op: 2007/12/11, 17:41:55 »
Citaat van: SWAT
net zoals "apt-get source " dus?
Wacht eens even...

Ben zo terug...

- SeySayux
I use a Unix-based system, that means I'll get laid as often as I have to reboot.
LibSylph
SeySayux.net

SPkg (Source Package Manager)
« Reactie #3 Gepost op: 2007/12/11, 17:49:25 »
Zij die vernederd gaan worden, groeten u.
Nu ja, niet helemaal hetzelfde. Het pakt het niet uit en past de patch niet toe (zodat ik de patch zelf nog kan nakijken) en het is minder typwerk. En ik heb er geen werkende dpkg/apt get installatie met pakketbronnen voor nodig (perl, wget en coreutils is voldoende) Voor de rest... mja... veel overeenkomsten... Maar apt-get is GPL, dus daar hoef ik me niet druk over te maken (opnieuw: Lang leve de GPL!)

- SeySayux
I use a Unix-based system, that means I'll get laid as often as I have to reboot.
LibSylph
SeySayux.net

Offline bartek

  • Lid
    • http://bartek.blogsome.com
SPkg (Source Package Manager)
« Reactie #4 Gepost op: 2007/12/11, 17:54:24 »
Zo leer je het seySayux.
Knap dat ge dit al maakt.

Ben benieuwd naar je Ubuntu-versie.
| Deliberando saepe perit occasio |

"Car la vie est un bien perdu quand on n'a pas vécu comme on l'aurait voulu"

SPkg (Source Package Manager)
« Reactie #5 Gepost op: 2007/12/11, 18:21:22 »
Citaat van: bartek
Zo leer je het seySayux.
Knap dat ge dit al maakt.

Ben benieuwd naar je Ubuntu-versie.
3 dagen en 1 forum topic. Hoelang en hoeveel topics zal ik dan niet over de distro doen? Nu ja, altijd optimistisch blijven hé :)

- SeySayux
I use a Unix-based system, that means I'll get laid as often as I have to reboot.
LibSylph
SeySayux.net