fosslinux / live-bootstrap

Use of a Linux initramfs to fully automate the bootstrapping process
501 stars 35 forks source link

Support interactive issue resolution prompts #386

Closed Googulator closed 9 months ago

Googulator commented 9 months ago

This adds a new flag, -i / --interactive, which enables opening a Bash prompt whenever something goes wrong in the bootstrap. This is highly useful when developing or debugging live-bootstrap, but it needs to be off by default, for use in automated processes.

In the future, asking for variables at runtime could (and perhaps should) also be gated behind this flag.

Depends on #385

Googulator commented 9 months ago

Traps do work when used like this; the normal interactive prompt doesn't work, but this one does. I have hit it a few times during development already, and used the trap prompt successfully to fix the issue and continue bootstrapping.

Maybe EXIT traps don't work (that's what was used in live-bootstrap before the simplify refactor), but ERR ones do.

Googulator commented 9 months ago

I was thinking "not using Bash" (0) -> "using Bash #1" -> "using Bash #2", not necessarily a boolean.

What would be a better variable name for you?

Googulator commented 9 months ago

Just a quick heads up - I've just discovered a bug in this. When -i is given, checksum failures after switching to the first Bash don't trigger a drop to the trap as intended, but only print a warning. Fortunately, the fix should be easy ("set -E" needs to be set to propagate the trap to functions).

fosslinux commented 9 months ago

What would be a better variable name for you?

Perhaps bash_rebuild? It's not a huge deal though.

Googulator commented 9 months ago

"bash_rebuild" is slightly off semantically, as 0 means "no bash", 1 means "initial build of bash" (= no rebuilds), and 2 is "2nd build of bash") (= 1 rebuild). "bash_build" works, however.

Googulator commented 9 months ago

Pushed the rename to bash_build.

Googulator commented 9 months ago

Ouch, the "set -E" fix causes a trap in the autogen build

EDIT: this appears to be a legit issue in the autogen bootstrap that we previously missed! I suggest that we merge this PR in the current state (unless there are other outstanding issues), and then fix the underlying issue in autogen separately, especially since this doesn't break existing bootstrap paths, only affecting the new "-i" option.