Bug#305175: better version

2005-04-20 Thread Eduard Bloch
#include hallo.h
* Eduard Bloch [Mon, Apr 18 2005, 04:11:27PM]:
 #include hallo.h
 
 A better version of that script attached.

PS: after some testing I reallized that pre-caching sucks. For example,
if person I uses packages (a,b,c) from Testing and person II uses
packages (d,e,f) from sid, they ALL are fetched in both available
versions by apt-precache.

OTOH pre-caching is still a good compromise between mirroring the whole
archive (with daily updates) and fetching on-demand.

Regards,
Eduard.
-- 
  After watching my newly-retired dad spend two weeks learning how to
  make a new folder, it became obvious that intuitive mostly means
  what the writer or speaker of intuitive likes.
- Bruce Ediger, [EMAIL PROTECTED], on X the intuitiveness of a Mac interface


-- 
To UNSUBSCRIBE, email to [EMAIL PROTECTED]
with a subject of unsubscribe. Trouble? Contact [EMAIL PROTECTED]



Bug#305175: better version

2005-04-18 Thread Eduard Bloch
#include hallo.h

A better version of that script attached.

Regards,
Eduard.
-- 
asuffield we should have a button on every computer marked ?, and
  connected to twenty pounds of semtex, and then let evolution take its
  course// quote from #debian-devel
#!/usr/bin/perl

use strict;

my ($cachedir, $baseurl, $verbose) = @ARGV;
die USAGE: apt-precache apt-cacher-cachedir apt-cacher-base-url [-v] \n if ! 
($cachedir  $baseurl);

my $tmp=`mktemp`;
my $pcount=0;
chomp $tmp;

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

   print D: $pgzurl\n if $verbose;
   # dl to temp file first, otherwise risking connection timout
   if((!system wget,-q,-O,$tmp,$pgzurl)  open(pfile,-|,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}) {
   if(!-e $1) {
  $pcount++;
  print D: $acurl/$path\n if $verbose;
  system wget, -q, -O, /dev/null, $acurl/$path;
   }
}
 }
  }
   }
}

unlink $tmp;

print Downloaded: $pcount packages.\n if $verbose;