|
1 | 1 | module Registry |
2 | 2 |
|
3 | 3 | import ..Pkg |
4 | | -using ..Pkg: depots1, printpkgstyle, stderr_f, isdir_nothrow, pathrepr, pkg_server, |
| 4 | +using ..Pkg: depots, depots1, printpkgstyle, stderr_f, isdir_nothrow, pathrepr, pkg_server, |
5 | 5 | GitTools |
6 | 6 | using ..Pkg.PlatformEngines: download_verify_unpack, download, download_verify, exe7z, verify_archive_tree_hash |
7 | 7 | using UUIDs, LibGit2, TOML, Dates |
@@ -48,11 +48,11 @@ function add(; name=nothing, uuid=nothing, url=nothing, path=nothing, linked=not |
48 | 48 | add([RegistrySpec(; name, uuid, url, path, linked)]; kwargs...) |
49 | 49 | end |
50 | 50 | end |
51 | | -function add(regs::Vector{RegistrySpec}; io::IO=stderr_f(), depot=depots1()) |
| 51 | +function add(regs::Vector{RegistrySpec}; io::IO=stderr_f(), depots::Union{String, Vector{String}}=depots()) |
52 | 52 | if isempty(regs) |
53 | | - download_default_registries(io, only_if_empty = false; depot) |
| 53 | + download_default_registries(io, only_if_empty = false; depots=depots) |
54 | 54 | else |
55 | | - download_registries(io, regs, depot) |
| 55 | + download_registries(io, regs, depots) |
56 | 56 | end |
57 | 57 | end |
58 | 58 |
|
@@ -103,20 +103,23 @@ end |
103 | 103 |
|
104 | 104 | pkg_server_url_hash(url::String) = Base.SHA1(split(url, '/')[end]) |
105 | 105 |
|
106 | | -function download_default_registries(io::IO; only_if_empty::Bool = true, depot=depots1()) |
107 | | - installed_registries = reachable_registries() |
| 106 | +function download_default_registries(io::IO; only_if_empty::Bool = true, depots::Union{String, Vector{String}}=depots()) |
| 107 | + # Check the specified depots for installed registries |
| 108 | + installed_registries = reachable_registries(; depots) |
108 | 109 | # Only clone if there are no installed registries, unless called |
109 | 110 | # with false keyword argument. |
110 | 111 | if isempty(installed_registries) || !only_if_empty |
111 | | - printpkgstyle(io, :Installing, "known registries into $(pathrepr(depot))") |
| 112 | + # Install to the first depot in the list |
| 113 | + target_depot = depots1(depots) |
| 114 | + printpkgstyle(io, :Installing, "known registries into $(pathrepr(target_depot))") |
112 | 115 | registries = copy(DEFAULT_REGISTRIES) |
113 | 116 | for uuid in keys(pkg_server_registry_urls()) |
114 | 117 | if !(uuid in (reg.uuid for reg in registries)) |
115 | 118 | push!(registries, RegistrySpec(uuid = uuid)) |
116 | 119 | end |
117 | 120 | end |
118 | 121 | filter!(reg -> !(reg.uuid in installed_registries), registries) |
119 | | - download_registries(io, registries, depot) |
| 122 | + download_registries(io, registries, depots) |
120 | 123 | return true |
121 | 124 | end |
122 | 125 | return false |
@@ -168,9 +171,11 @@ function check_registry_state(reg) |
168 | 171 | return nothing |
169 | 172 | end |
170 | 173 |
|
171 | | -function download_registries(io::IO, regs::Vector{RegistrySpec}, depot::String=depots1()) |
| 174 | +function download_registries(io::IO, regs::Vector{RegistrySpec}, depots::Union{String, Vector{String}}=depots()) |
| 175 | + # Use the first depot as the target |
| 176 | + target_depot = depots1(depots) |
172 | 177 | populate_known_registries_with_urls!(regs) |
173 | | - regdir = joinpath(depot, "registries") |
| 178 | + regdir = joinpath(target_depot, "registries") |
174 | 179 | isdir(regdir) || mkpath(regdir) |
175 | 180 | # only allow one julia process to download and install registries at a time |
176 | 181 | FileWatching.mkpidlock(joinpath(regdir, ".pid"), stale_age = 10) do |
|
0 commit comments