Package: apt-cacher
Version: current
Severity: wishlist
Tags: patch
Hello,
a nice thing I wish to see in the apt-cacher package is a script that
fetches packages that will presumable be fetched by apt-get in the next
run. This way we can download them tonight (after mirror push) on our
proxy server (slow outbound connection) and then install in the morning
quickly. My implementation attached.
Regards,
Eduard.
-- System Information:
Debian Release: 3.1
APT prefers unstable
APT policy: (990, 'unstable'), (500, 'testing'), (1, 'experimental')
Architecture: i386 (i686)
Kernel: Linux 2.6.11.5
Locale: LANG=de_DE.UTF-8, LC_CTYPE=de_DE.UTF-8 (charmap=UTF-8)
Versions of packages apt-cacher depends on:
ii apache2-mpm-prefork [apache2] 2.0.53-5 traditional model for Apache2
hi perl 5.8.4-8 Larry Wall's Practical Extraction
ii wget 1.9.1-10 retrieves files from the web
--
"Herr Ober, das Steak riecht nach Schnaps!"
Der Ober tritt drei Schritte zur�ck und fragt: "Immer noch?"
#!/usr/bin/perl
use strict;
my $nlcount=0;
my ($cachedir, $baseurl) = @ARGV;
my $tmp=`mktemp`;
chomp $tmp;
die "USAGE: apt-precache apt-cacher-cachedir apt-cacher-base-url\n" if !
($cachedir && $baseurl);
chdir $cachedir;
for my $pgz (<*es.gz>) {
my $acurl=$pgz;
$acurl =~ s!_!/!g;
my $pgzurl = "$baseurl/$acurl";
$acurl =~ s!^!$baseurl/!;
$acurl =~ s!/dists/.*!!; # that sucks, pure guessing
open(pfile, "wget -q -O - \"$pgzurl\" > $tmp; zcat $tmp |");
my %pkgs;
for (<*>) { my $pn=$_; $pn=~s/_.*//g; $pkgs{$pn}=$_; }
while(<pfile>) {
if(/^Filename: (.*)\n/) {
my $path=$1;
/^Filename: .*\/(([^\/_]+).*)\n/;
if($pkgs{$2}) {
#print "D: $path\n";
if(!-e $1) {
system "wget -q -O /dev/null $acurl/$path";
}
}
}
}
}
unlink $tmp;