Skip to content

Commit

Permalink
Handle multiple artifacts with a given os/arch in extract_artifacts.jl
Browse files Browse the repository at this point in the history
  • Loading branch information
thomasjm committed Nov 29, 2022
1 parent 56d0e46 commit 3d326d4
Showing 1 changed file with 26 additions and 13 deletions.
39 changes: 26 additions & 13 deletions extract_artifacts.jl
Original file line number Diff line number Diff line change
Expand Up @@ -19,22 +19,35 @@ platform = platform_key_abi()
# It's possible for the artifacts to have multiple entries with the same sha1,
# so group by that first
sha1_to_meta = Dict{String, Vector{Tuple{String, Any}}}()
for (artifact_name, value) in artifact_dict
meta = artifact_meta(artifact_name, artifact_dict, artifacts_toml; platform=platform)
sha1 = meta["git-tree-sha1"]

if !haskey(sha1_to_meta, sha1)
sha1_to_meta[sha1] = []
for (artifact_name, items) in artifact_dict
if !isa(items, Vector)
items = [items];
end

push!(sha1_to_meta[sha1], (artifact_name, meta))
# Get all possible artifacts that match our current os/arch.
# If they don't specify either key, consider it a match just to be safe.
for meta in items
if !(
!haskey(meta, "os") || meta["os"] == platform["os"]
&&
!haskey(meta, "arch") || meta["arch"] == platform["arch"]
)
continue
end

sha1 = meta["git-tree-sha1"]
if !haskey(sha1_to_meta, sha1)
sha1_to_meta[sha1] = []
end
push!(sha1_to_meta[sha1], (artifact_name, meta))
end
end

# Print a Nix attrset where the keys are sha1 hashes and the values
# are lists of "artifact infos"
print("{")
for (sha1, metas) in sha1_to_meta
print("""\n "$sha1" = [""")
print("""\n "$sha1" = [""")

for (index, (artifact_name, meta)) in enumerate(metas)
for download in meta["download"]
Expand All @@ -44,13 +57,13 @@ for (sha1, metas) in sha1_to_meta
print(" ")
end
print("{")
print("\n name = \"$artifact_name\";")
print("\n url = \"$url\";")
print("\n sha256 = \"$sha256\";")
print("\n }")
print("\n name = \"$artifact_name\";")
print("\n url = \"$url\";")
print("\n sha256 = \"$sha256\";")
print("\n }")
end
end

print("];")
end
print("\n }")
print("\n}")

0 comments on commit 3d326d4

Please sign in to comment.