Skip to content

Commit

Permalink
Only download compressed index files
Browse files Browse the repository at this point in the history
I cannot find a single repository serving the uncompressed index files.

Furthermore, per the documentation at
https://wiki.debian.org/DebianRepository/Format#Compression_of_indices

    Servers should offer only xz compressed files, except for the
    special cases listed above.

Therefore we should only download the compressed files, and only serve
the compressed files, and all clients are expected to understand them.

The uncompressed versions are documented in the Release file, but we can
safely ignore them and only get the compressed ones instead.
  • Loading branch information
chutzimir committed Jul 9, 2022
1 parent 7366c2e commit 76bd728
Showing 1 changed file with 9 additions and 12 deletions.
21 changes: 9 additions & 12 deletions apt-mirror
Expand Up @@ -468,7 +468,7 @@ sub find_metadata_in_release
my ( $release_uri, $release_path, $line ) = '';
my $component_regex = undef;
my $arch_regex = "(?:${arch}|all)";
my $compressed_extension_regex = '(?:\.(?:gz|bz2|xz))?$';
my $compressed_extension_regex = '(?:\.(?:gz|bz2|xz))$';
my $dist_uri;

if (@components)
Expand Down Expand Up @@ -523,23 +523,23 @@ sub find_metadata_in_release
} else {
if (
(
$filename =~ m{^Contents-${arch_regex}${compressed_extension_regex}$}
$filename =~ m{^Contents-${arch_regex}${compressed_extension_regex}}
) or (
$filename =~ m{^Packages${compressed_extension_regex}$}
$filename =~ m{^Packages${compressed_extension_regex}}
) or (
$filename =~ m{^${component_regex}/Contents-${arch_regex}${compressed_extension_regex}$}
$filename =~ m{^${component_regex}/Contents-${arch_regex}${compressed_extension_regex}}
) or (
$filename =~ m{^${component_regex}/binary-${arch_regex}/Packages${compressed_extension_regex}$}
$filename =~ m{^${component_regex}/binary-${arch_regex}/Packages${compressed_extension_regex}}
) or (
$filename =~ m{^${component_regex}/binary-${arch_regex}/Release$}
) or (
$filename =~ m{^${component_regex}/cnf/Commands-${arch_regex}${compressed_extension_regex}$}
$filename =~ m{^${component_regex}/cnf/Commands-${arch_regex}${compressed_extension_regex}}
) or (
$filename =~ m{^${component_regex}/dep11/Components-${arch_regex}}
$filename =~ m{^${component_regex}/dep11/Components-${arch_regex}.*${compressed_extension_regex}}
) or (
$filename =~ m{^${component_regex}/dep11/icons-}
$filename =~ m{^${component_regex}/dep11/icons-.*${compressed_extension_regex}}
) or (
$filename =~ m{^${component_regex}/i18n/Translation-}
$filename =~ m{^${component_regex}/i18n/Translation-.*${compressed_extension_regex}}
)
)
{
Expand Down Expand Up @@ -906,9 +906,6 @@ foreach (@index_urls)
{
die("apt-mirror: invalid url in index_urls") unless s[^(\w+)://][];
copy_file( get_variable("skel_path") . "/" . sanitise_uri("$_"), get_variable("mirror_path") . "/" . sanitise_uri("$_") );
copy_file( get_variable("skel_path") . "/" . sanitise_uri("$_"), get_variable("mirror_path") . "/" . sanitise_uri("$_") ) if (s/\.gz$//);
copy_file( get_variable("skel_path") . "/" . sanitise_uri("$_"), get_variable("mirror_path") . "/" . sanitise_uri("$_") ) if (s/\.bz2$//);
copy_file( get_variable("skel_path") . "/" . sanitise_uri("$_"), get_variable("mirror_path") . "/" . sanitise_uri("$_") ) if (s/\.xz$//);
}

######################################################################################
Expand Down

0 comments on commit 76bd728

Please sign in to comment.