Skip to content

Commit 8b4dcae

Browse files
DilumAluthge-LLMcodex
authored andcommitted
Add git-tree-{sha1,sha256} (but only for .tar.gz downloads)
Co-authored-by: OpenAI Codex GPT-5 <codex@openai.com>
1 parent cfb5c3c commit 8b4dcae

4 files changed

Lines changed: 56 additions & 16 deletions

File tree

Manifest.toml

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -2,7 +2,7 @@
22

33
julia_version = "1.10.11"
44
manifest_format = "2.0"
5-
project_hash = "55efac5eb5e37942e9cd8fef54ac706b62080e7c"
5+
project_hash = "297ab27881cec0a85c719648b28381580e85162c"
66

77
[[deps.AbstractFFTs]]
88
deps = ["LinearAlgebra"]

Project.toml

Lines changed: 1 addition & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -10,6 +10,7 @@ JSON = "682c06a0-de6a-54ab-a142-c8b1cf79cde6"
1010
Lazy = "50d2b5c4-7a5e-59d5-8109-a42b560f39c0"
1111
Pkg = "44cfe95a-1eb2-52ea-b672-e2afdf69b78f"
1212
SHA = "ea8e919c-243c-51af-8825-aaa63cd721ce"
13+
Tar = "a4e569a6-e804-4fa4-b0f3-eef7a1d5b13e"
1314
TimeZones = "f269a46b-ccf7-5d73-abea-4c690281aa53"
1415
WebCacheUtilities = "0c1c26de-fc5f-47ff-87a8-a157289a9bac"
1516

schema.json

Lines changed: 6 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -41,6 +41,12 @@
4141
"sha256": {
4242
"type": "string"
4343
},
44+
"git-tree-sha1": {
45+
"type": "string"
46+
},
47+
"git-tree-sha256": {
48+
"type": "string"
49+
},
4450
"size": {
4551
"type": "integer"
4652
},

src/VersionsJSONUtil.jl

Lines changed: 48 additions & 15 deletions
Original file line numberDiff line numberDiff line change
@@ -1,7 +1,9 @@
11
module VersionsJSONUtil
22

33
using HTTP, JSON, Pkg.BinaryPlatforms, WebCacheUtilities, SHA, Lazy
4+
using Tar: Tar
45
import Pkg.BinaryPlatforms: triplet, arch
6+
import Pkg.PlatformEngines: exe7z
57

68
"Wrapper types to define three jlext methods for portable, tarball and installer Windows"
79
struct WindowsPortable
@@ -109,6 +111,11 @@ julia_platforms = [
109111
FreeBSD(:x86_64),
110112
]
111113

114+
const tarball_git_tree_hash_skiplist = [
115+
# Corrupt gzip stream: `7z` reports a CRC failure for the embedded tarball.
116+
"https://julialang-s3.julialang.org/bin/linux/x86/0.7/julia-0.7.0-alpha-linux-i686.tar.gz",
117+
]
118+
112119
function vnum_maybe(x::AbstractString)
113120
try
114121
return VersionNumber(x)
@@ -122,6 +129,10 @@ function is_stable(v::VersionNumber)
122129
return v.prerelease == () && v.build == ()
123130
end
124131

132+
function tarball_git_tree_hash(; tarball_path::AbstractString, algorithm::AbstractString)
133+
return open(io -> Tar.tree_hash(io; algorithm), `$(exe7z()) x $tarball_path -so`)
134+
end
135+
125136
# Get list of tags from the Julia repo
126137
function get_tags()
127138
@info("Probing for tag list...")
@@ -160,6 +171,22 @@ function main(out_path)
160171
number_urls_success += 1
161172
println(stdout, "")
162173

174+
if endswith(filename, ".dmg")
175+
kind = "archive"
176+
extension = "dmg"
177+
elseif endswith(filename, ".exe")
178+
kind = "installer"
179+
extension = "exe"
180+
elseif endswith(filename, ".tar.gz")
181+
kind = "archive"
182+
extension = "tar.gz"
183+
elseif endswith(filename, ".zip")
184+
kind = "archive"
185+
extension = "zip"
186+
else
187+
error("Unsupported file extension in filename: $(filename)")
188+
end
189+
163190
tarball_hash_path = hit_file_cache("$(filename).sha256") do tarball_hash_path
164191
open(filepath, "r") do io
165192
open(tarball_hash_path, "w") do hash_io
@@ -169,6 +196,24 @@ function main(out_path)
169196
end
170197
tarball_hash = String(read(tarball_hash_path))
171198

199+
if extension == "tar.gz" && !(url in tarball_git_tree_hash_skiplist)
200+
tarball_git_tree_hashes = Dict{String, String}()
201+
tree_hash_path_sha1 = hit_file_cache("$(filename).git-tree-sha1") do tree_hash_path
202+
open(tree_hash_path, "w") do hash_io
203+
write(hash_io, tarball_git_tree_hash(; tarball_path=filepath, algorithm="git-sha1"))
204+
end
205+
end
206+
tree_hash_path_sha256 = hit_file_cache("$(filename).git-tree-sha256") do tree_hash_path
207+
open(tree_hash_path, "w") do hash_io
208+
write(hash_io, tarball_git_tree_hash(; tarball_path=filepath, algorithm="git-sha256"))
209+
end
210+
end
211+
tarball_git_tree_hashes["git-tree-sha1"] = String(read(tree_hash_path_sha1))
212+
tarball_git_tree_hashes["git-tree-sha256"] = String(read(tree_hash_path_sha256))
213+
else
214+
tarball_git_tree_hashes = nothing
215+
end
216+
172217
# Initialize overall version key, if needed
173218
if !haskey(meta, version)
174219
meta[version] = Dict(
@@ -196,21 +241,6 @@ function main(out_path)
196241
end
197242

198243
# Build up metadata about this file
199-
if endswith(filename, ".dmg")
200-
kind = "archive"
201-
extension = "dmg"
202-
elseif endswith(filename, ".exe")
203-
kind = "installer"
204-
extension = "exe"
205-
elseif endswith(filename, ".tar.gz")
206-
kind = "archive"
207-
extension = "tar.gz"
208-
elseif endswith(filename, ".zip")
209-
kind = "archive"
210-
extension = "zip"
211-
else
212-
error("Unsupported file extension in filename: $(filename)")
213-
end
214244
file_dict = Dict(
215245
"triplet" => triplet(platform),
216246
"os" => meta_os(platform),
@@ -222,6 +252,9 @@ function main(out_path)
222252
"extension" => extension,
223253
"url" => url,
224254
)
255+
if tarball_git_tree_hashes !== nothing
256+
merge!(file_dict, tarball_git_tree_hashes)
257+
end
225258
# Add in `.asc` signature content, if applicable
226259
if asc_signature !== nothing
227260
file_dict["asc"] = asc_signature

0 commit comments

Comments
 (0)