-
Notifications
You must be signed in to change notification settings - Fork 22
New issue
Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.
By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.
Already on GitHub? Sign in to your account
Use one artifact for each deposited GAP package #1069
Merged
Merged
Changes from 1 commit
Commits
Show all changes
2 commits
Select commit
Hold shift + click to select a range
File filter
Filter by extension
Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
There are no files selected for viewing
Large diffs are not rendered by default.
Oops, something went wrong.
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,8 @@ | ||
[deps] | ||
ArtifactUtils = "8b73e784-e7d8-4ea5-973d-377fed4e3bce" | ||
Artifacts = "56f22d72-fd6d-98f1-02f0-08ddc0907c33" | ||
Downloads = "f43a241f-c20a-4ad4-852c-f6b1247861c6" | ||
GZip = "92fee26a-97fe-5a0c-ad85-20a5f3185b63" | ||
JSON = "682c06a0-de6a-54ab-a142-c8b1cf79cde6" | ||
Pkg = "44cfe95a-1eb2-52ea-b672-e2afdf69b78f" | ||
TOML = "fa267f1f-6049-4f14-aa54-33bafae1ed76" |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,132 @@ | ||
# | ||
# This script is used to update Artifacts.toml | ||
# | ||
# Usage variants: | ||
# julia --project=etc etc/update_artifacts.jl 4.14.0 | ||
# julia --project=etc etc/update_artifacts.jl https://.../package-infos.json | ||
# julia --project=etc etc/update_artifacts.jl https://.../package-infos.json.gz | ||
# julia --project=etc etc/update_artifacts.jl local/path/package-infos.json | ||
# julia --project=etc etc/update_artifacts.jl local/path/package-infos.json.gz | ||
# | ||
|
||
using Downloads: download | ||
import Pkg | ||
using Pkg.Artifacts | ||
import Pkg.PlatformEngines | ||
#using Pkg.GitTools | ||
import GZip | ||
import JSON | ||
import TOML | ||
import SHA | ||
|
||
|
||
function sha256sum(tarball_path) | ||
return open(tarball_path, "r") do io | ||
return bytes2hex(SHA.sha256(io)) | ||
end | ||
end | ||
|
||
function add_artifacts_for_packages(; pkginfos_path::String = "package-infos.json", artifacts_toml::String="Artifacts.toml") | ||
pkgs = GZip.open(JSON.parse, pkginfos_path, "r") | ||
artifacts = TOML.parsefile(artifacts_toml) | ||
|
||
for name in sort(collect(keys(pkgs))) | ||
print("Processing '$name' ") | ||
pkginfo = pkgs[name] | ||
add_artifacts_for_package(pkginfo, artifacts) | ||
|
||
# write it all out again | ||
open(artifacts_toml, "w") do io | ||
TOML.print(io, artifacts; sorted=true) | ||
end | ||
|
||
end | ||
|
||
# delete artifacts for any packages that are no longer distributed with GAP | ||
pkg_names = ["GAP_pkg_"*lowercase(pkginfo["PackageName"]) for (name, pkginfo) in pkgs] | ||
to_be_removed = setdiff(keys(artifacts), pkg_names) | ||
for name in to_be_removed | ||
delete!(artifacts, name) | ||
end | ||
|
||
# write it all out again | ||
open(artifacts_toml, "w") do io | ||
TOML.print(io, artifacts; sorted=true) | ||
end | ||
|
||
return nothing | ||
end | ||
|
||
function add_artifacts_for_package(pkginfo, artifacts) | ||
gap_pkgname = pkginfo["PackageName"] | ||
pkgname = lowercase(gap_pkgname) | ||
artifact_name = "GAP_pkg_$(pkgname)" | ||
|
||
# | ||
# extract info about the package tarball | ||
# | ||
sha256 = pkginfo["ArchiveSHA256"] | ||
url = pkginfo["ArchiveURL"] | ||
formats = split(pkginfo["ArchiveFormats"], " ") | ||
url *= first(formats) # this matches what the PackageDistro does, and allow us to use ArchiveSHA256 | ||
url2 = "https://files.gap-system.org/pkg/" * basename(url) | ||
|
||
# check if this file is already registered | ||
if haskey(artifacts, artifact_name) | ||
downloads = artifacts[artifact_name]["download"] | ||
d = Dict("sha256" => sha256, "url" => url) | ||
if d in downloads | ||
println(" already present") | ||
d2 = Dict("sha256" => sha256, "url" => url2) | ||
if !(d2 in downloads) | ||
println(" added backup URL $(url2)") | ||
push!(downloads, d2) | ||
end | ||
return | ||
end | ||
end | ||
|
||
# add the artifact | ||
println(" importing new archive $url") | ||
tarball_path = download(url) | ||
tarball_hash = sha256sum(tarball_path) | ||
if sha256 != tarball_hash | ||
error("SHA256 mismatch for $url") | ||
end | ||
|
||
git_tree_sha1 = create_artifact() do artifact_dir | ||
Pkg.PlatformEngines.unpack(tarball_path, artifact_dir) | ||
end | ||
|
||
rm(tarball_path) | ||
#clear && remove_artifact(git_tree_sha1) | ||
|
||
artifacts[artifact_name] = Dict{String,Any}( | ||
"git-tree-sha1" => bytes2hex(git_tree_sha1.bytes), | ||
"download" => [ Dict("sha256" => sha256, "url" => url), | ||
Dict("sha256" => sha256, "url" => url2) ] | ||
) | ||
|
||
return | ||
end | ||
|
||
# https://github.com/gap-system/gap/releases/download/v4.14.0/package-infos.json.gz | ||
# https://github.com/gap-system/gap/releases/download/v4.14.0/package-infos.json.gz.sha256 | ||
|
||
if length(ARGS) > 0 | ||
desc = ARGS[1] | ||
if startswith(desc, "http") | ||
pkginfos_url = desc | ||
println("Download package-infos from $(pkginfos_url)") | ||
pkginfos_path = download(pkginfos_url) | ||
elseif startswith(desc, "4.") | ||
pkginfos_url = "https://github.com/gap-system/gap/releases/download/v$desc/package-infos.json.gz" | ||
println("Download package-infos from $(pkginfos_url)") | ||
pkginfos_path = download(pkginfos_url) | ||
else | ||
pkginfos_path = desc | ||
end | ||
|
||
println("processing $(pkginfos_path)") | ||
add_artifacts_for_packages(; pkginfos_path) | ||
end |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Oops, something went wrong.
Add this suggestion to a batch that can be applied as a single commit.
This suggestion is invalid because no changes were made to the code.
Suggestions cannot be applied while the pull request is closed.
Suggestions cannot be applied while viewing a subset of changes.
Only one suggestion per line can be applied in a batch.
Add this suggestion to a batch that can be applied as a single commit.
Applying suggestions on deleted lines is not supported.
You must change the existing code in this line in order to create a valid suggestion.
Outdated suggestions cannot be applied.
This suggestion has been applied or marked resolved.
Suggestions cannot be applied from pending reviews.
Suggestions cannot be applied on multi-line comments.
Suggestions cannot be applied while the pull request is queued to merge.
Suggestion cannot be applied right now. Please check back later.
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
IIuc this change is here to not use the same scratchspace as before as that could lead to conflicts, right? Wouldn't it make sense to either include some kind of increasing number in either the key or in the hash input, so we can bump that again for the next incompatible change in the future?
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
I actually had an intermediate version where I computed a more complicated hash, which involved the paths of the various artifacts (!) as those can also change; but also checksums of e.g.
setup.jl
and other files, but then realized this doesn't solve all the problems either...Here are some further alternatives:
atexit
handler to delete them at the end?)pkg
and there is already a dirpkg
, do nothing; but if we create a symlinkpkg
pointing totargetA
and there is instead a directorypkg
; or a symlink pointing toanotherTarget
, then deletepkg
.There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
See also #993
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
Hmm, yeah. No strong preference between 1 and 2.
But it seems that this is not immediately needed as running this PR works locally