Skip to content

Commit

Permalink
Support non-existing .gz index files
Browse files Browse the repository at this point in the history
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>
  • Loading branch information
Ganneff authored and bdrung committed Nov 8, 2016
1 parent 408721e commit ca24918
Showing 1 changed file with 15 additions and 7 deletions.
22 changes: 15 additions & 7 deletions apt-mirror
Expand Up @@ -752,7 +752,7 @@ sub remove_spaces($)
}
}

sub process_index_gz
sub process_index
{
my $uri = shift;
my $index = shift;
Expand All @@ -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;
}

Expand Down Expand Up @@ -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" );
}
}

Expand All @@ -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" );
}
}

Expand Down

0 comments on commit ca24918

Please sign in to comment.