Skip to content
Merged
Show file tree
Hide file tree
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
2 changes: 2 additions & 0 deletions Project.toml
Original file line number Diff line number Diff line change
Expand Up @@ -20,6 +20,7 @@ OrderedCollections = "bac558e1-5e72-5ebc-8fee-abe8a469f55d"
OutputCollectors = "6c11c7d4-943b-4e2b-80de-f2cfc2930a8c"
Pkg = "44cfe95a-1eb2-52ea-b672-e2afdf69b78f"
Printf = "de0858da-6303-5e67-8744-51eddeeeb8d7"
RegistryInstances = "2792f1a3-b283-48e8-9a74-f99dce5104f3"
ProgressMeter = "92933f4c-e287-5a05-a399-4b506db050ca"
REPL = "3fa0cd96-eef1-5676-8a61-b3b8758bbffb"
Random = "9a3f8284-a2c9-5f02-9a11-845980a1fd5c"
Expand Down Expand Up @@ -56,6 +57,7 @@ Printf = "1.7"
ProgressMeter = "1"
REPL = "1.7"
Random = "1.7"
RegistryInstances = "0.1"
SHA = "0.7, 1"
Scratch = "1.0"
SimpleBufferStream = "1"
Expand Down
1 change: 1 addition & 0 deletions src/BinaryBuilderBase.jl
Original file line number Diff line number Diff line change
Expand Up @@ -5,6 +5,7 @@ using Base.BinaryPlatforms
using Downloads
using JSON, OutputCollectors, Scratch
import HistoricalStdlibVersions
using RegistryInstances: reachable_registries, registry_info, uuids_from_name

# Re-export useful stuff from Base.BinaryPlatforms:
export HostPlatform, platform_dlext, valid_dl_path, arch, libc,
Expand Down
26 changes: 20 additions & 6 deletions src/Prefix.jl
Original file line number Diff line number Diff line change
Expand Up @@ -597,23 +597,37 @@ Given a JLL name and registered version, return a `PackageSpec` that, when passe
]
"""
function get_addable_spec(name::AbstractString, version::VersionNumber;
ctx = Pkg.Types.Context(), verbose::Bool = false)
verbose::Bool = false)
@debug "Getting addable spec" name version
# Zeroth, update the registry
update_registry(verbose ? stdout : devnull)

# Get registries using RegistryInstances
registries = reachable_registries()

# First, resolve the UUID
uuid = first(Pkg.Types.registry_resolve!(ctx.registries, Pkg.Types.PackageSpec(;name))).uuid
uuid = nothing
for reg in registries
uuids = uuids_from_name(reg, name)
if !isempty(uuids)
uuid = first(uuids)
break
end
end
if uuid === nothing
error("Unable to find package $name in any registry")
end
@debug "Resolved UUID" name uuid

# Next, determine the tree hash from the registry
repo_urls = Set{String}()
tree_hashes = Set{Base.SHA1}()
for reg in ctx.registries
for reg in registries
if !haskey(reg, uuid)
continue
end

pkg_info = registry_info(reg, reg[uuid])
pkg_info = registry_info(reg[uuid])
if pkg_info.repo !== nothing
push!(repo_urls, pkg_info.repo)
end
Expand All @@ -630,7 +644,7 @@ function get_addable_spec(name::AbstractString, version::VersionNumber;
@error("Unable to find dependency!",
name,
version,
registries=ctx.registries,
registries,
)
error("Unable to find dependency!")
end
Expand All @@ -639,7 +653,7 @@ function get_addable_spec(name::AbstractString, version::VersionNumber;
name,
version,
tree_hashes,
registries=ctx.registries,
registries,
)
error("Multiple treehashes found!")
end
Expand Down
13 changes: 0 additions & 13 deletions src/compat.jl
Original file line number Diff line number Diff line change
Expand Up @@ -29,16 +29,3 @@ if !isdefined(Pkg.Types, :stdlib_version)
else
const stdlib_version = Pkg.Types.stdlib_version
end

if isdefined(Pkg, :Registry) && isdefined(Pkg.Registry, :registry_info)
const _Pkg_registry_info = Pkg.Registry.registry_info
elseif isdefined(Pkg, :RegistryHandling) && isdefined(Pkg.RegistryHandling, :registry_info)
const _Pkg_registry_info = Pkg.RegistryHandling.registry_info
end

# Handle Pkg.jl signature change: registry_info(pkg) -> registry_info(registry, pkg)
if @isdefined(_Pkg_registry_info) && hasmethod(_Pkg_registry_info, Tuple{Pkg.Registry.PkgEntry})
registry_info(::Pkg.Registry.RegistryInstance, pkg::Pkg.Registry.PkgEntry) = _Pkg_registry_info(pkg)
else
const registry_info = _Pkg_registry_info
end