From 67f7da6249eed6d1fde800f96bc331435e713540 Mon Sep 17 00:00:00 2001 From: Franky Van Liedekerke Date: Thu, 6 Feb 2020 16:39:04 +0100 Subject: Support the by-hash/SHA256 dirs --- apt-mirror | 93 ++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++ 1 file changed, 93 insertions(+) diff --git a/apt-mirror b/apt-mirror index effac7e..389dca6 100755 --- a/apt-mirror +++ b/apt-mirror @@ -721,6 +721,99 @@ foreach ( keys %urls_to_download ) $skipclean{$_} = 1; } +###################################################################################### +## by-hash SHA256 files download + +%urls_to_download = (); + +sub find_by_hash_sha256_files_in_release +{ + # Look in the dists/$DIST/Release file for the by-hash SHA256 files that belong + # to the given component and architecture. + + my $dist_uri = shift; + my $component = shift; + my $arch = shift; + my ( $release_uri, $release_path, $line ) = ''; + + $release_uri = $dist_uri . "Release"; + $release_path = get_variable("skel_path") . "/" . sanitise_uri($release_uri); + + unless ( open STREAM, "<$release_path" ) + { + warn( "Failed to open Release file from " . $release_uri ); + return; + } + + my $checksums = 0; + while ( $line = ) + { + chomp $line; + if ($checksums) + { + if ( $line =~ /^ +(.*)$/ ) + { + my @parts = split( / +/, $1 ); + if ( @parts == 3 ) + { + my ( $sha256, $size, $filename ) = @parts; + my $dirname = dirname($filename); + my $sha256_filename = '/'.$dirname.'/by-hash/SHA256/'.$sha256; + { + add_url_to_download( $dist_uri . $sha256_filename ); + } + } + else + { + warn("Malformed checksum line \"$1\" in $release_uri"); + } + } + else + { + $checksums = 0; + } + } + if ( not $checksums ) + { + if ( $line eq "SHA256:" ) + { + $checksums = 1; + } + } + } +} + +print "Processing SHA256 by-hash files [" + if $progress; + +foreach (@config_binaries) +{ + my ( $arch, $uri, $distribution, @components ) = @{$_}; + print "D" if $progress; + if (@components) + { + $url = $uri . "/dists/" . $distribution . "/"; + + my $component; + foreach $component (@components) + { + find_by_hash_sha256_files_in_release( $url, $component, $arch ); + } + } +} + +print "]\n\n" if $progress; + +push( @index_urls, sort keys %urls_to_download ); +download_urls( "by-hash-SHA256", sort keys %urls_to_download ); + +foreach ( keys %urls_to_download ) +{ + s[^(\w+)://][]; + s[~][%7E]g if get_variable("_tilde"); + $skipclean{$_} = 1; +} + ###################################################################################### ## Main download preparations -- cgit v1.2.3 From a55ea4024344a6a8fcc36c520e48be2ce3039980 Mon Sep 17 00:00:00 2001 From: Franky Van Liedekerke Date: Mon, 9 May 2022 21:22:24 +0200 Subject: remove use of progress var remove use of progress var --- apt-mirror | 7 +++---- 1 file changed, 3 insertions(+), 4 deletions(-) diff --git a/apt-mirror b/apt-mirror index 389dca6..cd1f32c 100755 --- a/apt-mirror +++ b/apt-mirror @@ -783,13 +783,12 @@ sub find_by_hash_sha256_files_in_release } } -print "Processing SHA256 by-hash files [" - if $progress; +print "Processing SHA256 by-hash files ["; foreach (@config_binaries) { my ( $arch, $uri, $distribution, @components ) = @{$_}; - print "D" if $progress; + print "D"; if (@components) { $url = $uri . "/dists/" . $distribution . "/"; @@ -802,7 +801,7 @@ foreach (@config_binaries) } } -print "]\n\n" if $progress; +print "]\n\n"; push( @index_urls, sort keys %urls_to_download ); download_urls( "by-hash-SHA256", sort keys %urls_to_download ); -- cgit v1.2.3