|
70 | 70 | short_version = version.split(".").first(2).join(".") |
71 | 71 | url = "https://github.com/google/or-tools/releases/download/v#{short_version}/#{filename}" |
72 | 72 |
|
73 | | -# download |
74 | | -download_path = "#{Dir.tmpdir}/#{filename}" |
75 | | -unless File.exist?(download_path) |
76 | | - puts "Downloading #{url}..." |
77 | | - IO.copy_stream(URI.parse(url).open(max_redirects: 10), download_path) |
78 | | -end |
79 | | - |
80 | | -# check integrity - do this regardless of if just downloaded |
81 | | -download_checksum = Digest::SHA256.file(download_path).hexdigest |
82 | | -raise "Bad checksum: #{download_checksum}" if download_checksum != checksum |
83 | | - |
84 | 73 | path = File.expand_path("../../tmp/or-tools", __dir__) |
85 | 74 | FileUtils.mkdir_p(path) |
86 | 75 |
|
87 | | -# extract - can't use Gem::Package#extract_tar_gz from RubyGems |
88 | | -# since it limits filenames to 100 characters (doesn't support UStar format) |
89 | | -# for space, only keep licenses, include, and shared library |
90 | 76 | Dir.mktmpdir do |extract_path| |
| 77 | + # download |
| 78 | + download_path = "#{extract_path}/#{filename}" |
| 79 | + puts "Downloading #{url}..." |
| 80 | + IO.copy_stream(URI.parse(url).open(max_redirects: 10), download_path) |
| 81 | + |
| 82 | + # check integrity |
| 83 | + download_checksum = Digest::SHA256.file(download_path).hexdigest |
| 84 | + raise "Bad checksum: #{download_checksum}" if download_checksum != checksum |
| 85 | + |
| 86 | + # extract - can't use Gem::Package#extract_tar_gz from RubyGems |
| 87 | + # since it limits filenames to 100 characters (doesn't support UStar format) |
| 88 | + # for space, only keep licenses, include, and shared library |
91 | 89 | tar_args = Gem.win_platform? ? ["--force-local"] : [] |
92 | 90 | system "tar", "zxf", download_path, "-C", extract_path, "--strip-components=1", *tar_args |
93 | 91 |
|
|
0 commit comments