diff --git a/Project.toml b/Project.toml index 7575450..c3812f5 100644 --- a/Project.toml +++ b/Project.toml @@ -4,10 +4,12 @@ license = "MIT" version = "0.6.2" [deps] +CodecZlib = "944b1d66-785c-5afd-91f1-9de20f533193" Compat = "34da2185-b29b-5c13-b0c7-acf172513d20" Pkg = "44cfe95a-1eb2-52ea-b672-e2afdf69b78f" REPL = "3fa0cd96-eef1-5676-8a61-b3b8758bbffb" TOML = "fa267f1f-6049-4f14-aa54-33bafae1ed76" +Tar = "a4e569a6-e804-4fa4-b0f3-eef7a1d5b13e" UUIDs = "cf7118a7-6976-5b1a-9a39-7adc72f591a4" [compat] diff --git a/src/PkgDeps.jl b/src/PkgDeps.jl index aa7fed7..6bfa49b 100644 --- a/src/PkgDeps.jl +++ b/src/PkgDeps.jl @@ -6,6 +6,8 @@ using REPL using TOML: parsefile using UUIDs using Compat +import Tar +using CodecZlib: GzipDecompressorStream export PkgEntry, RegistryInstance export NoUUIDMatch, PackageNotInRegistry @@ -53,14 +55,27 @@ function reachable_registries( for d in depots isdir(d) || continue - reg_dir = joinpath(d, "registries") - isdir(reg_dir) || continue - - for name in readdir(reg_dir) - if isempty(registry_names) || name in registry_names - file = joinpath(reg_dir, name, "Registry.toml") - isfile(file) || continue - push!(registries, RegistryInstance(joinpath(reg_dir, name))) + registries_dir = joinpath(d, "registries") + isdir(registries_dir) || continue + + for file_name in readdir(registries_dir) + if isdir(registries_dir, file_name) + registry_name = file_name + registry_path = joinpath(registries_dir, registry_name) + elseif endswith(file_name, ".tar.gz") + registry_name = chop(file_name, tail = length(".tar.gz")) + + # We need to unpack the registry into a temporary directory. + registry_path = open(joinpath(registries_dir, file_name)) do io + Tar.extract(GzipDecompressorStream(io)) + end + else + continue + end + + if isempty(registry_names) || registry_name in registry_names + isfile(registry_path, "Registry.toml") || continue + push!(registries, RegistryInstance(registry_path)) end end end