diff options
author | Mikko Pesari <mikko.pesari@aalto.fi> | 2016-02-20 15:54:31 +0300 |
---|---|---|
committer | Benjamin Drung <benjamin.drung@profitbricks.com> | 2016-11-08 19:18:34 +0300 |
commit | a489c6d61f39bc9cf426e1d868be7fd71fabd3f5 (patch) | |
tree | 61eea7ccf03daf3dd37aae2f3fb864d32c3e612f | |
parent | 861e6acfb1c6a9eb93bb9677d0e6cbf4f583a1cb (diff) |
Download DEP-11 files in component/dep11 directories
Look in the Release file to select files relevant only for selected
architectures.
fixes #56
LP: #1550852
Signed-off-by: Benjamin Drung <benjamin.drung@profitbricks.com>
-rwxr-xr-x | apt-mirror | 91 |
1 files changed, 91 insertions, 0 deletions
@@ -617,6 +617,97 @@ foreach ( keys %urls_to_download ) } ###################################################################################### +## DEP-11 index download + +%urls_to_download = (); + +sub find_dep11_files_in_release +{ + # Look in the dists/$DIST/Release file for the DEP-11 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 = <STREAM> ) + { + chomp $line; + if ($checksums) + { + if ( $line =~ /^ +(.*)$/ ) + { + my @parts = split( / +/, $1 ); + if ( @parts == 3 ) + { + my ( $sha1, $size, $filename ) = @parts; + if ( $filename =~ m{^$component/dep11/(Components-${arch}\.yml|icons-[^./]+\.tar)\.gz$} ) + { + add_url_to_download( $dist_uri . $filename, $size ); + } + } + else + { + warn("Malformed checksum line \"$1\" in $release_uri"); + } + } + else + { + $checksums = 0; + } + } + if ( not $checksums ) + { + if ( $line eq "SHA256:" ) + { + $checksums = 1; + } + } + } +} + +print "Processing DEP-11 indexes: ["; + +foreach (@config_binaries) +{ + my ( $arch, $uri, $distribution, @components ) = @{$_}; + print "D"; + if (@components) + { + $url = $uri . "/dists/" . $distribution . "/"; + + my $component; + foreach $component (@components) + { + find_dep11_files_in_release( $url, $component, $arch ); + } + } +} + +print "]\n\n"; + +push( @index_urls, sort keys %urls_to_download ); +download_urls( "dep11", sort keys %urls_to_download ); + +foreach ( keys %urls_to_download ) +{ + s[^(\w+)://][]; + s[~][%7E]g if get_variable("_tilde"); + $skipclean{$_} = 1; +} + +###################################################################################### ## Main download preparations %urls_to_download = (); |