scripts/gen_image_generic.sh: move from x86/image
[openwrt/openwrt.git] / scripts / download.pl
index ad8b837288c594eeda0287f571dd3f09c06d85d8..5c9397b93259958f6dcf534d412846566a7c137c 100755 (executable)
@@ -65,12 +65,8 @@ sub hash_cmd() {
        my $len = length($file_hash);
        my $cmd;
 
-       $len == 64 and return "openssl dgst -sha256 | sed -e 's,.*= ,,'";
-       $len == 32 and do {
-               my $cmd = which("md5sum") || which("md5") || die 'no md5 checksum program found, please install md5 or md5sum';
-               chomp $cmd;
-               return $cmd;
-       };
+       $len == 64 and return "mkhash sha256";
+       $len == 32 and return "mkhash md5";
        return undef;
 }
 
@@ -86,7 +82,7 @@ sub download_cmd($) {
        }
 
        return $have_curl
-               ? (qw(curl --connect-timeout 20 --retry 5 --location --insecure), shellwords($ENV{CURL_OPTIONS} || ''), $url)
+               ? (qw(curl -f --connect-timeout 20 --retry 5 --location --insecure), shellwords($ENV{CURL_OPTIONS} || ''), $url)
                : (qw(wget --tries=5 --timeout=20 --no-check-certificate --output-document=-), shellwords($ENV{WGET_OPTIONS} || ''), $url)
        ;
 }
@@ -143,6 +139,7 @@ sub download
                };
        } else {
                my @cmd = download_cmd("$mirror/$url_filename");
+               print STDERR "+ ".join(" ",@cmd)."\n";
                open(FETCH_FD, '-|', @cmd) or die "Cannot launch curl or wget.\n";
                $hash_cmd and do {
                        open MD5SUM, "| $hash_cmd > '$target/$filename.hash'" or die "Cannot launch $hash_cmd.\n";
@@ -170,7 +167,7 @@ sub download
                $sum = $1;
 
                if ($sum ne $file_hash) {
-                       print STDERR "MD5 sum of the downloaded file does not match (file: $sum, requested: $file_hash) - deleting download.\n";
+                       print STDERR "Hash of the downloaded file does not match (file: $sum, requested: $file_hash) - deleting download.\n";
                        cleanup();
                        return;
                }