Skip to content

Commit f40d2e9

Browse files
committed
Support registries in gzipped tarballs
Starting with Julia 1.7, a registry can also be stored in a depot as a gzipped tarball. This commit unpacks the tarball into a temporary directory. This was the simplest way to support this new feature. This implementation will unpack a fresh copy of the registry on every call to `reachable_registries`. We could instead cache the temporary directory for future calls. There's an open PR for the Tar.jl package that will be of future interest: JuliaIO/Tar.jl#95 This would allow us to instead stream the individual files straight out of the tarball, rather than having to unpack it into a temporary location.
1 parent a568954 commit f40d2e9

File tree

2 files changed

+25
-8
lines changed

2 files changed

+25
-8
lines changed

Project.toml

Lines changed: 2 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -4,10 +4,12 @@ license = "MIT"
44
version = "0.6.2"
55

66
[deps]
7+
CodecZlib = "944b1d66-785c-5afd-91f1-9de20f533193"
78
Compat = "34da2185-b29b-5c13-b0c7-acf172513d20"
89
Pkg = "44cfe95a-1eb2-52ea-b672-e2afdf69b78f"
910
REPL = "3fa0cd96-eef1-5676-8a61-b3b8758bbffb"
1011
TOML = "fa267f1f-6049-4f14-aa54-33bafae1ed76"
12+
Tar = "a4e569a6-e804-4fa4-b0f3-eef7a1d5b13e"
1113
UUIDs = "cf7118a7-6976-5b1a-9a39-7adc72f591a4"
1214

1315
[compat]

src/PkgDeps.jl

Lines changed: 23 additions & 8 deletions
Original file line numberDiff line numberDiff line change
@@ -6,6 +6,8 @@ using REPL
66
using TOML: parsefile
77
using UUIDs
88
using Compat
9+
import Tar
10+
using CodecZlib: GzipDecompressorStream
911

1012
export PkgEntry, RegistryInstance
1113
export NoUUIDMatch, PackageNotInRegistry
@@ -53,14 +55,27 @@ function reachable_registries(
5355

5456
for d in depots
5557
isdir(d) || continue
56-
reg_dir = joinpath(d, "registries")
57-
isdir(reg_dir) || continue
58-
59-
for name in readdir(reg_dir)
60-
if isempty(registry_names) || name in registry_names
61-
file = joinpath(reg_dir, name, "Registry.toml")
62-
isfile(file) || continue
63-
push!(registries, RegistryInstance(joinpath(reg_dir, name)))
58+
registries_dir = joinpath(d, "registries")
59+
isdir(registries_dir) || continue
60+
61+
for file_name in readdir(registries_dir)
62+
if isdir(registries_dir, file_name)
63+
registry_name = file_name
64+
registry_path = joinpath(registries_dir, registry_name)
65+
elseif endswith(file_name, ".tar.gz")
66+
registry_name = chop(file_name, tail = length(".tar.gz"))
67+
68+
# We need to unpack the registry into a temporary directory.
69+
registry_path = open(joinpath(registries_dir, file_name)) do io
70+
Tar.extract(GzipDecompressorStream(io))
71+
end
72+
else
73+
continue
74+
end
75+
76+
if isempty(registry_names) || registry_name in registry_names
77+
isfile(registry_path, "Registry.toml") || continue
78+
push!(registries, RegistryInstance(registry_path))
6479
end
6580
end
6681
end

0 commit comments

Comments
 (0)