1999-11-11 16:10:37 -01:00
|
|
|
#!/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";
|
2000-06-30 00:04:03 +00:00
|
|
|
my $localdebs = $ENV{'LOCALDEBS'} || $mirror;
|
2002-03-21 17:30:24 -01:00
|
|
|
my $security = $ENV{'SECURITY'} || $mirror;
|
1999-11-11 16:10:37 -01:00
|
|
|
my $nonus = $ENV{'NONUS'} || '';
|
|
|
|
my $basedir = $ENV{'BASEDIR'} || die "Set the BASEDIR var ...\n";
|
2005-12-13 01:04:33 -01:00
|
|
|
my $codename = $ENV{'CODENAME'} || die "Set the CODENAME var ...\n";
|
1999-11-11 16:10:37 -01:00
|
|
|
|
|
|
|
require "$basedir/tools/link.pl";
|
|
|
|
|
|
|
|
open (LIST, "$basedir/tools/apt-selection cache show @ARGV |")
|
|
|
|
|| die "Can't fork : $!\n";
|
|
|
|
|
|
|
|
$/ = ''; # Browse by paragraph
|
|
|
|
|
2005-12-13 01:04:33 -01:00
|
|
|
my ($p, $file, $arch, $d, $realfile, $source, $section, $name, $pkgfile, $dist, $pdir);
|
1999-11-11 16:10:37 -01:00
|
|
|
while (defined($_ = <LIST>)) {
|
|
|
|
m/^Package: (\S+)/m and $p = $1;
|
2000-09-05 23:12:54 +00:00
|
|
|
m/^Filename: (\S+)/mi and $file = $1;
|
1999-11-11 16:10:37 -01:00
|
|
|
m/^Architecture: (\S+)/m and $arch = $1;
|
|
|
|
m/^Section: (\S+)/m and $section = $1;
|
|
|
|
|
2005-12-14 00:38:40 -01:00
|
|
|
if ($file =~ /\/main\//) {
|
2005-12-13 01:04:33 -01:00
|
|
|
$dist = "main";
|
2005-12-14 00:38:40 -01:00
|
|
|
} elsif ($file =~ /\/contrib\//) {
|
2005-12-13 01:04:33 -01:00
|
|
|
$dist = "contrib";
|
2005-12-14 00:38:40 -01:00
|
|
|
} elsif ($file =~ /\/non-free\//) {
|
2005-12-13 01:04:33 -01:00
|
|
|
$dist = "non-free";
|
2005-12-14 00:38:40 -01:00
|
|
|
} elsif ($file =~ /\/local\//) {
|
|
|
|
$dist = "local";
|
2005-12-13 01:04:33 -01:00
|
|
|
}
|
|
|
|
|
|
|
|
$pdir = "$dir/dists/$codename/$dist/binary-$ENV{'ARCH'}";
|
|
|
|
if ($section eq "debian-installer") {
|
|
|
|
$pdir = "$dir/dists/$codename/$dist/debian-installer/binary-$ENV{'ARCH'}";
|
|
|
|
}
|
|
|
|
$pkgfile = "$pdir/Packages";
|
|
|
|
|
|
|
|
if (! -d $pdir) {
|
|
|
|
system("mkdir -p $pdir");
|
|
|
|
}
|
|
|
|
|
|
|
|
open(PFILE, ">>$pkgfile");
|
|
|
|
print PFILE $_;
|
|
|
|
close(PFILE);
|
|
|
|
|
2001-08-21 19:07:43 +00:00
|
|
|
$source = ($section =~ /non-US/i) ? $nonus : $mirror;
|
1999-11-11 16:10:37 -01:00
|
|
|
|
2000-06-30 00:04:03 +00:00
|
|
|
# This is a hack to allow the local debs to be located elsewhere.
|
|
|
|
$source=$localdebs if $file=~m:local/:;
|
2005-12-13 01:04:33 -01:00
|
|
|
$source=$security if $file=~m:updates/:;
|
2000-06-30 00:04:03 +00:00
|
|
|
|
2000-11-12 21:41:45 -01:00
|
|
|
# If arch=all and filename points to binary-all then create
|
|
|
|
# a symbolic link in binary-$ARCH or if arch=all and filename is a
|
|
|
|
# symbolic link we suppose that the link points to
|
|
|
|
# .../binary-all/... and we reproduce a similar setup on the CD
|
|
|
|
if ($arch eq "all" and (-l "$source/$file" or
|
|
|
|
$file =~ m#/binary-all/#)) {
|
2001-03-18 18:01:36 -01:00
|
|
|
$file =~ s#/binary-all/#/binary-$ENV{'ARCH'}/#g;
|
|
|
|
|
|
|
|
# Check that the directory where the link will be created does
|
|
|
|
# exist
|
2005-12-13 01:04:33 -01:00
|
|
|
$pdir = "$dir/$file";
|
2001-03-18 18:01:36 -01:00
|
|
|
$pdir =~ s#[^/]+$##g;
|
|
|
|
if (! -d $pdir)
|
|
|
|
{
|
|
|
|
system("mkdir -p $pdir");
|
|
|
|
}
|
|
|
|
|
|
|
|
# Create the symlink from binary-$arch to binary-all
|
2002-03-21 17:30:24 -01:00
|
|
|
if ($section =~ /non-US/ || $file =~ /updates/ ) {
|
2001-03-18 18:01:36 -01:00
|
|
|
$file =~ m#/([^/]+)$# and $name = $1;
|
|
|
|
symlink ("../binary-all/$name", "$dir/$file") ||
|
|
|
|
die "Can't symlink $dir/$file to ../binary-all/$name: $!";
|
|
|
|
} else {
|
|
|
|
$file =~ m#/([^/]+/[^/]+)$# and $name = $1;
|
|
|
|
symlink ("../../binary-all/$name", "$dir/$file") ||
|
|
|
|
die "Can't symlink $dir/$file to ../../binary-all/$name: $!";
|
|
|
|
}
|
|
|
|
$file =~ s#/binary-$ENV{'ARCH'}/#/binary-all/#g;
|
1999-11-11 16:10:37 -01:00
|
|
|
}
|
2001-03-18 18:01:36 -01:00
|
|
|
|
2000-01-21 20:22:03 -01:00
|
|
|
# And we put the file in the CD tree (with a (hard) link)
|
|
|
|
$realfile = real_file ("$source/$file");
|
|
|
|
good_link ($realfile, "$dir/$file");
|
1999-11-11 16:10:37 -01:00
|
|
|
}
|
|
|
|
|
|
|
|
close LIST or die "Something went wrong with apt-cache : $@ ($!)\n";
|
|
|
|
|
|
|
|
|