Skip to content

Commit

Permalink
Merge pull request #29 from JuliaPackaging/sk/Tar.jl
Browse files Browse the repository at this point in the history
  • Loading branch information
staticfloat authored Apr 28, 2020
2 parents a6a43ac + 77f2105 commit dab0c1d
Show file tree
Hide file tree
Showing 3 changed files with 25 additions and 45 deletions.
28 changes: 17 additions & 11 deletions Manifest.toml
Original file line number Diff line number Diff line change
Expand Up @@ -3,12 +3,6 @@
[[Base64]]
uuid = "2a0f44e3-6c83-55bd-87e4-b1978d98bd5f"

[[BinaryProvider]]
deps = ["Libdl", "SHA"]
git-tree-sha1 = "5b08ed6036d9d3f0ee6369410b830f8873d4024c"
uuid = "b99e7846-7c00-51b0-8f62-c81ae34c0232"
version = "0.5.8"

[[Dates]]
deps = ["Printf"]
uuid = "ade2ca70-3891-5945-98fb-dc099432e06a"
Expand All @@ -19,9 +13,9 @@ uuid = "8ba89e20-285c-5b6f-9357-94700520ee1b"

[[HTTP]]
deps = ["Base64", "Dates", "IniFile", "MbedTLS", "Sockets"]
git-tree-sha1 = "5c49dab19938b119fe204fd7d7e8e174f4e9c68b"
git-tree-sha1 = "fe31f4ff144392ad8176f5c7c03cca6ba320271c"
uuid = "cd3eb016-35fb-5094-929b-558a96fad6f3"
version = "0.8.8"
version = "0.8.14"

[[IniFile]]
deps = ["Test"]
Expand All @@ -34,6 +28,7 @@ deps = ["Markdown"]
uuid = "b77e0a4c-d291-57a0-90e8-8db25a27a240"

[[LibGit2]]
deps = ["Printf"]
uuid = "76f85450-5226-5b5a-8eaa-529ad045b433"

[[Libdl]]
Expand All @@ -47,10 +42,16 @@ deps = ["Base64"]
uuid = "d6f4376e-aef5-505a-96c1-9c027394607a"

[[MbedTLS]]
deps = ["BinaryProvider", "Dates", "Libdl", "Random", "Sockets"]
git-tree-sha1 = "85f5947b53c8cfd53ccfa3f4abae31faa22c2181"
deps = ["Dates", "MbedTLS_jll", "Random", "Sockets"]
git-tree-sha1 = "426a6978b03a97ceb7ead77775a1da066343ec6e"
uuid = "739be429-bea8-5141-9913-cc70e7f3736d"
version = "0.7.0"
version = "1.0.2"

[[MbedTLS_jll]]
deps = ["Libdl", "Pkg"]
git-tree-sha1 = "c83f5a1d038f034ad0549f9ee4d5fac3fb429e33"
uuid = "c8ffd9c3-330d-5841-b78e-0817d7145fa1"
version = "2.16.0+2"

[[Pkg]]
deps = ["Dates", "LibGit2", "Libdl", "Logging", "Markdown", "Printf", "REPL", "Random", "SHA", "UUIDs"]
Expand All @@ -77,6 +78,11 @@ uuid = "9e88b42a-f829-5b0c-bbe9-9e923198166b"
[[Sockets]]
uuid = "6462fe0b-24de-5631-8697-dd941f90decc"

[[Tar]]
git-tree-sha1 = "eaee2dba5f1f91c17e8a80d13303b1f236fea2f3"
uuid = "a4e569a6-e804-4fa4-b0f3-eef7a1d5b13e"
version = "1.3.0"

[[Test]]
deps = ["Distributed", "InteractiveUtils", "Logging", "Random"]
uuid = "8dfed614-e22c-5e08-85e1-65c5234f0b40"
Expand Down
1 change: 1 addition & 0 deletions Project.toml
Original file line number Diff line number Diff line change
Expand Up @@ -8,6 +8,7 @@ HTTP = "cd3eb016-35fb-5094-929b-558a96fad6f3"
LibGit2 = "76f85450-5226-5b5a-8eaa-529ad045b433"
Pkg = "44cfe95a-1eb2-52ea-b672-e2afdf69b78f"
Random = "9a3f8284-a2c9-5f02-9a11-845980a1fd5c"
Tar = "a4e569a6-e804-4fa4-b0f3-eef7a1d5b13e"

[compat]
HTTP = "0.8"
Expand Down
41 changes: 7 additions & 34 deletions bin/gen_static.jl
Original file line number Diff line number Diff line change
Expand Up @@ -10,26 +10,11 @@ import Pkg
import Pkg.TOML
import Pkg.Artifacts: download_artifact, artifact_path
import LibGit2

# TODO: ensure all registries are git clones
Pkg.update()
import Tar

mkpath(clones_dir)
mkpath(static_dir)

const tar_opts = ```
--format=posix
--numeric-owner
--owner=0
--group=0
--mode=go-w,+X
--mtime=1970-01-01
--pax-option=exthdr.name=%d/PaxHeaders/%f,delete=atime,delete=ctime,delete=mtime
--no-recursion
```
# reproducible tarball options based on
# http://h2.jaguarpaw.co.uk/posts/reproducible-tar/

const compress = `gzip -9`
const decompress = `gzcat`

Expand All @@ -43,25 +28,11 @@ function make_tarball(
tarball::AbstractString,
tree_path::AbstractString,
)
paths = String[]
for (root, dirs, files) in walkdir(tree_path)
path = root != tree_path ? relpath(root, tree_path) : ""
for file in [dirs; files]
push!(paths, joinpath(path, file))
open(tarball, write=true) do io
open(pipeline(compress, io), write=true) do io
Tar.create(tree_path, io)
end
end
sort!(paths)
mktemp() do paths_file, io
for path in paths
print(io, "$path\0")
end
close(io)
open(tarball, write=true) do io
tar_cmd = `gtar $tar_opts -cf - -C $tree_path --null -T $paths_file`
run(pipeline(tar_cmd, compress, io))
end
end
return
end

function create_git_tarball(
Expand Down Expand Up @@ -94,7 +65,9 @@ function verify_tarball_hash(
)
local hash
mktempdir() do tmp_dir
run(pipeline(`$decompress $tarball`, `tar -C $tmp_dir -x`))
open(pipeline(tarball, decompress)) do io
Tar.extract(io, tmp_dir)
end
hash = bytes2hex(Pkg.GitTools.tree_hash(tmp_dir))
chmod(tmp_dir, 0o777, recursive=true)
end
Expand Down

0 comments on commit dab0c1d

Please sign in to comment.