@@ -21,9 +21,11 @@ sleepcmd = `sleep`
2121lscmd = ` ls`
2222havebb = false
2323
24+ busybox_hash_correct (file) = bytes2ex (open (SHA. sha256, file)) == " ed2f95da9555268e93c7af52feb48e148534ee518b9128f65dda9a2767b61b9e"
25+
2426function _tryonce_download_from_cache (desired_url:: AbstractString )
2527 cache_url = " https://cache.julialang.org/$(desired_url) "
26- cache_output_filename = joinpath (mktempdir (), " myfile " )
28+ cache_output_filename = joinpath (mktempdir (), " busybox " * (Sys . iswindows () ? " .exe " : " " ) )
2729 cache_response = Downloads. request (
2830 cache_url;
2931 output = cache_output_filename,
@@ -32,9 +34,14 @@ function _tryonce_download_from_cache(desired_url::AbstractString)
3234 )
3335 if cache_response isa Downloads. Response
3436 if Downloads. status_ok (cache_response. proto, cache_response. status)
35- return cache_output_filename
37+ if busybox_hash_correct (cache_output_filename)
38+ return cache_output_filename
39+ else
40+ @warn " The busybox executable downloaded from the cache has an incorrect hash" cache_output_filename bytes2hex (open (SHA. sha256, cache_output_filename))
41+ end
3642 end
3743 end
44+ @warn " Could not download from cache at $cache_url , falling back to primary source at $desired_url "
3845 return Downloads. download (desired_url; timeout = 60 )
3946end
4047
@@ -46,7 +53,11 @@ function download_from_cache(desired_url::AbstractString)
4653end
4754
4855if Sys. iswindows ()
49- busybox = download_from_cache (" https://frippery.org/files/busybox/busybox.exe" )
56+ # See https://frippery.org/files/busybox/
57+ # latest as of 2024-09-20 18:08
58+ busybox = download_from_cache (" https://frippery.org/files/busybox/busybox-w32-FRP-5467-g9376eebd8.exe" )
59+ busybox_hash_correct (busybox) || error (" The busybox executable downloaded has an incorrect hash" )
60+
5061 havebb = try # use busybox-w32 on windows, if available
5162 success (` $busybox ` )
5263 true
0 commit comments