117 lines
2.8 KiB
Plaintext
117 lines
2.8 KiB
Plaintext
|
#!/usr/bin/perl -w
|
||
|
#
|
||
|
# 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
|
||
|
|
||
|
use strict;
|
||
|
|
||
|
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;
|
||
|
print "$bin_deb\n";
|
||
|
}
|
||
|
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;
|
||
|
$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";
|
||
|
}
|
||
|
}
|
||
|
}
|
||
|
|