From af50ab0a86269871a5d852e8405014eb98d7c9cd Mon Sep 17 00:00:00 2001 From: ading2210 Date: Thu, 9 Nov 2023 21:13:59 +0000 Subject: [PATCH] support pre-frecon shims --- bootloader/bin/bootstrap.sh | 10 ++++------ bootloader/bin/init | 14 ++++++++++++-- build_image.sh | 1 + rootfs/etc/modules-load.d/tun.conf | 1 + 4 files changed, 18 insertions(+), 8 deletions(-) create mode 100644 rootfs/etc/modules-load.d/tun.conf diff --git a/bootloader/bin/bootstrap.sh b/bootloader/bin/bootstrap.sh index 69f0d3b..501418d 100755 --- a/bootloader/bin/bootstrap.sh +++ b/bootloader/bin/bootstrap.sh @@ -133,7 +133,7 @@ get_selection() { reboot -f elif [ "$selection" = "s" ]; then reset - enable_debug_console "/dev/pts/0" + enable_debug_console "$TTY1" return 0 elif [ "$selection" = "l" ]; then clear @@ -266,8 +266,7 @@ boot_target() { echo "switching root" mkdir -p /newroot/bootloader pivot_root /newroot /newroot/bootloader - local tty="/dev/pts/0" - exec /sbin/init < "$tty" >> "$tty" 2>&1 + exec /sbin/init < "$TTY1" >> "$TTY1" 2>&1 } boot_chromeos() { @@ -317,14 +316,13 @@ boot_chromeos() { echo "starting init" /sbin/modprobe zram pkill frecon-lite - local tty="/dev/pts/0" - exec /sbin/init < "$tty" >> "$tty" 2>&1 + exec /sbin/init < "$TTY1" >> "$TTY1" 2>&1 } main() { echo "starting the shimboot bootloader" - enable_debug_console "/dev/pts/1" + enable_debug_console "$TTY2" local valid_partitions="$(find_all_partitions)" diff --git a/bootloader/bin/init b/bootloader/bin/init index 628ac40..80efb03 100755 --- a/bootloader/bin/init +++ b/bootloader/bin/init @@ -10,6 +10,16 @@ set -x +detect_tty() { + if [ -f "/bin/frecon-lite" ]; then + export TTY1="/dev/pts/0" + export TTY2="/dev/pts/1" + else + export TTY1="/dev/tty1" + export TTY2="/dev/tty2" + fi +} + setup_environment() { # Install additional utility programs. /bin/busybox --install /bin || true @@ -17,10 +27,10 @@ setup_environment() { main() { setup_environment + detect_tty # In case an error is not handled by bootstrapping, stop here # so that an operator can see installation stop. - local tty="/dev/pts/0" - exec bootstrap.sh < "$tty" >> "$tty" 2>&1 || sleep 1d + exec bootstrap.sh < "$TTY1" >> "$TTY1" 2>&1 || sleep 1d } main "$@" diff --git a/build_image.sh b/build_image.sh index 9ff6fd0..5dcf7ef 100755 --- a/build_image.sh +++ b/build_image.sh @@ -100,6 +100,7 @@ populate_partitions() { local stateful_mount=/tmp/shim_stateful safe_mount "${image_loop}p1" $stateful_mount mkdir -p $stateful_mount/dev_image/etc/ + mkdir -p $stateful_mount/dev_image/factory/sh touch $stateful_mount/dev_image/etc/lsb-factory umount $stateful_mount diff --git a/rootfs/etc/modules-load.d/tun.conf b/rootfs/etc/modules-load.d/tun.conf new file mode 100644 index 0000000..e3ad0b7 --- /dev/null +++ b/rootfs/etc/modules-load.d/tun.conf @@ -0,0 +1 @@ +tun \ No newline at end of file