Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

Workaround for symlink-unfriendly filesystems #7

Closed
wants to merge 1 commit into from
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
33 changes: 32 additions & 1 deletion deps/build.jl
Original file line number Diff line number Diff line change
Expand Up @@ -12,10 +12,35 @@ else
binary_name = "cmake"
end

function probe_symlink_creation(dest::AbstractString)
while !isdir(dest)
dest = dirname(dest)
end

# Build arbitrary (non-existent) file path name
link_path = joinpath(dest, "binaryprovider_symlink_test")
while ispath(link_path)
link_path *= "1"
end

try
symlink("foo", link_path)
return true
catch e
if isa(e, Base.IOError)
return false
end
rethrow(e)
finally
rm(link_path; force=true)
end
end

function install_binaries(file_base, file_ext, binary_dir)
filename = "$(file_base).$(file_ext)"
url = "$(base_url)/$(filename)"
binary_path = joinpath(basedir, "downloads", file_base, binary_dir)
copyderef = get(ENV, "BINARYPROVIDER_COPYDEREF", "") == "true" || !probe_symlink_creation(binary_path)

@static if Sys.iswindows()
install_step = () -> begin
Expand All @@ -28,8 +53,14 @@ function install_binaries(file_base, file_ext, binary_dir)
else
install_step = () -> begin
for file in readdir(binary_path)
symlink(joinpath(binary_path, file),
if !copyderef
symlink(joinpath(binary_path, file),
joinpath(prefix, "bin", file))
else
cp(joinpath(binary_path, file),
joinpath(prefix, "bin", file);
force=true)
end
end
end
end
Expand Down