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

Commit 1b8031a

Browse files
authored
Merge pull request #192 from JuliaPackaging/mg/fix-write-deps-isolation
2 parents 332b58c + 12adfe6 commit 1b8031a

File tree

8 files changed

+224
-101
lines changed

8 files changed

+224
-101
lines changed

.cirrus.yml

Lines changed: 0 additions & 16 deletions
This file was deleted.

.travis.yml

Lines changed: 1 addition & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -3,6 +3,7 @@ language: julia
33
os:
44
- linux
55
- osx
6+
- freebsd
67
julia:
78
- 0.7
89
- 1.0

Project.toml

Lines changed: 2 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -1,9 +1,10 @@
11
name = "BinaryProvider"
22
uuid = "b99e7846-7c00-51b0-8f62-c81ae34c0232"
3-
version = "0.5.8"
3+
version = "0.5.9"
44

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

910
[compat]

src/BinaryProvider.jl

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -1,6 +1,6 @@
11
module BinaryProvider
22

3-
using Libdl
3+
using Libdl, Logging
44

55
# Utilities for controlling verbosity
66
include("LoggingUtils.jl")

src/PlatformEngines.jl

Lines changed: 178 additions & 70 deletions
Large diffs are not rendered by default.

src/Prefix.jl

Lines changed: 25 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -7,7 +7,7 @@ using SHA
77
export Prefix, bindir, libdir, includedir, logdir, activate, deactivate,
88
extract_name_version_platform_key, extract_platform_key, isinstalled,
99
install, uninstall, manifest_from_url, manifest_for_file,
10-
list_tarball_files, verify, temp_prefix, package
10+
list_tarball_files, list_tarball_symlinks, verify, temp_prefix, package
1111

1212

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

473+
"""
474+
list_tarball_symlinks(path::AbstractString; verbose::Bool = false)
475+
476+
Given a `.tar.gz` filepath, return a dictionary of symlinks in the archive
477+
"""
478+
function list_tarball_symlinks(tarball_path::AbstractString; verbose::Bool = false)
479+
if !isdefined(BinaryProvider, :gen_symlink_parser)
480+
error("Call `probe_platform_engines!()` before `list_tarball_symlinks()`")
481+
end
482+
oc = OutputCollector(gen_list_tarball_cmd(tarball_path; verbose = true); verbose = verbose)
483+
try
484+
if !wait(oc)
485+
error()
486+
end
487+
catch
488+
error("Could not list contents of tarball $(tarball_path)")
489+
end
490+
output = collect_stdout(oc)
491+
492+
mm = [m.captures for m in eachmatch(gen_symlink_parser, output)]
493+
symlinks = [m[1] => joinpath(dirname(m[1]), m[2]) for m in mm]
494+
return symlinks
495+
end
496+
473497
"""
474498
verify(path::AbstractString, hash::AbstractString;
475499
verbose::Bool = false, report_cache_status::Bool = false)

src/Products.jl

Lines changed: 11 additions & 6 deletions
Original file line numberDiff line numberDiff line change
@@ -165,7 +165,8 @@ function locate(lp::LibraryProduct; verbose::Bool = false,
165165
if platforms_match(platform, platform_key_abi())
166166
if isolate
167167
# Isolated dlopen is a lot slower, but safer
168-
if success(`$(Base.julia_cmd()) -e "import Libdl; Libdl.dlopen(\"$dl_path\")"`)
168+
dl_esc_path = replace(dl_path, "\\"=>"\\\\")
169+
if success(`$(Base.julia_cmd()) -e "import Libdl; Libdl.dlopen(\"$(dl_esc_path)\")"`)
169170
return dl_path
170171
end
171172
else
@@ -177,7 +178,11 @@ function locate(lp::LibraryProduct; verbose::Bool = false,
177178
end
178179

179180
if verbose
180-
@info("$(dl_path) cannot be dlopen'ed")
181+
try
182+
dlopen(dl_path)
183+
catch dlopen_result
184+
@info("$(dl_path) cannot be dlopen'ed",dlopen_result)
185+
end
181186
end
182187
else
183188
# If the current platform doesn't match, then just trust in our
@@ -341,7 +346,7 @@ function locate(fp::FileProduct; platform::Platform = platform_key_abi(),
341346
mappings["\$$(var)"] = string(val)
342347
mappings["\${$(var)}"] = string(val)
343348
end
344-
349+
345350
expanded = fp.path
346351
for (old, new) in mappings
347352
expanded = replace(expanded, old => new)
@@ -390,7 +395,7 @@ package load time, and if an error is discovered, package loading will fail,
390395
asking the user to re-run `Pkg.build("package_name")`.
391396
"""
392397
function write_deps_file(depsjl_path::AbstractString, products::Vector{P};
393-
verbose::Bool=false) where {P <: Product}
398+
verbose::Bool=false, isolate::Bool=true) where {P <: Product}
394399
# helper function to escape paths
395400
escape_path = path -> replace(path, "\\" => "\\\\")
396401

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

411416
# Begin by ensuring that we can satisfy every product RIGHT NOW
412417
for p in products
413-
if !satisfied(p; verbose=verbose)
418+
if !satisfied(p; verbose=verbose, isolate=isolate)
414419
error("$p is not satisfied, cannot generate deps.jl!")
415420
end
416421
end
@@ -437,7 +442,7 @@ function write_deps_file(depsjl_path::AbstractString, products::Vector{P};
437442
# Escape the location so that e.g. Windows platforms are happy with
438443
# the backslashes in a string literal
439444
product_path = locate(product, platform=platform_key_abi(),
440-
verbose=verbose)
445+
verbose=verbose, isolate=isolate)
441446
product_path = relpath(product_path, dirname(depsjl_path))
442447
product_path = escape_path(product_path)
443448
vp = variable_name(product)

test/runtests.jl

Lines changed: 6 additions & 6 deletions
Original file line numberDiff line numberDiff line change
@@ -376,7 +376,7 @@ end
376376
@test success(sh(`prefix_path_test.sh`))
377377
end
378378
end
379-
379+
380380
# Test that we can control libdir() via platform arguments
381381
@test libdir(prefix, Linux(:x86_64)) == joinpath(prefix, "lib")
382382
@test libdir(prefix, Windows(:x86_64)) == joinpath(prefix, "bin")
@@ -407,7 +407,7 @@ end
407407
bin/
408408
bin/socrates
409409
"""
410-
@test parse_tar_list(fake_tar_output) == ["bin/socrates"]
410+
@test parse_tar_list(fake_tar_output) == normpath.(["bin/socrates"])
411411

412412
end
413413

@@ -480,7 +480,7 @@ end
480480
touch(l_path)
481481
@test satisfied(l, verbose=true, platform=p)
482482
@test satisfied(l, verbose=true, platform=p, isolate=true)
483-
483+
484484
# Check LibraryProduct objects with explicit directory paths
485485
ld = LibraryProduct(libdir(prefix, p), "libfoo", :libfoo)
486486
@test satisfied(ld, verbose=true, platform=p)
@@ -820,20 +820,20 @@ end
820820

821821
@test choose_download(platforms, Linux(:x86_64)) == "linux8"
822822
@test choose_download(platforms, Linux(:x86_64, compiler_abi=CompilerABI(:gcc7))) == "linux7"
823-
823+
824824
# Ambiguity test
825825
@test choose_download(platforms, Linux(:aarch64)) == "linux5"
826826
@test choose_download(platforms, Linux(:aarch64; compiler_abi=CompilerABI(:gcc4))) == "linux5"
827827
@test choose_download(platforms, Linux(:aarch64; compiler_abi=CompilerABI(:gcc5))) == "linux5"
828828
@test choose_download(platforms, Linux(:aarch64; compiler_abi=CompilerABI(:gcc6))) == "linux5"
829829
@test choose_download(platforms, Linux(:aarch64; compiler_abi=CompilerABI(:gcc7))) == nothing
830-
830+
831831
@test choose_download(platforms, MacOS(:x86_64)) == "mac4"
832832
@test choose_download(platforms, MacOS(:x86_64, compiler_abi=CompilerABI(:gcc7))) == nothing
833833

834834
@test choose_download(platforms, Windows(:x86_64, compiler_abi=CompilerABI(:gcc_any, :cxx11))) == "win"
835835
@test choose_download(platforms, Windows(:x86_64, compiler_abi=CompilerABI(:gcc_any, :cxx03))) == nothing
836-
836+
837837
# Poor little guy
838838
@test choose_download(platforms, FreeBSD(:x86_64)) == nothing
839839
end

0 commit comments

Comments
 (0)