diff --git a/src/wizard/deploy.jl b/src/wizard/deploy.jl index 9675b137c..23bf98c7b 100644 --- a/src/wizard/deploy.jl +++ b/src/wizard/deploy.jl @@ -1,15 +1,13 @@ function print_build_tarballs(io::IO, state::WizardState) - urlfiles = zip(state.source_urls, state.source_files) - - sources_strings = map(urlfiles) do x + sources_strings = map(state.source_files) do source # Try to be smart and automatically replace version number with `$(version)`. - url_string = replace(repr(x[1]), string(state.version) => "\$(version)") + url_string = replace(repr(source.url), string(state.version) => "\$(version)") if endswith(x[1], ".git") - "GitSource($(url_string), $(repr(x[2].hash)))" + "GitSource($(url_string), $(repr(source.hash)))" elseif any(endswith(x[1], ext) for ext in BinaryBuilderBase.archive_extensions) - "ArchiveSource($(url_string), $(repr(x[2].hash)))" + "ArchiveSource($(url_string), $(repr(source.hash)))" else - "FileSource($(url_string), $(repr(x[2].hash)))" + "FileSource($(url_string), $(repr(source.hash)))" end end if !isempty(state.patches) diff --git a/src/wizard/obtain_source.jl b/src/wizard/obtain_source.jl index c464e7475..3dfc2c0f5 100644 --- a/src/wizard/obtain_source.jl +++ b/src/wizard/obtain_source.jl @@ -83,7 +83,11 @@ function download_source(state::WizardState) local source_hash - if endswith(url, ".git") || startswith(url, "git://") + if url == "N" + return nothing + end + + if endswith(url, ".git") || startswith(url, "git://") || startswith(url, "ssh://") source_path = cached_git_clone(url; progressbar=true, verbose=true) # Clone the URL, record the current gitsha for the given branch repo = GitRepo(source_path) @@ -136,7 +140,7 @@ function download_source(state::WizardState) end # Spit back the url, local path and source hash - return url, SetupSource(url, source_path, source_hash, "") + return SetupSource(url, source_path, source_hash, "") end """ @@ -272,17 +276,15 @@ function obtain_source(state::WizardState) # These are the metadata we need to know about all the sources we'll be # building over the course of this journey we're on together. - state.source_urls = String[] state.source_files = SetupSource[] while true - url, file = download_source(state) - if url != "N" - push!(state.source_urls, url) + file = download_source(state) + if file !== nothing push!(state.source_files, file) println(state.outs) else - if isempty(state.source_urls) + if isempty(state.source_files) printstyled(state.outs, "No URLs were given.\n", color=:yellow, bold=true) continue end diff --git a/src/wizard/state.jl b/src/wizard/state.jl index ce7cb3980..69bf7290d 100644 --- a/src/wizard/state.jl +++ b/src/wizard/state.jl @@ -31,7 +31,6 @@ necessary. It also holds all necessary metadata such as input/output streams. # Filled in by step 2 workspace::Union{Nothing, String} = nothing - source_urls::Union{Nothing, Vector{String}} = nothing source_files::Union{Nothing, Vector{SetupSource}} = nothing dependencies::Union{Nothing, Vector{Dependency}} = nothing compilers::Union{Nothing, Vector{Symbol}} = nothing diff --git a/test/basic.jl b/test/basic.jl index c8ac4c169..ea7850259 100644 --- a/test/basic.jl +++ b/test/basic.jl @@ -167,8 +167,7 @@ end state = Wizard.WizardState() state.step = :step34 state.platforms = [Platform("x86_64", "linux")] - state.source_urls = ["http://127.0.0.1:14444/a/source.tar.gz"] - state.source_files = [BinaryBuilder.SetupSource{ArchiveSource}("/tmp/source.tar.gz", bytes2hex(sha256("a")), "")] + state.source_files = [BinaryBuilder.SetupSource{ArchiveSource}("http://127.0.0.1:14444/a/source.tar.gz", "/tmp/source.tar.gz", bytes2hex(sha256("a")), "")] state.name = "libfoo" state.version = v"1.0.0" state.dependencies = [Dependency(PackageSpec(;name="Zlib_jll")), diff --git a/test/wizard.jl b/test/wizard.jl index 395b969e6..f09f43b26 100644 --- a/test/wizard.jl +++ b/test/wizard.jl @@ -178,7 +178,7 @@ end call_response(ins, outs, "Select the preferred LLVM version", "\e[B\e[B\e[B\r") end # Check that the state is modified appropriately - @test state.source_urls == ["http://127.0.0.1:$(port)/a/source.tar.gz"] + @test getfield.(state.source_files, :url) == ["http://127.0.0.1:$(port)/a/source.tar.gz"] @test getfield.(state.source_files, :hash) == [libfoo_tarball_hash] @test Set(state.compilers) == Set([:c, :rust, :go]) @test state.preferred_gcc_version == getversion(available_gcc_builds[1]) @@ -201,7 +201,7 @@ end call_response(ins, outs, "Do you want to customize the set of compilers?", "N") end # Check that the state is modified appropriately - @test state.source_urls == [ + @test getfield.(state.source_files, :url) == [ "http://127.0.0.1:$(port)/a/source.tar.gz", "http://127.0.0.1:$(port)/b/source.tar.gz", ] @@ -268,7 +268,7 @@ end call_response(ins, outs, "Enter a version number", "1.0.0") call_response(ins, outs, "Do you want to customize the set of compilers?", "N") end - @test state.source_urls == ["http://127.0.0.1:$(port)/a/source.tar.gz"] + @test getfield.(state.source_files, :url) == ["http://127.0.0.1:$(port)/a/source.tar.gz"] state = step2_state() with_wizard_output(state, Wizard.step2) do ins, outs call_response(ins, outs, "Please enter a URL", "N") @@ -295,8 +295,8 @@ function step3_state() state = Wizard.WizardState() state.step = :step34 state.platforms = [Platform("x86_64", "linux")] - state.source_urls = ["http://127.0.0.1:$(port)/a/source.tar.gz"] - state.source_files = [BinaryBuilder.SetupSource{ArchiveSource}(libfoo_tarball_path, libfoo_tarball_hash, "")] + state.source_files = [BinaryBuilder.SetupSource{ArchiveSource}("http://127.0.0.1:$(port)/a/source.tar.gz", + libfoo_tarball_path, libfoo_tarball_hash, "")] state.name = "libfoo" state.version = v"1.0.0" state.dependencies = Dependency[]