From fca374793b023eb5881bffe8816eb7e70b91f0e2 Mon Sep 17 00:00:00 2001 From: Simon Rettberg Date: Thu, 11 Jul 2024 10:26:10 +0200 Subject: Update dracut patch; make failing patches fatal - Check for /.console_lock before trying to drop another shell - Silence systemd console output before spawning shell --- build-initramfs.sh | 3 +- patches/dracut/dracut-lib.sh.patch | 65 +++++++++++++++++++++++++++++++------- 2 files changed, 56 insertions(+), 12 deletions(-) diff --git a/build-initramfs.sh b/build-initramfs.sh index 188369e4..2bea05c4 100755 --- a/build-initramfs.sh +++ b/build-initramfs.sh @@ -127,7 +127,8 @@ bootstrap() { for patch in "${_repo_dir}/patches/${_ref[path]##*/}/"*.patch; do [ -s "$patch" ] || continue if ! patch -p1 < "$patch"; then - echo "Applying '$patch' failed, expecting errors. Continuing..." + echo "ERROR: Applying '$patch' failed" + exit 1 fi done popd || exit 1 diff --git a/patches/dracut/dracut-lib.sh.patch b/patches/dracut/dracut-lib.sh.patch index b285a6b0..accc42bc 100644 --- a/patches/dracut/dracut-lib.sh.patch +++ b/patches/dracut/dracut-lib.sh.patch @@ -1,26 +1,69 @@ +diff --git a/modules.d/98dracut-systemd/dracut-emergency.sh b/modules.d/98dracut-systemd/dracut-emergency.sh +index c6637a5c..19fc4948 100755 +--- a/modules.d/98dracut-systemd/dracut-emergency.sh ++++ b/modules.d/98dracut-systemd/dracut-emergency.sh +@@ -42,6 +42,11 @@ else + [ -z "$_emergency_action" ] && _emergency_action=halt + fi + ++if ! getarg splash; then ++ # Enable systemd output again ++ /bin/kill -SIGRTMIN+20 1 ++fi ++ + /bin/rm -f -- /.console_lock + + case "$_emergency_action" in diff --git a/modules.d/99base/dracut-lib.sh b/modules.d/99base/dracut-lib.sh -index 99cb9dbc..af3b62f3 100755 +index 39609d82..8e28789a 100755 --- a/modules.d/99base/dracut-lib.sh +++ b/modules.d/99base/dracut-lib.sh -@@ -1134,10 +1134,14 @@ emergency_shell() +@@ -945,7 +945,13 @@ _emergency_shell() { fi + [ -c "$_ctty" ] || _ctty=/dev/tty1 + case "$(/usr/bin/setsid --help 2>&1)" in *--ctty*) CTTY="--ctty" ;; esac ++ : > /.console_lock + setsid $CTTY /bin/sh -i -l 0<> $_ctty 1<> $_ctty 2<> $_ctty ++ rm -f -- /.console_lock ++ if ! getarg splash; then ++ # Enable systemd output again ++ /bin/kill -SIGRTMIN+20 1 ++ fi + fi + } + +@@ -955,6 +961,8 @@ emergency_shell() { + local _rdshell_name="dracut" action="Boot" hook="emergency" + local _emergency_action + ++ [ -e /.console_lock ] && return 0 ++ + if [ "$1" = "-n" ]; then + _rdshell_name=$2 + shift 2 +@@ -964,11 +972,16 @@ emergency_shell() { + hook="shutdown-emergency" shift 2 fi - -- echo ; echo +- echo +- echo - warn "$*" -+ if getarg splash; then -+ echo -en '\033[2J' > /dev/tty1 -+ fi +- echo + { -+ # clear fbsplash -+ echo "$@" - echo ++ # clear fbsplash ++ if getarg splash; then ++ echo -en '\033[2J' ++ fi ++ echo "$*" ++ echo + } > /dev/tty1 ++ # Disable systemd output ++ /bin/kill -SIGRTMIN+21 1 _emergency_action=$(getarg rd.emergency) [ -z "$_emergency_action" ] \ -@@ -1150,6 +1154,16 @@ emergency_shell() +@@ -981,6 +994,16 @@ emergency_shell() { source_hook "$hook" warn "$action has failed. To debug this issue add \"rd.shell rd.debug\" to the kernel command line." [ -z "$_emergency_action" ] && _emergency_action=halt @@ -30,7 +73,7 @@ index 99cb9dbc..af3b62f3 100755 + while [ "$delay" -gt 0 ]; do + echo -e "System will ${_emergency_action} in $delay seconds or upon key press."'\e[1A\e[K' + (( delay-- )) -+ sleep 1 ++ sleep 1 + done & + } > /dev/tty1 + read -s -t 60 -n 1 bs < /dev/tty1 -- cgit v1.2.3-55-g7522