Skip to content

Commit 29c0eed

Browse files
Kenogiordano
authored andcommitted
Store url in SetupSource
Otherwise the wizard needs to keep a separate 1-1 mapping of the urls, which is somewhat silly.
1 parent 7c82b89 commit 29c0eed

File tree

3 files changed

+19
-14
lines changed

3 files changed

+19
-14
lines changed

Project.toml

+1-1
Original file line numberDiff line numberDiff line change
@@ -1,7 +1,7 @@
11
name = "BinaryBuilderBase"
22
uuid = "7f725544-6523-48cd-82d1-3fa08ff4056e"
33
authors = ["Elliot Saba <[email protected]>"]
4-
version = "1.35.2"
4+
version = "1.36.0"
55

66
[deps]
77
Bzip2_jll = "6e34b625-4abd-537c-b88f-471c36dfa7a0"

src/Prefix.jl

+1-1
Original file line numberDiff line numberDiff line change
@@ -346,7 +346,7 @@ function setup(source::SetupSource{ArchiveSource}, targetdir, verbose; tar_flags
346346
run(`$(unzip_jll.unzip()) -q $(source.path) $(pkg_name)`)
347347
end
348348
# Second untar the pkg tarball
349-
pkg_source = SetupSource{ArchiveSource}(joinpath(targetdir, pkg_name), source.hash, source.target)
349+
pkg_source = SetupSource{ArchiveSource}(source.url, joinpath(targetdir, pkg_name), source.hash, source.target)
350350
# Run setup again to untar the pkg binaries
351351
setup(pkg_source, targetdir, verbose; tar_flags = tar_flags)
352352
else

src/Sources.jl

+17-12
Original file line numberDiff line numberDiff line change
@@ -128,28 +128,29 @@ DirectorySource(path::String; target::String = "", follow_symlinks::Bool=false)
128128
DirectorySource(path, target, follow_symlinks)
129129

130130
# Try to guess if a URL is a Git repository
131-
isgitrepo(url::AbstractString) = endswith(url, ".git") || startswith(url, "git://")
131+
isgitrepo(url::AbstractString) = endswith(url, ".git") || startswith(url, "git://") || startswith(url, "ssh://")
132132

133133
# This is not meant to be used as source in the `build_tarballs.jl` scripts but
134134
# only to set up the source in the workspace.
135135
struct SetupSource{T<:AbstractSource}
136+
url::Union{String, Nothing}
136137
path::String
137138
hash::String
138139
target::String
139140
follow_symlinks::Bool
140141
end
141142
# `follow_symlinks` is used only for DirectorySource, let's have a method without it.
142-
SetupSource{T}(path::String, hash::String, target::String) where {T} =
143-
SetupSource{T}(path, hash, target, false)
143+
SetupSource{T}(url::Union{Nothing, String}, path::String, hash::String, target::String) where {T} =
144+
SetupSource{T}(url, path, hash, target, false)
144145
# This is used in wizard/obtain_source.jl to automatically guess the parameter
145146
# of SetupSource from the URL
146147
function SetupSource(url::String, path::String, hash::String, target::String)
147148
if isgitrepo(url)
148-
return SetupSource{GitSource}(path, hash, target)
149+
return SetupSource{GitSource}(url, path, hash, target)
149150
elseif any(endswith(path, ext) for ext in archive_extensions)
150-
return SetupSource{ArchiveSource}(path, hash, target)
151+
return SetupSource{ArchiveSource}(url, path, hash, target)
151152
else
152-
return SetupSource{FileSource}(path, hash, target)
153+
return SetupSource{FileSource}(url, path, hash, target)
153154
end
154155
end
155156

@@ -158,10 +159,13 @@ struct PatchSource
158159
patch::String
159160
end
160161

161-
function download_source(source::T; verbose::Bool = false, downloads_dir = storage_dir("downloads")) where {T<:Union{ArchiveSource,FileSource}}
162+
function download_source(source::Union{T, SetupSource{T}}; verbose::Bool = false, downloads_dir = storage_dir("downloads")) where {T<:Union{ArchiveSource,FileSource}}
162163
gettarget(s::ArchiveSource) = s.unpack_target
163164
gettarget(s::FileSource) = s.filename
164-
if isfile(source.url)
165+
gettarget(s::SetupSource) = s.target
166+
if isa(source, SetupSource) && isfile(source.path) && verify(source.path, source.hash)
167+
return source
168+
elseif isfile(source.url)
165169
# Immediately abspath() a src_url so we don't lose track of
166170
# sources given to us with a relative path
167171
src_path = abspath(source.url)
@@ -173,7 +177,7 @@ function download_source(source::T; verbose::Bool = false, downloads_dir = stora
173177
src_path = joinpath(downloads_dir, string(source.hash, "-", basename(source.url)))
174178
download_verify(source.url, source.hash, src_path)
175179
end
176-
return SetupSource{T}(src_path, source.hash, gettarget(source))
180+
return SetupSource{T}(source.url, src_path, source.hash, gettarget(source))
177181
end
178182

179183
struct GitTransferProgress
@@ -243,9 +247,10 @@ function cached_git_clone(url::String;
243247
return repo_path
244248
end
245249

246-
function download_source(source::GitSource; kwargs...)
250+
function download_source(source::Union{GitSource, SetupSource{GitSource}}; kwargs...)
247251
src_path = cached_git_clone(source.url; hash_to_check=source.hash, kwargs...)
248-
return SetupSource{GitSource}(src_path, source.hash, source.unpack_target)
252+
return SetupSource{GitSource}(source.url, src_path, source.hash,
253+
isa(source, GitSource) ? source.unpack_target : source.target)
249254
end
250255

251256
function download_source(source::DirectorySource; verbose::Bool = false)
@@ -255,7 +260,7 @@ function download_source(source::DirectorySource; verbose::Bool = false)
255260
if verbose
256261
@info "Directory \"$(source.path)\" found"
257262
end
258-
return SetupSource{DirectorySource}(abspath(source.path), "", source.target, source.follow_symlinks)
263+
return SetupSource{DirectorySource}(nothing, abspath(source.path), "", source.target, source.follow_symlinks)
259264
end
260265

261266
"""

0 commit comments

Comments
 (0)