2008-11-22 09:46:55 -01:00
|
|
|
#!/usr/bin/perl -w
|
2008-09-15 23:09:18 +00:00
|
|
|
#
|
|
|
|
# which_deb
|
|
|
|
#
|
|
|
|
# Simple helper tool to find the appropriate version of a package in
|
|
|
|
# the archive to meet a requirement in the debian-cd build
|
|
|
|
|
2008-11-22 09:46:55 -01:00
|
|
|
use strict;
|
2008-09-15 23:09:18 +00:00
|
|
|
|
2008-11-22 09:46:55 -01:00
|
|
|
my ($mirror, $codename, $pkg, $pth, $output);
|
|
|
|
|
|
|
|
$mirror = shift;
|
|
|
|
$codename = shift;
|
|
|
|
$pkg = shift;
|
|
|
|
$output = shift;
|
|
|
|
$pth = "$mirror/dists/$codename/main";
|
|
|
|
|
|
|
|
if (!defined ($output)) {
|
|
|
|
$output = "binary";
|
|
|
|
}
|
|
|
|
|
|
|
|
sub grab_bin_info {
|
|
|
|
my $pth = shift;
|
|
|
|
my $arch = shift;
|
|
|
|
my $pkgname = shift;
|
|
|
|
my $old_split = $/;
|
|
|
|
my $match;
|
|
|
|
my $result = "";
|
|
|
|
|
|
|
|
my $pgz = "$pth/binary-$arch/Packages.gz";
|
|
|
|
|
|
|
|
$/ = ''; # Browse by paragraph
|
|
|
|
|
|
|
|
if (-e $pgz) {
|
|
|
|
open(PFILE, "zcat $pgz |") or
|
|
|
|
die "Failed to read Packages file $pgz";
|
|
|
|
|
|
|
|
while (defined($match = <PFILE>)) {
|
|
|
|
if (($match =~ /^Package: \Q$pkgname\E$/m)) {
|
|
|
|
$result = $match;
|
|
|
|
close PFILE;
|
|
|
|
return $result;
|
|
|
|
}
|
|
|
|
}
|
|
|
|
# Fell through
|
|
|
|
close PFILE;
|
|
|
|
}
|
|
|
|
return "";
|
|
|
|
}
|
|
|
|
|
|
|
|
sub grab_src_info {
|
|
|
|
my $pth = shift;
|
|
|
|
my $pkgname = shift;
|
|
|
|
my $old_split = $/;
|
|
|
|
my $match;
|
|
|
|
my $result = "";
|
|
|
|
|
|
|
|
my $pgz = "$pth/source/Sources.gz";
|
|
|
|
|
|
|
|
$/ = ''; # Browse by paragraph
|
|
|
|
|
|
|
|
if (-e $pgz) {
|
|
|
|
open(PFILE, "zcat $pgz |") or
|
|
|
|
die "Failed to read Sources file $pgz";
|
|
|
|
|
|
|
|
while (defined($match = <PFILE>)) {
|
|
|
|
if (($match =~ /^Package: \Q$pkgname\E$/m)) {
|
|
|
|
$result = $match;
|
|
|
|
close PFILE;
|
|
|
|
return $result;
|
|
|
|
}
|
|
|
|
}
|
|
|
|
# Fell through
|
|
|
|
close PFILE;
|
|
|
|
}
|
|
|
|
return "";
|
|
|
|
}
|
|
|
|
|
|
|
|
my $bin_deb = "";
|
|
|
|
my $pkgdata = "";
|
|
|
|
my $srcname = "";
|
|
|
|
|
|
|
|
if ($pkg eq "debootstrap") {
|
|
|
|
$pkgdata = grab_bin_info($pth, "i386", $pkg);
|
|
|
|
|
|
|
|
} elsif ($pkg eq "silo") {
|
|
|
|
$pkgdata = grab_bin_info($pth, "sparc", $pkg);
|
|
|
|
|
|
|
|
} elsif ($pkg eq "syslinux") {
|
|
|
|
$pkgdata = grab_bin_info($pth, "i386", "syslinux-common");
|
|
|
|
if (length($pkgdata) < 3) {
|
|
|
|
$pkgdata = grab_bin_info($pth, "i386", "syslinux");
|
|
|
|
}
|
|
|
|
} elsif ($pkg eq "yaboot") {
|
|
|
|
$pkgdata = grab_bin_info($pth, "powerpc", $pkg);
|
|
|
|
}
|
|
|
|
|
|
|
|
if (length($pkgdata) > 2) {
|
|
|
|
if ($output eq "binary") {
|
|
|
|
$pkgdata =~ m/^Filename: (\S+)/m and $bin_deb = $1;
|
2008-11-23 17:19:25 -01:00
|
|
|
print "$bin_deb\n";
|
2008-11-22 09:46:55 -01:00
|
|
|
}
|
|
|
|
elsif ($output eq "source") {
|
|
|
|
$srcname = $pkg;
|
|
|
|
$pkgdata =~ m/^Source: (\S+)/m and $srcname = $1;
|
|
|
|
$pkgdata = grab_src_info($pth, $srcname);
|
|
|
|
if (length($pkgdata) > 2) {
|
|
|
|
my $dir;
|
|
|
|
$pkgdata =~ m/^Directory: (\S+)/m and $dir = $1;
|
2008-11-23 17:19:25 -01:00
|
|
|
$pkgdata =~ m/^ (\S+) (\S+) ((\S+).*dsc)/m and print "$dir/$3\n";
|
|
|
|
$pkgdata =~ m/^ (\S+) (\S+) ((\S+).*diff.gz)/m and print "$dir/$3\n";
|
|
|
|
$pkgdata =~ m/^ (\S+) (\S+) ((\S+).*tar.gz)/m and print "$dir/$3\n";
|
2008-11-22 09:46:55 -01:00
|
|
|
}
|
|
|
|
}
|
|
|
|
}
|
|
|
|
|