Skip to content
Closed
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
19 changes: 13 additions & 6 deletions src/utils.jl
Original file line number Diff line number Diff line change
Expand Up @@ -80,7 +80,7 @@ function isinmanifest end
tree_hash(pe) = get(pe[1], "git-tree-sha1", nothing)

frommanifest(c::Pkg.Types.Context, uuid) = frommanifest(c.env.manifest, uuid)

function frommanifest(manifest::Dict{String,Any}, uuid)
for p in values(manifest)
if get(first(p), "uuid", "") == string(uuid)
Expand All @@ -107,7 +107,7 @@ else
end
packageuuid(pkg::Pair{String,UUID}) = last(pkg)
packageuuid(pkg::Pair{UUID,PackageEntry}) = first(pkg)

packagename(pkg::Pair{UUID,PackageEntry})::String = last(pkg).name
packagename(c::Pkg.Types.Context, uuid::UUID) = manifest(c)[uuid].name
packagename(manifest::Dict{UUID,PackageEntry}, uuid::UUID) = manifest[uuid].name
Expand All @@ -127,9 +127,16 @@ else
version(pe::Pair{UUID,PackageEntry}) = last(pe).version
frommanifest(c::Pkg.Types.Context, uuid) = manifest(c)[uuid]
frommanifest(manifest::Dict{UUID,PackageEntry}, uuid) = manifest[uuid]

tree_hash(pe::PackageEntry) = VERSION >= v"1.3" ? pe.tree_hash : get(pe.other, "git-tree-sha1", nothing)

is_package_deved(manifest, uuid) = manifest[uuid].path !== nothing

@static if !(Pkg.Types.Manifest <: Dict)
frommanifest(manifest::Pkg.Types.Manifest, uuid) = frommanifest(manifest.deps, uuid)
packagename(manifest::Pkg.Types.Manifest, uuid::UUID) = packagename(manifest.deps, uuid)
isinmanifest(manifest::Pkg.Types.Manifest, uuid::UUID) = isinmanifest(manifest.deps, uuid)
end
end

function sha2_256_dir(path, sha=zeros(UInt8, 32))
Expand Down Expand Up @@ -413,7 +420,7 @@ end


pkg_src_dir(m::Module) = dirname(pathof(m))



# replace s1 with s2 at the start of a string
Expand Down Expand Up @@ -485,7 +492,7 @@ function validate_disc_store(store_path, manifest)
filter(manifest) do pkg
uuid = packageuuid(pkg)
file_name = joinpath(get_cache_path(manifest, uuid)...)
!isfile(joinpath(store_path, file_name)) && !endswith(file_name, "_jll.jstore")
!isfile(joinpath(store_path, file_name)) && !endswith(file_name, "_jll.jstore")
end
end

Expand All @@ -497,7 +504,7 @@ Find out where a package is installed without having to load it.
function get_pkg_path(pkg::Base.PkgId, env, depot_path)
project_file = Base.env_project_file(env)
manifest_file = Base.project_file_manifest_path(project_file)

d = Base.parsed_toml(manifest_file)
entries = get(d, pkg.name, nothing)::Union{Nothing, Vector{Any}}
entries === nothing && return nothing # TODO: allow name to mismatch?
Expand Down Expand Up @@ -571,7 +578,7 @@ function get_cache_path(manifest, uuid)
ver = replace(string(ver), '+'=>'_')
th = tree_hash(pkg_info)
th = th === nothing ? "nothing" : th

[
string(uppercase(string(name)[1]))
string(name, "_", uuid)
Expand Down