@@ -128,28 +128,29 @@ DirectorySource(path::String; target::String = "", follow_symlinks::Bool=false)
128
128
DirectorySource (path, target, follow_symlinks)
129
129
130
130
# 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:// " )
132
132
133
133
# This is not meant to be used as source in the `build_tarballs.jl` scripts but
134
134
# only to set up the source in the workspace.
135
135
struct SetupSource{T<: AbstractSource }
136
+ url:: Union{String, Nothing}
136
137
path:: String
137
138
hash:: String
138
139
target:: String
139
140
follow_symlinks:: Bool
140
141
end
141
142
# `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 )
144
145
# This is used in wizard/obtain_source.jl to automatically guess the parameter
145
146
# of SetupSource from the URL
146
147
function SetupSource (url:: String , path:: String , hash:: String , target:: String )
147
148
if isgitrepo (url)
148
- return SetupSource {GitSource} (path, hash, target)
149
+ return SetupSource {GitSource} (url, path, hash, target)
149
150
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)
151
152
else
152
- return SetupSource {FileSource} (path, hash, target)
153
+ return SetupSource {FileSource} (url, path, hash, target)
153
154
end
154
155
end
155
156
@@ -158,10 +159,13 @@ struct PatchSource
158
159
patch:: String
159
160
end
160
161
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} }
162
163
gettarget (s:: ArchiveSource ) = s. unpack_target
163
164
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)
165
169
# Immediately abspath() a src_url so we don't lose track of
166
170
# sources given to us with a relative path
167
171
src_path = abspath (source. url)
@@ -173,7 +177,7 @@ function download_source(source::T; verbose::Bool = false, downloads_dir = stora
173
177
src_path = joinpath (downloads_dir, string (source. hash, " -" , basename (source. url)))
174
178
download_verify (source. url, source. hash, src_path)
175
179
end
176
- return SetupSource {T} (src_path, source. hash, gettarget (source))
180
+ return SetupSource {T} (source . url, src_path, source. hash, gettarget (source))
177
181
end
178
182
179
183
struct GitTransferProgress
@@ -243,9 +247,10 @@ function cached_git_clone(url::String;
243
247
return repo_path
244
248
end
245
249
246
- function download_source (source:: GitSource ; kwargs... )
250
+ function download_source (source:: Union{ GitSource, SetupSource{GitSource}} ; kwargs... )
247
251
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)
249
254
end
250
255
251
256
function download_source (source:: DirectorySource ; verbose:: Bool = false )
@@ -255,7 +260,7 @@ function download_source(source::DirectorySource; verbose::Bool = false)
255
260
if verbose
256
261
@info " Directory \" $(source. path) \" found"
257
262
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)
259
264
end
260
265
261
266
"""
0 commit comments