Merge branch 'debug-trap' into bare-metal-full

This commit is contained in:
Gábor Stefanik 2024-01-02 01:23:58 +01:00
commit 3935c52325
2 changed files with 23 additions and 9 deletions

View file

@ -32,6 +32,7 @@ def create_configuration_file(args):
config.write(f"UPDATE_CHECKSUMS={args.update_checksums}\n") config.write(f"UPDATE_CHECKSUMS={args.update_checksums}\n")
config.write(f"JOBS={args.cores}\n") config.write(f"JOBS={args.cores}\n")
config.write(f"INTERNAL_CI={args.internal_ci or False}\n") config.write(f"INTERNAL_CI={args.internal_ci or False}\n")
config.write(f"INTERACTIVE={args.interactive}\n")
config.write(f"BARE_METAL={args.bare_metal}\n") config.write(f"BARE_METAL={args.bare_metal}\n")
if (args.bare_metal or args.qemu) and not args.kernel: if (args.bare_metal or args.qemu) and not args.kernel:
if args.repo or args.external_sources: if args.repo or args.external_sources:
@ -70,21 +71,24 @@ def main():
help="Force all files timestamps to be 0 unix time", help="Force all files timestamps to be 0 unix time",
action="store_true") action="store_true")
parser.add_argument("--update-checksums", parser.add_argument("--update-checksums",
help="Update checksum files.", help="Update checksum files",
action="store_true") action="store_true")
parser.add_argument("--external-sources", parser.add_argument("--external-sources",
help="Download sources externally from live-bootstrap.", help="Download sources externally from live-bootstrap",
action="store_true") action="store_true")
parser.add_argument("--build-kernels", parser.add_argument("--build-kernels",
help="Also build kernels in chroot and bwrap builds.", help="Also build kernels in chroot and bwrap builds",
action="store_true") action="store_true")
parser.add_argument("--no-create-config", parser.add_argument("--no-create-config",
help="Do not automatically create config file", help="Do not automatically create config file",
action="store_true") action="store_true")
parser.add_argument("-i", "--interactive",
help="Use interactive prompts to resolve issues during bootstrap",
action="store_true")
parser.add_argument("-r", "--repo", parser.add_argument("-r", "--repo",
help="Path to prebuilt binary packages.", nargs=None) help="Path to prebuilt binary packages", nargs=None)
parser.add_argument("--early-preseed", parser.add_argument("--early-preseed",
help="Skip early stages of live-bootstrap.", nargs=None) help="Skip early stages of live-bootstrap", nargs=None)
parser.add_argument("--internal-ci", help="INTERNAL for github CI") parser.add_argument("--internal-ci", help="INTERNAL for github CI")
# QEMU arguments # QEMU arguments

View file

@ -168,7 +168,7 @@ void output_config(FILE *out) {
char *get_var(char *name) { char *get_var(char *name) {
/* Search through existing variables. */ /* Search through existing variables. */
Variable *var; Variable *var;
Variable *last; Variable *last = NULL;
for (var = variables; var != NULL; var = var->next) { for (var = variables; var != NULL; var = var->next) {
if (strcmp(name, var->name) == 0) { if (strcmp(name, var->name) == 0) {
return var->val; return var->val;
@ -373,7 +373,7 @@ int interpret(Directive *directive) {
Directive *interpreter(Directive *directives) { Directive *interpreter(Directive *directives) {
Directive *directive; Directive *directive;
Directive *last; Directive *last = NULL;
for (directive = directives; directive != NULL; directive = directive->next) { for (directive = directives; directive != NULL; directive = directive->next) {
if (interpret(directive)) { if (interpret(directive)) {
/* This means this directive needs to be removed from the linked list. */ /* This means this directive needs to be removed from the linked list. */
@ -425,7 +425,17 @@ FILE *start_script(int id, int using_bash) {
if (using_bash) { if (using_bash) {
fputs("#!/bin/bash\n", out); fputs("#!/bin/bash\n", out);
if (strcmp(get_var("INTERACTIVE"), "True") == 0) {
if (using_bash != 1) {
fputs("trap 'env PS1=\"[TRAP] \\w # \" bash -i' ERR\n", out);
} else {
fputs("trap 'bash -c '\"'\"'while true; do printf \""
"[TRAP - use Ctrl+D] $(pwd) # \"; $(cat); done'\"'\"'' ERR\n",
out);
}
} else {
fputs("set -e\n", out); fputs("set -e\n", out);
}
fputs("cd /steps\n", out); fputs("cd /steps\n", out);
fputs(". ./bootstrap.cfg\n", out); fputs(". ./bootstrap.cfg\n", out);
fputs(". ./env\n", out); fputs(". ./env\n", out);
@ -537,7 +547,7 @@ void generate(Directive *directives) {
*/ */
generate_preseed_jump(counter); generate_preseed_jump(counter);
} }
using_bash = 1; using_bash += 1;
/* Create call to new script. */ /* Create call to new script. */
output_call_script(out, "", int2str(counter, 10, 0), using_bash, 0); output_call_script(out, "", int2str(counter, 10, 0), using_bash, 0);
fclose(out); fclose(out);