Skip to content

Commit acf0d35

Browse files
DilumAluthgegiordano
authored andcommitted
Use Tar_jll.jl to provide a GNU tar binary (instead of relying on the system tar)
Co-authored-by: Mosè Giordano <[email protected]>
1 parent a74624a commit acf0d35

File tree

2 files changed

+13
-2
lines changed

2 files changed

+13
-2
lines changed

Project.toml

Lines changed: 2 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -12,10 +12,12 @@ SHA = "ea8e919c-243c-51af-8825-aaa63cd721ce"
1212
Scratch = "6c6a2e73-6563-6170-7368-637461726353"
1313
TOML = "fa267f1f-6049-4f14-aa54-33bafae1ed76"
1414
Tar = "a4e569a6-e804-4fa4-b0f3-eef7a1d5b13e"
15+
Tar_jll = "9b64493d-8859-5bf3-93d7-7c32dd38186f"
1516
UserNSSandbox_jll = "b88861f7-1d72-59dd-91e7-a8cc876a4984"
1617

1718
[compat]
1819
Preferences = "1.2.1"
1920
Scratch = "1"
21+
Tar_jll = "=1.32.0"
2022
UserNSSandbox_jll = "2021.8.18"
2123
julia = "1.6"

src/Docker.jl

Lines changed: 11 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -1,4 +1,5 @@
11
using Random, Tar
2+
import Tar_jll
23

34
Base.@kwdef struct DockerExecutor <: SandboxExecutor
45
label::String = Random.randstring(10)
@@ -91,9 +92,17 @@ function build_docker_image(root_path::String, uid::Cint, gid::Cint; verbose::Bo
9192

9293
# Build the docker image
9394
open(`docker import - $(image_name)`, "w", verbose ? stdout : devnull) do io
94-
# we need to record permisions, so can't use Tar.jl
95+
# We need to record permissions, and therefore we cannot use Tar.jl.
96+
# Some systems (e.g. macOS) ship with a BSD tar that does not support the
97+
# `--owner` and `--group` command-line options. Therefore, if Tar_jll is
98+
# available, we use the GNU tar provided by Tar_jll. If Tar_jll is not available,
99+
# we fall back to the system tar.
95100
cd(root_path) do
96-
run(pipeline(`tar -c --owner=$(uid) --group=$(gid) .`, stdout=io))
101+
# tar = Tar_jll.is_available() ? Tar_jll.tar() : `tar`
102+
# run(pipeline(`$(tar) -c --owner=$(uid) --group=$(gid) .`, stdout=io))
103+
Tar_jll.tar() do tar
104+
run(pipeline(`$(tar) -c --owner=$(uid) --group=$(gid) .`, stdout=io))
105+
end
97106
end
98107
end
99108

0 commit comments

Comments
 (0)