Skip to content

Commit cefaeb3

Browse files
committed
[Prefix] Use bzip2, gzip, tar, xz and zstd from JLLs
1 parent 24a5009 commit cefaeb3

File tree

2 files changed

+37
-1
lines changed

2 files changed

+37
-1
lines changed

Project.toml

Lines changed: 7 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -4,10 +4,13 @@ authors = ["Elliot Saba <staticfloat@gmail.com>"]
44
version = "1.20.0"
55

66
[deps]
7+
Bzip2_jll = "6e34b625-4abd-537c-b88f-471c36dfa7a0"
78
CodecZlib = "944b1d66-785c-5afd-91f1-9de20f533193"
89
Downloads = "f43a241f-c20a-4ad4-852c-f6b1247861c6"
10+
Gzip_jll = "be1be57a-8558-53c3-a7e5-50095f79957e"
911
HistoricalStdlibVersions = "6df8b67a-e8a0-4029-b4b7-ac196fe72102"
1012
InteractiveUtils = "b77e0a4c-d291-57a0-90e8-8db25a27a240"
13+
JLLWrappers = "692b3bcd-3c85-4b1f-b108-f13ce0eb3210"
1114
JSON = "682c06a0-de6a-54ab-a142-c8b1cf79cde6"
1215
LibGit2 = "76f85450-5226-5b5a-8eaa-529ad045b433"
1316
LibGit2_jll = "e37daf67-58a4-590a-8e99-b0245dd2ffc5"
@@ -23,13 +26,17 @@ Scratch = "6c6a2e73-6563-6170-7368-637461726353"
2326
SimpleBufferStream = "777ac1f9-54b0-4bf8-805c-2214025038e7"
2427
TOML = "fa267f1f-6049-4f14-aa54-33bafae1ed76"
2528
Tar = "a4e569a6-e804-4fa4-b0f3-eef7a1d5b13e"
29+
Tar_jll = "9b64493d-8859-5bf3-93d7-7c32dd38186f"
2630
UUIDs = "cf7118a7-6976-5b1a-9a39-7adc72f591a4"
31+
XZ_jll = "ffd25f8a-64ca-5728-b0f7-c24cf3aae800"
32+
Zstd_jll = "3161d3a3-bdf6-5164-811a-617609db77b4"
2733
p7zip_jll = "3f19e933-33d8-53b3-aaab-bd5110c3b7a0"
2834
pigz_jll = "1bc43ea1-30af-5bc8-a9d4-c018457e6e3e"
2935

3036
[compat]
3137
CodecZlib = "0.5, 0.6, 0.7"
3238
HistoricalStdlibVersions = "0.1, 1"
39+
JLLWrappers = "1.4"
3340
JSON = "0.21"
3441
OrderedCollections = "1.4.1"
3542
OutputCollectors = "0.1"

src/Prefix.jl

Lines changed: 30 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -3,6 +3,8 @@
33
# environment variables must be updated to, etc...
44
import Base: convert, joinpath, show
55
using SHA, CodecZlib, TOML, LibGit2_jll
6+
import Bzip2_jll, Gzip_jll, Tar_jll, XZ_jll, Zstd_jll
7+
using JLLWrappers: pathsep, LIBPATH_env
68

79
export Prefix, bindir, libdirs, includedir, logdir, temp_prefix, package
810

@@ -300,7 +302,34 @@ function setup(source::SetupSource{ArchiveSource}, targetdir, verbose; tar_flags
300302
if verbose
301303
@info "Extracting tarball $(basename(source.path))..."
302304
end
303-
run(`tar -$(tar_flags) $(source.path)`)
305+
tar = Tar_jll.is_available() ? Tar_jll.tar() : `tar`
306+
# Add gzip, bzip2 & Co. to PATH.
307+
path = split(get(ENV, "PATH", ""), pathsep)
308+
libpath = split(get(ENV, LIBPATH_env, ""), pathsep)
309+
if Tar_jll.is_available()
310+
libpath = vcat(Tar_jll.LIBPATH_list, libpath)
311+
end
312+
if Bzip2_jll.is_available()
313+
path = vcat(joinpath(Bzip2_jll.artifact_dir, "bin"), path)
314+
libpath = vcat(Bzip2_jll.LIBPATH_list, libpath)
315+
end
316+
if Gzip_jll.is_available()
317+
path = vcat(dirname(Gzip_jll.gzip_path), path)
318+
libpath = vcat(Gzip_jll.LIBPATH_list, libpath)
319+
end
320+
if XZ_jll.is_available()
321+
path = vcat(dirname(XZ_jll.xz_path), path)
322+
libpath = vcat(XZ_jll.LIBPATH_list, libpath)
323+
end
324+
if Zstd_jll.is_available()
325+
path = vcat(dirname(Zstd_jll.zstd_path), path)
326+
libpath = vcat(XZ_jll.LIBPATH_list, libpath)
327+
end
328+
unique!(filter!(!isempty, path))
329+
unique!(filter!(!isempty, libpath))
330+
tar = addenv(tar, "PATH" => join(path, pathsep), LIBPATH_env => join(libpath, pathsep))
331+
# Unpack the tarball
332+
run(`$(tar) -$(tar_flags) $(source.path)`)
304333
elseif endswith(source.path, ".zip")
305334
if verbose
306335
@info "Extracting zipball $(basename(source.path))..."

0 commit comments

Comments
 (0)