Skip to content

Commit ad42b59

Browse files
fredrikekrestaticfloat
authored andcommitted
Unsymlink deps from the prefixes in the wizard.
1 parent 750ec56 commit ad42b59

File tree

1 file changed

+37
-9
lines changed

1 file changed

+37
-9
lines changed

src/wizard/interactive_build.jl

Lines changed: 37 additions & 9 deletions
Original file line numberDiff line numberDiff line change
@@ -55,7 +55,9 @@ function step4(state::WizardState, ur::Runner, platform::Platform,
5555
println(state.outs)
5656

5757
if choice == 1
58-
return step3_interactive(state, prefix, platform, ur, build_path)
58+
# Link dependencies into the prefix again
59+
artifact_paths = setup_dependencies(prefix, state.dependencies, platform)
60+
return step3_interactive(state, prefix, platform, ur, build_path, artifact_paths)
5961
elseif choice == 2
6062
state.step = :step3
6163
return
@@ -183,13 +185,16 @@ script or proceed to step 4.
183185
"""
184186
function step3_interactive(state::WizardState, prefix::Prefix,
185187
platform::Platform,
186-
ur::Runner, build_path::AbstractString)
188+
ur::Runner, build_path::AbstractString, artifact_paths::Vector{String})
187189

188190
if interactive_build(state, prefix, ur, build_path)
191+
# Unsymlink all the deps from the dest_prefix before moving to the next step
192+
cleanup_dependencies(prefix, artifact_paths)
189193
state.step = :step3_retry
190194
else
191195
step3_audit(state, platform, joinpath(prefix, "destdir"))
192-
196+
# Unsymlink all the deps from the dest_prefix before moving to the next step
197+
cleanup_dependencies(prefix, artifact_paths)
193198
return step4(state, ur, platform, build_path, prefix)
194199
end
195200
end
@@ -209,7 +214,7 @@ function step3_retry(state::WizardState)
209214
build_path = tempname()
210215
mkpath(build_path)
211216
prefix = setup_workspace(build_path, state.source_files, state.source_hashes; verbose=false)
212-
setup_dependencies(prefix, state.dependencies, platform)
217+
artifact_paths = setup_dependencies(prefix, state.dependencies, platform)
213218

214219
ur = preferred_runner()(
215220
prefix.path;
@@ -221,6 +226,8 @@ function step3_retry(state::WizardState)
221226
run(ur, `/bin/bash -c $(state.history)`, io; verbose=true, tee_stream=state.outs)
222227
end
223228
step3_audit(state, platform, joinpath(prefix, "destdir"))
229+
# Unsymlink all the deps from the dest_prefix before moving to the next step
230+
cleanup_dependencies(prefix, artifact_paths)
224231

225232
return step4(state, ur, platform, build_path, prefix)
226233
end
@@ -290,7 +297,7 @@ function step34(state::WizardState)
290297
state.source_hashes;
291298
verbose=false,
292299
)
293-
setup_dependencies(prefix, state.dependencies, platform)
300+
artifact_paths = setup_dependencies(prefix, state.dependencies, platform)
294301

295302
provide_hints(state, joinpath(prefix.path, "srcdir"))
296303

@@ -303,7 +310,7 @@ function step34(state::WizardState)
303310
platform=platform,
304311
src_name=state.name,
305312
)
306-
return step3_interactive(state, prefix, platform, ur, build_path)
313+
return step3_interactive(state, prefix, platform, ur, build_path, artifact_paths)
307314
end
308315

309316
function step5_internal(state::WizardState, platform::Platform)
@@ -321,10 +328,19 @@ function step5_internal(state::WizardState, platform::Platform)
321328
build_path = tempname()
322329
mkpath(build_path)
323330
local ok = false
331+
# The code path in this function is rather complex (and unpredictable)
332+
# due to the fact that the user makes the choices. Therefore we keep
333+
# track of all the linked artifacts in a dictionary, and make sure to
334+
# unlink them before setting up a new build prefix
335+
prefix_artifacts = Dict{Prefix,Vector{String}}()
324336
while !ok
325337
cd(build_path) do
326338
prefix = setup_workspace(build_path, state.source_files, state.source_hashes; verbose=true)
327-
setup_dependencies(prefix, state.dependencies, platform)
339+
# Clean up artifacts in case there are some
340+
cleanup_dependencies(prefix, get(prefix_artifacts, prefix, String[]))
341+
artifact_paths = setup_dependencies(prefix, state.dependencies, platform)
342+
# Record newly added artifacts for this prefix
343+
prefix_artifacts[prefix] = artifact_paths
328344
ur = preferred_runner()(
329345
prefix.path;
330346
cwd="/workspace/srcdir",
@@ -385,7 +401,12 @@ function step5_internal(state::WizardState, platform::Platform)
385401
state.source_hashes;
386402
verbose=true,
387403
)
388-
setup_dependencies(prefix, state.dependencies, platform)
404+
# Clean up artifacts in case there are some
405+
cleanup_dependencies(prefix, get(prefix_artifacts, prefix, String[]))
406+
artifact_paths = setup_dependencies(prefix, state.dependencies, platform)
407+
# Record newly added artifacts for this prefix
408+
prefix_artifacts[prefix] = artifact_paths
409+
389410
ur = preferred_runner()(
390411
prefix.path;
391412
cwd="/workspace/srcdir",
@@ -432,6 +453,10 @@ function step5_internal(state::WizardState, platform::Platform)
432453
println(state.outs)
433454
end
434455
end
456+
# Unsymlink all the deps from the prefixes before moving to the next step
457+
for (prefix, paths) in prefix_artifacts
458+
cleanup_dependencies(prefix, paths)
459+
end
435460
return ok
436461
end
437462

@@ -507,7 +532,7 @@ function step5c(state::WizardState)
507532
state.source_hashes;
508533
verbose=false,
509534
)
510-
setup_dependencies(prefix, state.dependencies, platform)
535+
artifact_paths = setup_dependencies(prefix, state.dependencies, platform)
511536
ur = preferred_runner()(
512537
prefix.path;
513538
cwd="/workspace/srcdir",
@@ -535,6 +560,9 @@ function step5c(state::WizardState)
535560
silent = true
536561
))
537562

563+
# Unsymlink all the deps from the prefix before moving to the next platform
564+
cleanup_dependencies(prefix, artifact_paths)
565+
538566
print(state.outs, "[")
539567
if ok
540568
printstyled(state.outs, "", color=:green)

0 commit comments

Comments
 (0)