@@ -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.
135135struct SetupSource{T<: AbstractSource }
136+ url:: Union{String, Nothing}
136137 path:: String
137138 hash:: String
138139 target:: String
139140 follow_symlinks:: Bool
140141end
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
146147function 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
154155end
155156
@@ -158,10 +159,13 @@ struct PatchSource
158159 patch:: String
159160end
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))
177181end
178182
179183struct GitTransferProgress
@@ -243,9 +247,10 @@ function cached_git_clone(url::String;
243247 return repo_path
244248end
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)
249254end
250255
251256function 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)
259264end
260265
261266"""
0 commit comments