commit acd3485c6fa9ce27f3aa61749a1c2cd4afbe53c7
parent 9dbb87dcbfc404333713a0d24459532bb064d58b
Author: phoebos <ben@bvnf.space>
Date: Tue, 17 Jun 2025 22:13:43 +0100
build: use coroutines to permit restarting failed build
Diffstat:
1 file changed, 26 insertions(+), 2 deletions(-)
diff --git a/bliss/build.lua b/bliss/build.lua
@@ -75,7 +75,8 @@ local function build_build(env, p)
if not utils.run(buildfile, {destdir, p.ver}, build_env, logfile) then
utils.log(p.pkg, "Build failed")
utils.log(p.pkg, "Log stored to " .. logfile)
- os.exit(false)
+ coroutine.yield("BUILD_FAIL", logfile)
+ -- os.exit(false)
end
if env.KEEPLOG ~= 1 then
@@ -232,7 +233,30 @@ local function build(env, arg)
utils.log(p.pkg, "Building package ("..index.."/"..#db..")")
build_extract(env, p)
- build_build(env, p)
+
+ local co = coroutine.create(build_build)
+ local stat, r, logfile = coroutine.resume(co, env, p)
+ -- yield is either on build script fail, or build_build returned.
+ if stat then
+ if r == "BUILD_FAIL" then
+ -- drop into shell
+ local destdir = env.pkg_dir .. "/" .. p.pkg
+ utils.log("Dropped into interactive shell to manually fix and install to $DESTDIR.")
+ utils.log("`exit` or Ctrl-D when done to finish building the tarball.")
+ utils.run_quiet("sh", {"-i"}, {DESTDIR=destdir})
+ utils.prompt(env, "Continue to build the tarball?") -- TODO: logfile isn't deleted!
+ coroutine.resume(co)
+ end
+ else
+ -- some other failure
+ utils.log(p.pkg, "Error: "..r)
+ if env.KEEPLOG ~= 1 then
+ unistd.unlink(logfile)
+ end
+ coroutine.close(co)
+ --os.exit(false)
+ error(r)
+ end
-- TODO: strip? fix_deps?
gen_manifest(env, p)