Skip to content

Commit 4bb7f6d

Browse files
committed
Remove separate source_urls wizard field
Goes with JuliaPackaging/BinaryBuilderBase.jl#322. Part of the problem with the current setup is that the WizardState doesn't actually round trip properly, because the cache for archive downloads gets deleted. It could be reconstituted from source_urls of course, but it would be cleaner to just do that on-demand with the SetupSource (though this commit doesn't do that yet).
1 parent d40ec61 commit 4bb7f6d

File tree

5 files changed

+20
-22
lines changed

5 files changed

+20
-22
lines changed

src/wizard/deploy.jl

Lines changed: 5 additions & 7 deletions
Original file line numberDiff line numberDiff line change
@@ -1,15 +1,13 @@
11
function print_build_tarballs(io::IO, state::WizardState)
2-
urlfiles = zip(state.source_urls, state.source_files)
3-
4-
sources_strings = map(urlfiles) do x
2+
sources_strings = map(state.source_files) do source
53
# Try to be smart and automatically replace version number with `$(version)`.
6-
url_string = replace(repr(x[1]), string(state.version) => "\$(version)")
4+
url_string = replace(repr(source.url), string(state.version) => "\$(version)")
75
if endswith(x[1], ".git")
8-
"GitSource($(url_string), $(repr(x[2].hash)))"
6+
"GitSource($(url_string), $(repr(source.hash)))"
97
elseif any(endswith(x[1], ext) for ext in BinaryBuilderBase.archive_extensions)
10-
"ArchiveSource($(url_string), $(repr(x[2].hash)))"
8+
"ArchiveSource($(url_string), $(repr(source.hash)))"
119
else
12-
"FileSource($(url_string), $(repr(x[2].hash)))"
10+
"FileSource($(url_string), $(repr(source.hash)))"
1311
end
1412
end
1513
if !isempty(state.patches)

src/wizard/obtain_source.jl

Lines changed: 9 additions & 7 deletions
Original file line numberDiff line numberDiff line change
@@ -83,7 +83,11 @@ function download_source(state::WizardState)
8383

8484
local source_hash
8585

86-
if endswith(url, ".git") || startswith(url, "git://")
86+
if url == "N"
87+
return nothing
88+
end
89+
90+
if endswith(url, ".git") || startswith(url, "git://") || startswith(url, "ssh://")
8791
source_path = cached_git_clone(url; progressbar=true, verbose=true)
8892
# Clone the URL, record the current gitsha for the given branch
8993
repo = GitRepo(source_path)
@@ -136,7 +140,7 @@ function download_source(state::WizardState)
136140
end
137141

138142
# Spit back the url, local path and source hash
139-
return url, SetupSource(url, source_path, source_hash, "")
143+
return SetupSource(url, source_path, source_hash, "")
140144
end
141145

142146
"""
@@ -272,17 +276,15 @@ function obtain_source(state::WizardState)
272276

273277
# These are the metadata we need to know about all the sources we'll be
274278
# building over the course of this journey we're on together.
275-
state.source_urls = String[]
276279
state.source_files = SetupSource[]
277280

278281
while true
279-
url, file = download_source(state)
280-
if url != "N"
281-
push!(state.source_urls, url)
282+
file = download_source(state)
283+
if file !== nothing
282284
push!(state.source_files, file)
283285
println(state.outs)
284286
else
285-
if isempty(state.source_urls)
287+
if isempty(state.source_files)
286288
printstyled(state.outs, "No URLs were given.\n", color=:yellow, bold=true)
287289
continue
288290
end

src/wizard/state.jl

Lines changed: 0 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -31,7 +31,6 @@ necessary. It also holds all necessary metadata such as input/output streams.
3131

3232
# Filled in by step 2
3333
workspace::Union{Nothing, String} = nothing
34-
source_urls::Union{Nothing, Vector{String}} = nothing
3534
source_files::Union{Nothing, Vector{SetupSource}} = nothing
3635
dependencies::Union{Nothing, Vector{Dependency}} = nothing
3736
compilers::Union{Nothing, Vector{Symbol}} = nothing

test/basic.jl

Lines changed: 1 addition & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -167,8 +167,7 @@ end
167167
state = Wizard.WizardState()
168168
state.step = :step34
169169
state.platforms = [Platform("x86_64", "linux")]
170-
state.source_urls = ["http://127.0.0.1:14444/a/source.tar.gz"]
171-
state.source_files = [BinaryBuilder.SetupSource{ArchiveSource}("/tmp/source.tar.gz", bytes2hex(sha256("a")), "")]
170+
state.source_files = [BinaryBuilder.SetupSource{ArchiveSource}("http://127.0.0.1:14444/a/source.tar.gz", "/tmp/source.tar.gz", bytes2hex(sha256("a")), "")]
172171
state.name = "libfoo"
173172
state.version = v"1.0.0"
174173
state.dependencies = [Dependency(PackageSpec(;name="Zlib_jll")),

test/wizard.jl

Lines changed: 5 additions & 5 deletions
Original file line numberDiff line numberDiff line change
@@ -178,7 +178,7 @@ end
178178
call_response(ins, outs, "Select the preferred LLVM version", "\e[B\e[B\e[B\r")
179179
end
180180
# Check that the state is modified appropriately
181-
@test state.source_urls == ["http://127.0.0.1:$(port)/a/source.tar.gz"]
181+
@test getfield.(state.source_files, :url) == ["http://127.0.0.1:$(port)/a/source.tar.gz"]
182182
@test getfield.(state.source_files, :hash) == [libfoo_tarball_hash]
183183
@test Set(state.compilers) == Set([:c, :rust, :go])
184184
@test state.preferred_gcc_version == getversion(available_gcc_builds[1])
@@ -201,7 +201,7 @@ end
201201
call_response(ins, outs, "Do you want to customize the set of compilers?", "N")
202202
end
203203
# Check that the state is modified appropriately
204-
@test state.source_urls == [
204+
@test getfield.(state.source_files, :url) == [
205205
"http://127.0.0.1:$(port)/a/source.tar.gz",
206206
"http://127.0.0.1:$(port)/b/source.tar.gz",
207207
]
@@ -268,7 +268,7 @@ end
268268
call_response(ins, outs, "Enter a version number", "1.0.0")
269269
call_response(ins, outs, "Do you want to customize the set of compilers?", "N")
270270
end
271-
@test state.source_urls == ["http://127.0.0.1:$(port)/a/source.tar.gz"]
271+
@test getfield.(state.source_files, :url) == ["http://127.0.0.1:$(port)/a/source.tar.gz"]
272272
state = step2_state()
273273
with_wizard_output(state, Wizard.step2) do ins, outs
274274
call_response(ins, outs, "Please enter a URL", "N")
@@ -295,8 +295,8 @@ function step3_state()
295295
state = Wizard.WizardState()
296296
state.step = :step34
297297
state.platforms = [Platform("x86_64", "linux")]
298-
state.source_urls = ["http://127.0.0.1:$(port)/a/source.tar.gz"]
299-
state.source_files = [BinaryBuilder.SetupSource{ArchiveSource}(libfoo_tarball_path, libfoo_tarball_hash, "")]
298+
state.source_files = [BinaryBuilder.SetupSource{ArchiveSource}("http://127.0.0.1:$(port)/a/source.tar.gz",
299+
libfoo_tarball_path, libfoo_tarball_hash, "")]
300300
state.name = "libfoo"
301301
state.version = v"1.0.0"
302302
state.dependencies = Dependency[]

0 commit comments

Comments
 (0)