blob: 80443dbc5bf6d03f01f51ddac3eb4ac0ca803ed1 (
plain)
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
33
34
35
36
37
38
39
40
41
42
43
44
45
46
47
48
|
#!/usr/bin/perl -w
use strict;
my $dir = shift;
if (! -d $dir) {
die "$dir is not a directory ...";
}
my $mirror = $ENV{'MIRROR'} || die "Set the MIRROR var ...\n";
my $localdebs = $ENV{'LOCALDEBS'} || $mirror;
my $security = $ENV{'SECURITY'} || $mirror;
my $basedir = $ENV{'BASEDIR'} || die "Set the BASEDIR var ...\n";
open (LIST, "$basedir/tools/apt-selection cache show @ARGV |")
|| die "Can't fork : $!\n";
$/ = ''; # Browse by paragraph
my ($p, $file, $arch, $section, $version, $pkgspec, $name);
while (defined($_ = <LIST>)) {
m/^Package: (\S+)/m and $p = $1;
m/^Filename: (\S+)/mi and $file = $1;
m/^Architecture: (\S+)/m and $arch = $1;
m/^Section: (\S+)/m and $section = $1;
m/^Version: (\S+)/m and $version = $1;
$pkgspec = "$p:$arch=$version";
# Check that the directory where the file will be created does
# exist
my $pdir = "$dir/$file";
$pdir =~ s#[^/]+$##g;
if (! -d $pdir)
{
system("mkdir -p $pdir");
}
# And we put the file in the CD tree
chdir($pdir);
system("$basedir/tools/apt-selection", "download", "$pkgspec") == 0
|| die "Failed to download $pkgspec: $!";
}
close LIST or die "Something went wrong with apt-cache : $@ ($!)\n";
|