diff options
author | Andreas Guldstrand <andreas.guldstrand@gmail.com> | 2015-12-03 01:39:28 +0100 |
---|---|---|
committer | Andreas Guldstrand <andreas.guldstrand@gmail.com> | 2015-12-03 01:39:28 +0100 |
commit | eeb7a259c1d924246e39730d948d142321b2d0da (patch) | |
tree | 0656e04c1f7fa992c5d15b995434259cb39bec67 | |
parent | 69dbea2bd7a7efd3003016d88c497c529ced5820 (diff) | |
download | sbotools2-eeb7a259c1d924246e39730d948d142321b2d0da.tar.xz |
Use sbosrcarch if a download fails
This should solve #7 but further testing is warranted
-rw-r--r-- | SBO-Lib/lib/SBO/Lib.pm | 28 |
1 files changed, 24 insertions, 4 deletions
diff --git a/SBO-Lib/lib/SBO/Lib.pm b/SBO-Lib/lib/SBO/Lib.pm index 8d22ecd..b5d1bc3 100644 --- a/SBO-Lib/lib/SBO/Lib.pm +++ b/SBO-Lib/lib/SBO/Lib.pm @@ -509,12 +509,32 @@ sub get_distfile { mkdir $distfiles unless -d $distfiles; chdir $distfiles; unlink $filename if -f $filename; + my $fail = {}; + + # if wget $link && verify, return + # else wget sbosrcarch && verify if (system('wget', '--no-check-certificate', $link) != 0) { - return "Unable to wget $link.\n", _ERR_DOWNLOAD; + $fail->{msg} = "Unable to wget $link.\n"; + $fail->{err} = _ERR_DOWNLOAD; + } + return 1 if not %$fail and verify_distfile(@_); + if (not %$fail) { + $fail->{msg} = "md5sum failure for $filename.\n"; + $fail->{err} = _ERR_MD5SUM; } - # can't do anything if the link in the .info doesn't lead to a good d/l - verify_distfile(@_) ? return 1 : return "md5sum failure for $filename.\n", - _ERR_MD5SUM; + + # since the download from the original link either didn't download or + # didn't verify, try to get it from sbosrcarch instead + unlink $filename if -f $filename; + my $sbosrcarch = sprintf( + "ftp://ftp.slackware.org.uk/sbosrcarch/by-md5/%s/%s/%s/%s", + substr($info_md5, 0, 1), substr($info_md5, 1, 1), $info_md5, $filename); + + return 1 if + system('wget', '--no-check-certificate', $sbosrcarch) == 0 and + verify_distfile(@_); + + return $fail->{msg}, $fail->{err}; } # for a given distfile, figure out what the full path to its symlink will be |