Skip to content
This repository has been archived by the owner on Aug 16, 2023. It is now read-only.

Commit

Permalink
Merge pull request #192 from JuliaPackaging/mg/fix-write-deps-isolation
Browse files Browse the repository at this point in the history
  • Loading branch information
giordano authored Apr 29, 2020
2 parents 332b58c + 12adfe6 commit 1b8031a
Show file tree
Hide file tree
Showing 8 changed files with 224 additions and 101 deletions.
16 changes: 0 additions & 16 deletions .cirrus.yml

This file was deleted.

1 change: 1 addition & 0 deletions .travis.yml
Original file line number Diff line number Diff line change
Expand Up @@ -3,6 +3,7 @@ language: julia
os:
- linux
- osx
- freebsd
julia:
- 0.7
- 1.0
Expand Down
3 changes: 2 additions & 1 deletion Project.toml
Original file line number Diff line number Diff line change
@@ -1,9 +1,10 @@
name = "BinaryProvider"
uuid = "b99e7846-7c00-51b0-8f62-c81ae34c0232"
version = "0.5.8"
version = "0.5.9"

[deps]
Libdl = "8f399da3-3557-5675-b5ff-fb832c97cbdb"
Logging = "56ddb016-857b-54e1-b83d-db4d58db5568"
SHA = "ea8e919c-243c-51af-8825-aaa63cd721ce"

[compat]
Expand Down
2 changes: 1 addition & 1 deletion src/BinaryProvider.jl
Original file line number Diff line number Diff line change
@@ -1,6 +1,6 @@
module BinaryProvider

using Libdl
using Libdl, Logging

# Utilities for controlling verbosity
include("LoggingUtils.jl")
Expand Down
248 changes: 178 additions & 70 deletions src/PlatformEngines.jl

Large diffs are not rendered by default.

26 changes: 25 additions & 1 deletion src/Prefix.jl
Original file line number Diff line number Diff line change
Expand Up @@ -7,7 +7,7 @@ using SHA
export Prefix, bindir, libdir, includedir, logdir, activate, deactivate,
extract_name_version_platform_key, extract_platform_key, isinstalled,
install, uninstall, manifest_from_url, manifest_for_file,
list_tarball_files, verify, temp_prefix, package
list_tarball_files, list_tarball_symlinks, verify, temp_prefix, package


# Temporary hack around https://github.com/JuliaLang/julia/issues/26685
Expand Down Expand Up @@ -470,6 +470,30 @@ function list_tarball_files(path::AbstractString; verbose::Bool = false)
return parse_tarball_listing(collect_stdout(oc))
end

"""
list_tarball_symlinks(path::AbstractString; verbose::Bool = false)
Given a `.tar.gz` filepath, return a dictionary of symlinks in the archive
"""
function list_tarball_symlinks(tarball_path::AbstractString; verbose::Bool = false)
if !isdefined(BinaryProvider, :gen_symlink_parser)
error("Call `probe_platform_engines!()` before `list_tarball_symlinks()`")
end
oc = OutputCollector(gen_list_tarball_cmd(tarball_path; verbose = true); verbose = verbose)
try
if !wait(oc)
error()
end
catch
error("Could not list contents of tarball $(tarball_path)")
end
output = collect_stdout(oc)

mm = [m.captures for m in eachmatch(gen_symlink_parser, output)]
symlinks = [m[1] => joinpath(dirname(m[1]), m[2]) for m in mm]
return symlinks
end

"""
verify(path::AbstractString, hash::AbstractString;
verbose::Bool = false, report_cache_status::Bool = false)
Expand Down
17 changes: 11 additions & 6 deletions src/Products.jl
Original file line number Diff line number Diff line change
Expand Up @@ -165,7 +165,8 @@ function locate(lp::LibraryProduct; verbose::Bool = false,
if platforms_match(platform, platform_key_abi())
if isolate
# Isolated dlopen is a lot slower, but safer
if success(`$(Base.julia_cmd()) -e "import Libdl; Libdl.dlopen(\"$dl_path\")"`)
dl_esc_path = replace(dl_path, "\\"=>"\\\\")
if success(`$(Base.julia_cmd()) -e "import Libdl; Libdl.dlopen(\"$(dl_esc_path)\")"`)
return dl_path
end
else
Expand All @@ -177,7 +178,11 @@ function locate(lp::LibraryProduct; verbose::Bool = false,
end

if verbose
@info("$(dl_path) cannot be dlopen'ed")
try
dlopen(dl_path)
catch dlopen_result
@info("$(dl_path) cannot be dlopen'ed",dlopen_result)
end
end
else
# If the current platform doesn't match, then just trust in our
Expand Down Expand Up @@ -341,7 +346,7 @@ function locate(fp::FileProduct; platform::Platform = platform_key_abi(),
mappings["\$$(var)"] = string(val)
mappings["\${$(var)}"] = string(val)
end

expanded = fp.path
for (old, new) in mappings
expanded = replace(expanded, old => new)
Expand Down Expand Up @@ -390,7 +395,7 @@ package load time, and if an error is discovered, package loading will fail,
asking the user to re-run `Pkg.build("package_name")`.
"""
function write_deps_file(depsjl_path::AbstractString, products::Vector{P};
verbose::Bool=false) where {P <: Product}
verbose::Bool=false, isolate::Bool=true) where {P <: Product}
# helper function to escape paths
escape_path = path -> replace(path, "\\" => "\\\\")

Expand All @@ -410,7 +415,7 @@ function write_deps_file(depsjl_path::AbstractString, products::Vector{P};

# Begin by ensuring that we can satisfy every product RIGHT NOW
for p in products
if !satisfied(p; verbose=verbose)
if !satisfied(p; verbose=verbose, isolate=isolate)
error("$p is not satisfied, cannot generate deps.jl!")
end
end
Expand All @@ -437,7 +442,7 @@ function write_deps_file(depsjl_path::AbstractString, products::Vector{P};
# Escape the location so that e.g. Windows platforms are happy with
# the backslashes in a string literal
product_path = locate(product, platform=platform_key_abi(),
verbose=verbose)
verbose=verbose, isolate=isolate)
product_path = relpath(product_path, dirname(depsjl_path))
product_path = escape_path(product_path)
vp = variable_name(product)
Expand Down
12 changes: 6 additions & 6 deletions test/runtests.jl
Original file line number Diff line number Diff line change
Expand Up @@ -376,7 +376,7 @@ end
@test success(sh(`prefix_path_test.sh`))
end
end

# Test that we can control libdir() via platform arguments
@test libdir(prefix, Linux(:x86_64)) == joinpath(prefix, "lib")
@test libdir(prefix, Windows(:x86_64)) == joinpath(prefix, "bin")
Expand Down Expand Up @@ -407,7 +407,7 @@ end
bin/
bin/socrates
"""
@test parse_tar_list(fake_tar_output) == ["bin/socrates"]
@test parse_tar_list(fake_tar_output) == normpath.(["bin/socrates"])

end

Expand Down Expand Up @@ -480,7 +480,7 @@ end
touch(l_path)
@test satisfied(l, verbose=true, platform=p)
@test satisfied(l, verbose=true, platform=p, isolate=true)

# Check LibraryProduct objects with explicit directory paths
ld = LibraryProduct(libdir(prefix, p), "libfoo", :libfoo)
@test satisfied(ld, verbose=true, platform=p)
Expand Down Expand Up @@ -820,20 +820,20 @@ end

@test choose_download(platforms, Linux(:x86_64)) == "linux8"
@test choose_download(platforms, Linux(:x86_64, compiler_abi=CompilerABI(:gcc7))) == "linux7"

# Ambiguity test
@test choose_download(platforms, Linux(:aarch64)) == "linux5"
@test choose_download(platforms, Linux(:aarch64; compiler_abi=CompilerABI(:gcc4))) == "linux5"
@test choose_download(platforms, Linux(:aarch64; compiler_abi=CompilerABI(:gcc5))) == "linux5"
@test choose_download(platforms, Linux(:aarch64; compiler_abi=CompilerABI(:gcc6))) == "linux5"
@test choose_download(platforms, Linux(:aarch64; compiler_abi=CompilerABI(:gcc7))) == nothing

@test choose_download(platforms, MacOS(:x86_64)) == "mac4"
@test choose_download(platforms, MacOS(:x86_64, compiler_abi=CompilerABI(:gcc7))) == nothing

@test choose_download(platforms, Windows(:x86_64, compiler_abi=CompilerABI(:gcc_any, :cxx11))) == "win"
@test choose_download(platforms, Windows(:x86_64, compiler_abi=CompilerABI(:gcc_any, :cxx03))) == nothing

# Poor little guy
@test choose_download(platforms, FreeBSD(:x86_64)) == nothing
end
Expand Down

2 comments on commit 1b8031a

@giordano
Copy link
Member Author

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

@JuliaRegistrator
Copy link

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Registration pull request created: JuliaRegistries/General/13874

After the above pull request is merged, it is recommended that a tag is created on this repository for the registered package version.

This will be done automatically if the Julia TagBot GitHub Action is installed, or can be done manually through the github interface, or via:

git tag -a v0.5.9 -m "<description of version>" 1b8031aaa59cc1069dcf154b71a3b529e25360f5
git push origin v0.5.9

Please sign in to comment.