From 8fca0973abb40b370f919f99f31a817fbc35cdca Mon Sep 17 00:00:00 2001 From: =?UTF-8?q?G=C3=A1bor=20Stefanik?= Date: Tue, 23 Jan 2024 19:05:05 +0100 Subject: [PATCH 1/3] Fix "no job control in this shell" in final Bash prompt --- steps/improve/after.sh | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/steps/improve/after.sh b/steps/improve/after.sh index 32d445c..9160743 100644 --- a/steps/improve/after.sh +++ b/steps/improve/after.sh @@ -10,7 +10,7 @@ . /steps/env if [ "${INTERACTIVE}" = True ]; then - env - PATH=${PREFIX}/bin PS1="\w # " bash -i + env - PATH=${PREFIX}/bin PS1="\w # " setsid openvt -fec1 -- bash -i fi if [ "${CHROOT}" = False ]; then From 221f2d0f8eabd58d73159ef8cc71eead19532840 Mon Sep 17 00:00:00 2001 From: =?UTF-8?q?G=C3=A1bor=20Stefanik?= Date: Tue, 23 Jan 2024 19:33:55 +0100 Subject: [PATCH 2/3] Open shells on virtual terminals for monitoring in interactive mode We spawn a shell: - When Bash is first built, on tty2. This shell uses the old Bash, so interactive mode needs to be emulated using redirection. Thus, entering commands needs to be done using Enter followed by Ctrl+D, and certain redirection features are unavailable. - After moving the system to disk, on tty2. Old Bash, same limitations. - After 2nd Bash is built, on tty3. This is a fully functional shell. This is disabled in chroot-like bootstrap modes, or when -i is not set. --- steps/improve/open_console.sh | 11 +++++++++++ steps/improve/populate_device_nodes.sh | 2 ++ steps/manifest | 6 +++++- 3 files changed, 18 insertions(+), 1 deletion(-) create mode 100644 steps/improve/open_console.sh diff --git a/steps/improve/open_console.sh b/steps/improve/open_console.sh new file mode 100644 index 0000000..33cc402 --- /dev/null +++ b/steps/improve/open_console.sh @@ -0,0 +1,11 @@ +#!/bin/sh + +# SPDX-FileCopyrightText: 2024 Gábor Stefanik +# +# SPDX-License-Identifier: GPL-3.0-or-later + +if bash --version | grep -q 'GPLv3'; then + env - PATH=${PREFIX}/bin PS1="\w # " openvt -- bash -i +else + bash -c 'while true; do printf "[early Bash - use Ctrl+D] $(pwd) # "; $(cat /dev/tty2); done' &> /dev/tty2 & +fi diff --git a/steps/improve/populate_device_nodes.sh b/steps/improve/populate_device_nodes.sh index 98ffc8d..99f081c 100755 --- a/steps/improve/populate_device_nodes.sh +++ b/steps/improve/populate_device_nodes.sh @@ -23,6 +23,8 @@ if mount --version >/dev/null 2>&1; then fi if [ "${CHROOT}" = False ]; then + test -c "/dev/tty1" || mknod -m 666 "/dev/tty1" c 4 1 + test -c "/dev/tty2" || mknod -m 666 "/dev/tty2" c 4 2 test -c "/dev/console" || mknod -m 666 "/dev/console" c 5 1 test -b "/dev/sda" || mknod -m 600 "/dev/sda" b 8 0 test -b "/dev/sda1" || mknod -m 600 "/dev/sda1" b 8 1 diff --git a/steps/manifest b/steps/manifest index 36ded1a..77eab6f 100644 --- a/steps/manifest +++ b/steps/manifest @@ -54,6 +54,9 @@ build: bash-2.05b improve: setup_repo improve: update_env improve: merged_usr +improve: populate_device_nodes +define: CONSOLES = ( INTERACTIVE == True && CHROOT == False ) +improve: open_console ( CONSOLES == True ) build: flex-2.5.11 build: tcc-0.9.27 improve: musl_libdir @@ -80,7 +83,6 @@ build: perl5.004-05 build: perl5.005-03 build: perl-5.6.2 uninstall: perl-5.000 perl-5.003 perl5.004-05 perl5.005-03 -improve: populate_device_nodes build: autoconf-2.52 build: automake-1.6.3 build: automake-1.6.3 @@ -128,11 +130,13 @@ jump: linux ( CHROOT == False ) jump: move_disk ( KERNEL_BOOTSTRAP == True ) improve: finalize_job_count improve: finalize_fhs +improve: open_console ( CONSOLES == True ) improve: swap ( SWAP_SIZE != 0 ) build: musl-1.2.4 build: curl-8.5.0 improve: get_network ( CHROOT == False ) build: bash-5.2.15 +improve: open_console ( CONSOLES == True ) build: xz-5.4.1 build: file-5.44 build: libtool-2.4.7 From c748766fac7f46a1fa6b7a7e6cad5fad4c69bd72 Mon Sep 17 00:00:00 2001 From: =?UTF-8?q?G=C3=A1bor=20Stefanik?= Date: Wed, 24 Jan 2024 00:10:37 +0100 Subject: [PATCH 3/3] Switch Fiwix's console to tty1 on bare metal This is needed to make the monitoring/recovery shell on tty2 work, as the default console is tty0, which will just print to whichever virtual console is active at the moment, making the shell unusable. --- steps/kexec-fiwix-1.0/kexec-fiwix-1.0.checksums | 2 +- steps/kexec-fiwix-1.0/src/kexec-fiwix.c | 2 +- 2 files changed, 2 insertions(+), 2 deletions(-) diff --git a/steps/kexec-fiwix-1.0/kexec-fiwix-1.0.checksums b/steps/kexec-fiwix-1.0/kexec-fiwix-1.0.checksums index f3e5b34..61d7d42 100644 --- a/steps/kexec-fiwix-1.0/kexec-fiwix-1.0.checksums +++ b/steps/kexec-fiwix-1.0/kexec-fiwix-1.0.checksums @@ -1 +1 @@ -f8c754de5bd9cf5a1b36dfea25e81f7b39c4e0145e10eebafccc8cdca5be91bd /usr/bin/kexec-fiwix +d4f502384ab723ae4b3bf33e8024a93c71cba8481f8065182a8f21ffff0fbd6d /usr/bin/kexec-fiwix diff --git a/steps/kexec-fiwix-1.0/src/kexec-fiwix.c b/steps/kexec-fiwix-1.0/src/kexec-fiwix.c index 7443bf4..4c4826d 100644 --- a/steps/kexec-fiwix-1.0/src/kexec-fiwix.c +++ b/steps/kexec-fiwix-1.0/src/kexec-fiwix.c @@ -82,7 +82,7 @@ int main() { char *bare_metal = getenv("BARE_METAL"); if (bare_metal != NULL && strcmp(bare_metal, "True") == 0) { - sprintf(cmdline, "fiwix root=/dev/ram0 ramdisksize=%d initrd=fiwix.ext2 kexec_proto=linux kexec_size=%d kexec_cmdline=\"init=/init consoleblank=0\"", INITRD_MB * 1024, KEXEC_MB * 1024); + sprintf(cmdline, "fiwix console=/dev/tty1 root=/dev/ram0 ramdisksize=%d initrd=fiwix.ext2 kexec_proto=linux kexec_size=%d kexec_cmdline=\"init=/init consoleblank=0\"", INITRD_MB * 1024, KEXEC_MB * 1024); } else {