Support non-existing .gz index files

apt-mirror hardcodes .gz usage and as such is no longer able to
actually mirror Debian (experimental).

Use .xz or .bz2 index files when there are not .gz index files.

fixes #30
Closes: #819974

Signed-off-by: Benjamin Drung <benjamin.drung@profitbricks.com>
pull/51/merge
Joerg Jaspert 6 years ago committed by Benjamin Drung
parent 408721e8f0
commit ca24918f57
  1. 22
      apt-mirror

@ -752,7 +752,7 @@ sub remove_spaces($)
}
}
sub process_index_gz
sub process_index
{
my $uri = shift;
my $index = shift;
@ -762,14 +762,22 @@ sub process_index_gz
local $/ = "\n\n";
$mirror = get_variable("mirror_path") . "/" . $path;
if ( $index =~ s/\.gz$// )
if (-e "$path/$index.gz" )
{
system("gunzip < $path/$index.gz > $path/$index");
}
elsif (-e "$path/$index.xz" )
{
system("xz -d < $path/$index.xz > $path/$index");
}
elsif (-e "$path/$index.bz2" )
{
system("bzip2 -d < $path/$index.bz2 > $path/$index");
}
unless ( open STREAM, "<$path/$index" )
{
warn("apt-mirror: can't open index in process_index_gz");
warn("apt-mirror: can't open index $path/$index in process_index");
return;
}
@ -827,12 +835,12 @@ foreach (@config_sources)
my $component;
foreach $component (@components)
{
process_index_gz( $uri, "/dists/$distribution/$component/source/Sources.gz" );
process_index( $uri, "/dists/$distribution/$component/source/Sources" );
}
}
else
{
process_index_gz( $uri, "/$distribution/Sources.gz" );
process_index( $uri, "/$distribution/Sources" );
}
}
@ -845,12 +853,12 @@ foreach (@config_binaries)
my $component;
foreach $component (@components)
{
process_index_gz( $uri, "/dists/$distribution/$component/binary-$arch/Packages.gz" );
process_index( $uri, "/dists/$distribution/$component/binary-$arch/Packages" );
}
}
else
{
process_index_gz( $uri, "/$distribution/Packages.gz" );
process_index( $uri, "/$distribution/Packages" );
}
}

Loading…
Cancel
Save