X-Git-Url: https://git.deb.at/?a=blobdiff_plain;f=lib%2FPackages%2FDoDownload.pm;h=a871afd031bddcf4668ff86a2be15306b33b3b93;hb=d379d564bf9c217e8ac416f75a1a558151cd889f;hp=9cf75f51ba1103255fc8132a91576c8cdc776a61;hpb=ef769eaccb9ebf7f49b8c3240c9c4d6980072ee5;p=deb%2Fpackages.git
diff --git a/lib/Packages/DoDownload.pm b/lib/Packages/DoDownload.pm
index 9cf75f5..a871afd 100644
--- a/lib/Packages/DoDownload.pm
+++ b/lib/Packages/DoDownload.pm
@@ -3,215 +3,42 @@ package Packages::DoDownload;
use strict;
use warnings;
+use POSIX;
use CGI ();
use DB_File;
-use Benchmark;
+use Benchmark ':hireswallclock';
use Exporter;
use Deb::Versions;
-use Packages::HTML ();
use Packages::Search qw( :all );
-use Packages::Config qw( $HOME $DBDIR @SUITES @ARCHIVES @SECTIONS @ARCHITECTURES );
+use Packages::Config qw( $DBDIR @SUITES @ARCHIVES @SECTIONS @ARCHITECTURES );
use Packages::CGI;
use Packages::DB;
our @ISA = qw( Exporter );
our @EXPORT = qw( do_download );
-# TODO: find a way to get the U.S. mirror list from a more authoritive
-# location automatically. might not be overly smart to automatize it
-# completely, since I hand pick sites that are up-to-date, fast, and
-# have HTTP on a reasonably short URL
-# -- Joy
-
-# hint:
-# grep-dctrl -F Site,Alias -e '(udel|bigfoot|kernel|crosslink|internap|cerias|lcs.mit|progeny)' Mirrors.masterlist | timestamps/archive_mirror_check.py
-our @north_american_sites = (
- "ftp.us.debian.org/debian",
- "http.us.debian.org/debian",
- "ftp.debian.org/debian",
-# "ftp.ca.debian.org/debian",
- "ftp.egr.msu.edu/debian",
- "mirrors.kernel.org/debian",
- "archive.progeny.com/debian",
- "debian.crosslink.net/debian",
- "ftp-mirror.internap.com/pub/debian",
- "ftp.cerias.purdue.edu/pub/os/debian",
- "ftp.lug.udel.edu/debian",
- "debian.lcs.mit.edu/debian",
- "debian.teleglobe.net",
- "debian.rutgers.edu",
- "debian.oregonstate.edu/debian",
- );
-our @european_sites = (
- "ftp.de.debian.org/debian",
- "ftp.at.debian.org/debian",
- "ftp.bg.debian.org/debian",
- "ftp.cz.debian.org/debian",
- "ftp.dk.debian.org/debian",
- "ftp.ee.debian.org/debian",
- "ftp.fi.debian.org/debian",
- "ftp.fr.debian.org/debian",
- "ftp.hr.debian.org/debian",
- "ftp.hu.debian.org/debian",
- "ftp.ie.debian.org/debian",
- "ftp.is.debian.org/debian",
- "ftp.it.debian.org/debian",
- "ftp.nl.debian.org/debian",
- "ftp.no.debian.org/debian",
- "ftp.pl.debian.org/debian",
- "ftp.si.debian.org/debian",
- "ftp.es.debian.org/debian",
- "ftp.se.debian.org/debian",
- "ftp.tr.debian.org/debian",
- "ftp.uk.debian.org/debian",
- );
-our @south_american_sites = (
- "ftp.br.debian.org/debian",
- "ftp.cl.debian.org/debian",
- );
-our @australian_sites = (
- "ftp.au.debian.org/debian",
- "ftp.wa.au.debian.org/debian",
- "ftp.nz.debian.org/debian",
- );
-our @asian_sites = (
- "ftp.jp.debian.org/debian",
-# "ftp.kr.debian.org/debian",
- "linux.csie.nctu.edu.tw/debian",
- "debian.linux.org.tw/debian",
- "linux.cdpa.nsysu.edu.tw/debian",
- );
-
-our @volatile_european_sites = (
- "volatile.debian.net/debian-volatile",
- "ftp2.de.debian.org/debian-volatile",
- "ftp.sk.debian.org/debian-volatile",
- );
-our @backports_european_sites = (
- "www.backports.org/debian",
- "debian.sil.at/backports.org/",
- "backports.debian.or.at/backports.org",
- "mirror.realroute.net/backports.org",
- "backports.cisbg.com",
- "backports.linuxdediziert.de/backports.org",
- "debian.netcologne.de/debian-backports",
- "ftp.de.debian.org/backports.org",
- "mirror.buildd.net/backports.org",
- "ftp.estpak.ee/backports.org",
- "debian.acantho.net/backports.org",
- "backports.essentkabel.com/backports.org",
- "backports.sipo.nl",
- "ftp.tuke.sk",
- );
-our @backports_asian_sites = (
- "backports.mithril-linux.org",
- );
-our @backports_australian_sites = (
- "mirror.linux.org.au/backports.org",
- );
-our @amd64_european_sites = (
- "amd64.debian.net/debian",
- "ftp.de.debian.org/debian-amd64/debian",
- "bach.hpc2n.umu.se/debian-amd64/debian",
- "bytekeeper.as28747.net/debian-amd64/debian",
- "mirror.switch.ch/debian-amd64/debian",
- "ftp.nl.debian.org/debian-amd64/debian",
- );
-our @amd64_asian_sites = (
- "hanzubon.jp/debian-amd64/debian",
- );
-our @amd64_north_american_sites = (
- "mirror.espri.arizona.edu/debian-amd64/debian",
- );
-our @kfreebsd_north_american_sites = (
- "www.gtlib.gatech.edu/pub/gnuab/debian",
- );
-our @kfreebsd_european_sites = (
- # master site, aka ftp.gnuab.org
- "kfreebsd-gnu.debian.net/debian",
- "ftp.easynet.be/ftp/gnuab/debian",
- "ftp.de.debian.org/debian-kfreebsd",
- );
-our @nonus_north_american_sites = (
-# "ftp.ca.debian.org/debian-non-US",
- "debian.yorku.ca/debian/non-US",
- "mirror.direct.ca/linux/debian-non-US",
- );
-our @nonus_european_sites = (
- "non-us.debian.org/debian-non-US",
- "ftp.de.debian.org/debian-non-US",
- "ftp.at.debian.org/debian-non-US",
- "ftp.bg.debian.org/debian-non-US",
- "ftp.cz.debian.org/debian-non-US",
- "ftp.fi.debian.org/debian-non-US",
- "ftp.fr.debian.org/debian-non-US",
- "ftp.hr.debian.org/debian-non-US",
- "ftp.hu.debian.org/debian-non-US",
- "ftp.ie.debian.org/debian-non-US",
- "ftp.is.debian.org/debian-non-US",
- "ftp.it.debian.org/debian-non-US",
- "ftp.nl.debian.org/debian-non-US",
- "ftp.no.debian.org/debian-non-US",
- "ftp.pl.debian.org/debian/non-US",
- "ftp.si.debian.org/debian-non-US",
- "ftp.es.debian.org/debian-non-US",
- "ftp.se.debian.org/debian-non-US",
- "ftp.tr.debian.org/debian-non-US",
- "ftp.uk.debian.org/debian/non-US",
- );
-our @nonus_australian_sites = (
- "ftp.au.debian.org/debian-non-US",
- "ftp.wa.au.debian.org/debian-non-US",
- "ftp.nz.debian.org/debian-non-US",
- );
-our @nonus_asian_sites = (
- "ftp.jp.debian.org/debian-non-US",
-# "ftp.kr.debian.org/debian-non-US",
- "linux.csie.nctu.edu.tw/debian-non-US",
- "debian.linux.org.tw/debian-non-US",
- "linux.cdpa.nsysu.edu.tw/debian-non-US",
- );
-our @nonus_south_american_sites = (
- "ftp.br.debian.org/debian-non-US",
- "ftp.cl.debian.org/debian-non-US",
- );
-
-# list of architectures
-our %arches = (
- i386 => 'Intel x86',
- m68k => 'Motorola 680x0',
- sparc => 'SPARC',
- alpha => 'Alpha',
- powerpc => 'PowerPC',
- arm => 'ARM',
- hppa => 'HP PA-RISC',
- ia64 => 'Intel IA-64',
- mips => 'MIPS',
- mipsel => 'MIPS (DEC)',
- s390 => 'IBM S/390',
- "hurd-i386" => 'Hurd (i386)',
- amd64 => 'AMD64',
- "kfreebsd-i386" => 'GNU/kFreeBSD (i386)'
-);
sub do_download {
- my ($params, $opts, $html_header, $menu, $page_content) = @_;
+ my ($params, $opts, $page_content) = @_;
+ my $cat = $opts->{cat};
if ($params->{errors}{package}) {
- fatal_error( "package not valid or not specified" );
+ fatal_error( $cat->g( "package not valid or not specified" ) );
}
if ($params->{errors}{suite}) {
- fatal_error( "suite not valid or not specified" );
+ fatal_error( $cat->g( "suite not valid or not specified" ) );
}
if ($params->{errors}{arch}) {
- fatal_error( "arch not valid or not specified" );
+ fatal_error( $cat->g( "architecture not valid or not specified" ) );
}
if (@{$opts->{suite}} > 1) {
- fatal_error( "more than one suite specified for download (@{$opts->{suite}})" );
+ fatal_error( $cat->g( "more than one suite specified for download (%s)",
+ "@{$opts->{suite}}" ) );
}
if (@{$opts->{arch}} > 1) {
- fatal_error( "more than one architecture specified for download (@{$opts->{arch}})" );
+ fatal_error( $cat->g( "more than one architecture specified for download (%s)",
+ "@{$opts->{arch}}" ) );
}
$opts->{h_sections} = { map { $_ => 1 } @SECTIONS };
@@ -221,9 +48,7 @@ sub do_download {
our (%packages_all);
my (@results);
- my ($final_result, $file, $filen, $md5sum, @file_components, $archive) = ("")x5;
-
- sub gettext { return $_[0]; };
+ my ($final_result, $filename, $directory, @file_components, $archive) = ("")x5;
my $st0 = new Benchmark;
unless (@Packages::CGI::fatal_errors) {
@@ -233,9 +58,10 @@ sub do_download {
read_entry( \%packages, $pkg, \@results, $opts );
+ @results = grep { $_->[7] ne 'v' } @results;
unless (@results) {
- fatal_error( "No such package".
- "{insert link to search page with substring search}" );
+# fatal_error( _g( "No such package." )."
".
+# sprintf( _g( 'Search for the package' ), "$SEARCH_URL/$pkg" ) );
} else {
my $final_result = shift @results;
foreach (@results) {
@@ -244,164 +70,43 @@ sub do_download {
}
}
+ debug( "final_result=@$final_result", 1 );
$archive = $final_result->[1];
my %data = split /\000/, $packages_all{"$pkg $arch $final_result->[7]"};
- $file = $data{filename};
- @file_components = split('/', $file);
- $filen = pop(@file_components);
-
- $md5sum = $data{md5sum};
- }
- }
-
- my $arch_string = $arch ne 'all' ? "on $arches{$arch} machines" : "";
-
- %$html_header = ( title => "Package Download Selection",
- lang => "en",
- print_title => 1 );
-
- if ($file) {
- $$page_content .= "
You can download the requested file from the "; - $$page_content .= join( '/', @file_components).'/'; - $$page_content .= " subdirectory at"; - $$page_content .= $archive ne 'security' ? " any of these sites:" : ":"; - $$page_content .= "
\n"; - - if ($archive eq 'security') { - - $$page_content .= <Debian security updates are currently officially distributed only via - security.debian.org.
-END -; - } elsif ($arch eq 'amd64') { - - $$page_content .= print_links( "North America", $file, @amd64_north_american_sites ); - $$page_content .= print_links( "Europe", $file, @amd64_european_sites ); -# $$page_content .= print_links( "Australia and New Zealand", $file, -# @nonus_australian_sites ); - $$page_content .= print_links( "Asia", $file, @amd64_asian_sites ); -# $$page_content .= print_links( "South America", $file, @nonus_south_american_sites ); - - $$page_content .= <The MD5sum for $filen is $md5sum
\n" - if $md5sum; } -} - -sub print_links { - my ( $title, $file, @servers ) = @_; - - my $str = "$title
"; - $str .= ""; - - return $str; + } 1;