57
58
59
60
61
62
63
64
65
66
67
68
69
70
71
72
73
74
75
76
77
78
79
80
81
82
83
84
85
86
87
88
89
90
91
92
93
94
|
# File 'lib/conan/repository.rb', line 57
def self.download(url, target_file, download_file_name, sha1_hash)
not_shasum = ->(file) {
ret = true
if (File.exists?(file))
found_hash = Digest::SHA1.file(file).hexdigest
puts "Found: #{found_hash}, Want: #{sha1_hash}"
if (found_hash != sha1_hash)
puts "#{file} is not the file we're looking for. It has a SHA1 hash of #{found_hash}, but #{sha1_hash} is expected"
ret = true
else
puts "#{file} matches checksum"
ret = false
end
end
ret
}
if (not_shasum.call(target_file))
tmp = File.join(Dir.tmpdir(), "nexus-app-manifest")
FileUtils.mkdir_p tmp
download_file = File.join(tmp, download_file_name)
if (not_shasum.call(download_file))
puts "Fetching artifact #{download_file_name}"
puts " #{url}"
puts "..."
wget_cmd = "wget -nv \"#{url}\" --content-disposition --no-use-server-timestamps --output-document \"#{download_file}\""
puts wget_cmd
system( wget_cmd )
raise "Failed to download #{download_file_name}" if not_shasum.call(download_file)
end
puts "cp #{download_file} to #{target_file}"
FileUtils.mkdir_p File.dirname(target_file)
FileUtils.copy(download_file, target_file)
end
end
|