diff mbox series

[LEDE-DEV,1/2] scripts/download.pl: Add a --skip-hash option

Message ID 20171026095059.6592-1-git@bitsofnetworks.org
State Superseded
Delegated to: John Crispin
Headers show
Series [LEDE-DEV,1/2] scripts/download.pl: Add a --skip-hash option | expand

Commit Message

Baptiste Jonglez Oct. 26, 2017, 9:50 a.m. UTC
When the new "--skip-hash" option is passed to scripts/download.pl, hash
verification of the downloaded files is completely skipped.  This can be
useful when bumping package version, since the hash may not be known in
advance.

Signed-off-by: Baptiste Jonglez <git@bitsofnetworks.org>
---
 scripts/download.pl | 13 ++++++++++---
 1 file changed, 10 insertions(+), 3 deletions(-)

Comments

Stijn Tintel Nov. 29, 2017, 7:22 p.m. UTC | #1
On 26-10-17 11:50, Baptiste Jonglez wrote:
> When the new "--skip-hash" option is passed to scripts/download.pl, hash
> verification of the downloaded files is completely skipped.  This can be
> useful when bumping package version, since the hash may not be known in
> advance.
>
>
Acked-by: Stijn Tintel <stijn@linux-ipv6.be>
diff mbox series

Patch

diff --git a/scripts/download.pl b/scripts/download.pl
index 775408934a..e0bf187559 100755
--- a/scripts/download.pl
+++ b/scripts/download.pl
@@ -13,9 +13,11 @@  use File::Basename;
 use File::Copy;
 use Text::ParseWords;
 
-@ARGV > 2 or die "Syntax: $0 <target dir> <filename> <hash> <url filename> [<mirror> ...]\n";
+@ARGV > 2 or die "Syntax: $0 [--skip-hash] <target dir> <filename> <hash> <url filename> [<mirror> ...]\n";
 
 my $url_filename;
+my $skip_hash = 0;
+$skip_hash = shift @ARGV if $ARGV[0] eq "--skip-hash";
 my $target = glob(shift @ARGV);
 my $filename = shift @ARGV;
 my $file_hash = shift @ARGV;
@@ -87,8 +89,13 @@  sub download_cmd($) {
 	;
 }
 
-my $hash_cmd = hash_cmd();
-$hash_cmd or die "Cannot find appropriate hash command, ensure the provided hash is either a MD5 or SHA256 checksum.\n";
+my $hash_cmd;
+if ($skip_hash) {
+	print("Warning: skipping hash verification as requested.\n");
+} else {
+	$hash_cmd = hash_cmd();
+	$hash_cmd or die "Cannot find appropriate hash command, ensure the provided hash is either a MD5 or SHA256 checksum.\n";
+}
 
 sub download
 {