summaryrefslogtreecommitdiff
path: root/solenv/bin/download_external_dependencies.pl
diff options
context:
space:
mode:
Diffstat (limited to 'solenv/bin/download_external_dependencies.pl')
-rwxr-xr-xsolenv/bin/download_external_dependencies.pl29
1 files changed, 18 insertions, 11 deletions
diff --git a/solenv/bin/download_external_dependencies.pl b/solenv/bin/download_external_dependencies.pl
index 0939635e0036..1854f78df974 100755
--- a/solenv/bin/download_external_dependencies.pl
+++ b/solenv/bin/download_external_dependencies.pl
@@ -159,11 +159,7 @@ sub ProcessLastBlock ()
my $name = GetValue('name');
my $checksum = GetChecksum();
- if ( ! defined $checksum)
- {
- die "no checksum given for $name";
- }
- elsif ( ! IsPresent($name, $checksum))
+ if ( ! IsPresent($name, $checksum))
{
AddDownloadRequest($name, $checksum);
}
@@ -263,7 +259,7 @@ sub SubstituteVariables ($)
{
my ($head,$name,$tail) = ($1,$2,$3);
my $value = GetValue($name);
- die "can evaluate variable $name" if ! defined $value;
+ die "can not evaluate variable $name" if ! defined $value;
$text = $head.$value.$tail;
die "(probably) detected an infinite recursion in variable definitions" if --$infinite_recursion_guard<=0;
@@ -387,7 +383,12 @@ sub IsPresent ($$)
# File exists. Check if its checksum is correct.
my $checksum;
- if ($given_checksum->{'type'} eq "MD5")
+ if ( ! defined $given_checksum)
+ {
+ print "no checksum given, can not verify\n";
+ return 1;
+ }
+ elsif ($given_checksum->{'type'} eq "MD5")
{
my $md5 = Digest::MD5->new();
open my $in, $filename;
@@ -410,7 +411,7 @@ sub IsPresent ($$)
{
# Checksum does not match. Delete the file.
print "$name exists, but checksum does not match => deleting\n";
- #unlink($filename);
+ unlink($filename);
return 0;
}
else
@@ -455,7 +456,12 @@ sub Download ()
foreach my $url (@$urls)
{
- last if DownloadFile($checksum->{'value'}."-".$name, $url, $checksum);
+ last if DownloadFile(
+ defined $checksum
+ ? $checksum->{'value'}."-".$name
+ : $name,
+ $url,
+ $checksum);
}
}
}
@@ -480,7 +486,8 @@ sub DownloadFile ($$$)
my $temporary_filename = $filename . ".part";
print "downloading to $temporary_filename\n";
- open my $out, ">$temporary_filename";
+ my $out;
+ open $out, ">$temporary_filename";
binmode($out);
# Prepare checksum
@@ -516,7 +523,7 @@ sub DownloadFile ($$$)
{
$last_was_redirect = 0;
# Throw away the data we got so far.
- $checksum->reset();
+ $digest->reset();
close $out;
open $out, ">$temporary_filename";
binmode($out);