Skip to content

Commit 3d326d4

Browse files
committed
Handle multiple artifacts with a given os/arch in extract_artifacts.jl
1 parent 56d0e46 commit 3d326d4

File tree

1 file changed

+26
-13
lines changed

1 file changed

+26
-13
lines changed

extract_artifacts.jl

Lines changed: 26 additions & 13 deletions
Original file line numberDiff line numberDiff line change
@@ -19,22 +19,35 @@ platform = platform_key_abi()
1919
# It's possible for the artifacts to have multiple entries with the same sha1,
2020
# so group by that first
2121
sha1_to_meta = Dict{String, Vector{Tuple{String, Any}}}()
22-
for (artifact_name, value) in artifact_dict
23-
meta = artifact_meta(artifact_name, artifact_dict, artifacts_toml; platform=platform)
24-
sha1 = meta["git-tree-sha1"]
25-
26-
if !haskey(sha1_to_meta, sha1)
27-
sha1_to_meta[sha1] = []
22+
for (artifact_name, items) in artifact_dict
23+
if !isa(items, Vector)
24+
items = [items];
2825
end
2926

30-
push!(sha1_to_meta[sha1], (artifact_name, meta))
27+
# Get all possible artifacts that match our current os/arch.
28+
# If they don't specify either key, consider it a match just to be safe.
29+
for meta in items
30+
if !(
31+
!haskey(meta, "os") || meta["os"] == platform["os"]
32+
&&
33+
!haskey(meta, "arch") || meta["arch"] == platform["arch"]
34+
)
35+
continue
36+
end
37+
38+
sha1 = meta["git-tree-sha1"]
39+
if !haskey(sha1_to_meta, sha1)
40+
sha1_to_meta[sha1] = []
41+
end
42+
push!(sha1_to_meta[sha1], (artifact_name, meta))
43+
end
3144
end
3245

3346
# Print a Nix attrset where the keys are sha1 hashes and the values
3447
# are lists of "artifact infos"
3548
print("{")
3649
for (sha1, metas) in sha1_to_meta
37-
print("""\n "$sha1" = [""")
50+
print("""\n "$sha1" = [""")
3851

3952
for (index, (artifact_name, meta)) in enumerate(metas)
4053
for download in meta["download"]
@@ -44,13 +57,13 @@ for (sha1, metas) in sha1_to_meta
4457
print(" ")
4558
end
4659
print("{")
47-
print("\n name = \"$artifact_name\";")
48-
print("\n url = \"$url\";")
49-
print("\n sha256 = \"$sha256\";")
50-
print("\n }")
60+
print("\n name = \"$artifact_name\";")
61+
print("\n url = \"$url\";")
62+
print("\n sha256 = \"$sha256\";")
63+
print("\n }")
5164
end
5265
end
5366

5467
print("];")
5568
end
56-
print("\n }")
69+
print("\n}")

0 commit comments

Comments
 (0)