Skip to content

Commit 8f84f3a

Browse files
authored
Fix some issues reported on Slack (#243)
* Fix `FileSource` incorrectly trying to replace `srcdir` Sometimes, a user tries to download a file that is an archive but it accidentally gets seen as a `FileSource` due to our imperfect archive detection. Rather than erroring out here with a bad `cp()` invocation, automatically plop the file into `srcdir`, and allow the build to continue. * Check `path` instead of `url` for `archive_extensions` This allows us to perform a bit of URL cleaning to drop things like `?raw=true` at the end of URLs from GitHub, for instance. Best to check the given destination path name, rather than the original URL name. * Update sources.jl
1 parent 4b21cde commit 8f84f3a

File tree

3 files changed

+8
-5
lines changed

3 files changed

+8
-5
lines changed

src/Prefix.jl

Lines changed: 3 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -297,6 +297,9 @@ function setup(source::SetupSource{ArchiveSource}, targetdir, verbose; tar_flags
297297
end
298298

299299
function setup(source::SetupSource{FileSource}, target, verbose)
300+
if isdir(target)
301+
target = joinpath(target, basename(source.path))
302+
end
300303
if verbose
301304
@info "Copying $(basename(source.path)) in $(basename(target))..."
302305
end

src/Sources.jl

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -114,7 +114,7 @@ SetupSource{T}(path::String, hash::String, target::String) where {T} =
114114
function SetupSource(url::String, path::String, hash::String, target::String)
115115
if endswith(url, ".git")
116116
return SetupSource{GitSource}(path, hash, target)
117-
elseif any(endswith(url, ext) for ext in archive_extensions)
117+
elseif any(endswith(path, ext) for ext in archive_extensions)
118118
return SetupSource{ArchiveSource}(path, hash, target)
119119
else
120120
return SetupSource{FileSource}(path, hash, target)

test/sources.jl

Lines changed: 4 additions & 4 deletions
Original file line numberDiff line numberDiff line change
@@ -11,10 +11,10 @@ using JSON
1111
@test FileSource("https://curl.haxx.se/ca/cacert-2020-01-01.pem", "adf770dfd574a0d6026bfaa270cb6879b063957177a991d453ff1d302c02081f").filename == "cacert-2020-01-01.pem"
1212
@test FileSource("https://curl.haxx.se/ca/cacert-2020-01-01.pem", "adf770dfd574a0d6026bfaa270cb6879b063957177a991d453ff1d302c02081f"; filename="cacert.pem").filename == "cacert.pem"
1313

14-
@test SetupSource("https://ftp.gnu.org/gnu/wget/wget-1.20.3.tar.gz", "", "", "") isa SetupSource{ArchiveSource}
15-
@test SetupSource("https://ftp.gnu.org/gnu/wget/wget-1.20.3.zip", "", "", "") isa SetupSource{ArchiveSource}
16-
@test SetupSource("https://github.com/jedisct1/libsodium.git", "", "", "") isa SetupSource{GitSource}
17-
@test SetupSource("https://curl.haxx.se/ca/cacert-2020-01-01.pem", "", "", "") isa SetupSource{FileSource}
14+
@test SetupSource("https://ftp.gnu.org/gnu/wget/wget-1.20.3.tar.gz", "wget-1.20.3.tar.gz", "", "") isa SetupSource{ArchiveSource}
15+
@test SetupSource("https://ftp.gnu.org/gnu/wget/wget-1.20.3.zip", "wget-1.20.3.zip", "", "") isa SetupSource{ArchiveSource}
16+
@test SetupSource("https://github.com/jedisct1/libsodium.git", "libsodium.git", "", "") isa SetupSource{GitSource}
17+
@test SetupSource("https://curl.haxx.se/ca/cacert-2020-01-01.pem", "cacert-2020-01-01.pem", "", "") isa SetupSource{FileSource}
1818

1919
@testset "Download and setup" begin
2020
mktempdir() do dir

0 commit comments

Comments
 (0)