Skip to content

Commit 2365e03

Browse files
authored
Use pigz to create archives (#107)
1 parent c91148e commit 2365e03

File tree

4 files changed

+48
-10
lines changed

4 files changed

+48
-10
lines changed

Manifest.toml

Lines changed: 14 additions & 8 deletions
Original file line numberDiff line numberDiff line change
@@ -28,9 +28,9 @@ deps = ["Markdown"]
2828
uuid = "b77e0a4c-d291-57a0-90e8-8db25a27a240"
2929

3030
[[JLLWrappers]]
31-
git-tree-sha1 = "7cec881362e5b4e367ff0279dd99a06526d51a55"
31+
git-tree-sha1 = "a431f5f2ca3f4feef3bd7a5e94b8b8d4f2f647a0"
3232
uuid = "692b3bcd-3c85-4b1f-b108-f13ce0eb3210"
33-
version = "1.1.2"
33+
version = "1.2.0"
3434

3535
[[JSON]]
3636
deps = ["Dates", "Mmap", "Parsers", "Unicode"]
@@ -47,7 +47,7 @@ deps = ["Libdl"]
4747
uuid = "deac9b47-8bc7-5906-a0fe-35ac56dc84c0"
4848

4949
[[LibGit2]]
50-
deps = ["Printf"]
50+
deps = ["Base64", "NetworkOptions", "Printf", "SHA"]
5151
uuid = "76f85450-5226-5b5a-8eaa-529ad045b433"
5252

5353
[[Libdl]]
@@ -75,10 +75,10 @@ uuid = "6c11c7d4-943b-4e2b-80de-f2cfc2930a8c"
7575
version = "0.1.0"
7676

7777
[[Parsers]]
78-
deps = ["Dates", "Test"]
79-
git-tree-sha1 = "8077624b3c450b15c087944363606a6ba12f925e"
78+
deps = ["Dates"]
79+
git-tree-sha1 = "50c9a9ed8c714945e01cd53a21007ed3865ed714"
8080
uuid = "69de0a69-1ddd-5017-9359-2bf0b02dc9f0"
81-
version = "1.0.10"
81+
version = "1.0.15"
8282

8383
[[Pkg]]
8484
deps = ["Artifacts", "Dates", "Downloads", "LibGit2", "Libdl", "Logging", "Markdown", "Printf", "REPL", "Random", "SHA", "Serialization", "TOML", "Tar", "UUIDs"]
@@ -137,12 +137,18 @@ uuid = "4ec0a83e-493e-50e2-b9ac-8f72acf5a8f5"
137137

138138
[[Zlib_jll]]
139139
deps = ["Artifacts", "JLLWrappers", "Libdl", "Pkg"]
140-
git-tree-sha1 = "320228915c8debb12cb434c59057290f0834dbf6"
140+
git-tree-sha1 = "32085929ad61a5ed99abea288ec7242be392bb8b"
141141
uuid = "83775a58-1f1d-513f-b197-d71354ab007a"
142-
version = "1.2.11+18"
142+
version = "1.2.12+0"
143143

144144
[[p7zip_jll]]
145145
deps = ["Artifacts", "JLLWrappers", "Libdl", "Pkg"]
146146
git-tree-sha1 = "ee65cfa19bea645698a0224bfa216f2b1c8b559f"
147147
uuid = "3f19e933-33d8-53b3-aaab-bd5110c3b7a0"
148148
version = "16.2.0+3"
149+
150+
[[pigz_jll]]
151+
deps = ["Artifacts", "JLLWrappers", "Libdl", "Pkg", "Zlib_jll"]
152+
git-tree-sha1 = "8c379a72c82099ceb4be53f4f427690376279052"
153+
uuid = "1bc43ea1-30af-5bc8-a9d4-c018457e6e3e"
154+
version = "2.5.0+0"

Project.toml

Lines changed: 1 addition & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -20,6 +20,7 @@ TOML = "fa267f1f-6049-4f14-aa54-33bafae1ed76"
2020
Tar = "a4e569a6-e804-4fa4-b0f3-eef7a1d5b13e"
2121
UUIDs = "cf7118a7-6976-5b1a-9a39-7adc72f591a4"
2222
p7zip_jll = "3f19e933-33d8-53b3-aaab-bd5110c3b7a0"
23+
pigz_jll = "1bc43ea1-30af-5bc8-a9d4-c018457e6e3e"
2324

2425
[compat]
2526
CodecZlib = "0.5, 0.6, 0.7"

src/ArchiveUtils.jl

Lines changed: 32 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -1,4 +1,6 @@
1-
using Downloads, Tar, p7zip_jll, SimpleBufferStream, SHA
1+
using Base: SHA1
2+
using Downloads, Tar, p7zip_jll, pigz_jll, SimpleBufferStream, SHA
3+
using Pkg.Artifacts: artifact_exists, artifact_path, query_override
24

35
export unpack, list_tarball_files, verify, download_verify
46

@@ -146,3 +148,32 @@ function download_verify(url, hash, path)
146148
verify(path, hash) || error("Verification failed")
147149
end
148150
end
151+
152+
# Stripped down copy of `Pkg.Artifacts.archive_artifact` that supports a custom `package`
153+
# function
154+
function _archive_artifact(hash::SHA1, tarball_path::String;
155+
honor_overrides::Bool=false,
156+
package::Function=_package_fast)
157+
158+
if !artifact_exists(hash)
159+
error("Unable to archive artifact $(bytes2hex(hash.bytes)): does not exist!")
160+
end
161+
162+
# Package it up
163+
package(artifact_path(hash), tarball_path)
164+
165+
# Calculate its sha256 and return that
166+
return open(tarball_path, "r") do io
167+
return bytes2hex(sha256(io))
168+
end
169+
end
170+
171+
# Copy of `Pkg.PlatformEngines.package` but using `pigz` instead of `7z`
172+
function _package_fast(src_dir::AbstractString, tarball_path::AbstractString)
173+
rm(tarball_path, force=true)
174+
pigz() do pigz_exe
175+
open(pipeline(`$pigz_exe -9`, stdout=tarball_path), write=true) do io
176+
Tar.create(src_dir, io)
177+
end
178+
end
179+
end

src/Prefix.jl

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -173,7 +173,7 @@ function package(prefix::Prefix,
173173
@info("Tree hash of contents of $(basename(out_path)): $(tree_hash)")
174174
end
175175

176-
tarball_hash = archive_artifact(tree_hash, out_path; honor_overrides=false)
176+
tarball_hash = _archive_artifact(tree_hash, out_path; honor_overrides=false)
177177
if verbose
178178
@info("SHA256 of $(basename(out_path)): $(tarball_hash)")
179179
end

0 commit comments

Comments
 (0)