Skip to content

Commit

Permalink
scripts/download.pl: fix downloads with wget
Browse files Browse the repository at this point in the history
Several users of wget for downloads (curl is not available in the
system) have reported broken download functionality:

 wget --tries=5 --timeout=20 --output-document=-  https://cdn.kernel.org/pub/linux/kernel/v5.x/linux-5.10.142.tar.xz
 http://: Invalid host name.

Thats all happening due to '' was passed as an argument, which got later
expanded to http://.

In the context of a list constructor '' is not nothing, it is an empty
string element.  So fix it by using () as it will yield "nothing" and
thus not introduce an empty string element.

Fixes: coolsnowwolf#10692
Fixes: 90c6e3a ("scripts: always check certificates")
Signed-off-by: Jo-Philipp Wich <[email protected]> [shellwords() -> ()]
Signed-off-by: Petr Štetiar <[email protected]>
  • Loading branch information
ynezz authored and aiamadeus committed Sep 27, 2022
1 parent 62b20da commit 331a9f6
Showing 1 changed file with 8 additions and 2 deletions.
10 changes: 8 additions & 2 deletions scripts/download.pl
Original file line number Diff line number Diff line change
Expand Up @@ -84,8 +84,14 @@ ($)
}

return $have_curl
? (qw(curl -f --connect-timeout 20 --retry 5 --location), $check_certificate ? '' : '--insecure', shellwords($ENV{CURL_OPTIONS} || ''), $url)
: (qw(wget --tries=5 --timeout=20 --output-document=-), $check_certificate ? '' : '--no-check-certificate', shellwords($ENV{WGET_OPTIONS} || ''), $url)
? (qw(curl -f --connect-timeout 20 --retry 5 --location),
$check_certificate ? () : '--insecure',
shellwords($ENV{CURL_OPTIONS} || ''),
$url)
: (qw(wget --tries=5 --timeout=20 --output-document=-),
$check_certificate ? () : '--no-check-certificate',
shellwords($ENV{WGET_OPTIONS} || ''),
$url)
;
}

Expand Down

0 comments on commit 331a9f6

Please sign in to comment.