From a053f03e403e96c432364e409e1e35cfe670a96a Mon Sep 17 00:00:00 2001 From: Chris Hofstaedtler Date: Fri, 3 Jan 2025 22:47:42 +0100 Subject: [PATCH 1/5] live.hook: extract grml-specifics into grml.hook --- backend/initramfs-tools/grml.hook | 21 +++++++++++++++++++++ backend/initramfs-tools/live.hook | 18 ------------------ 2 files changed, 21 insertions(+), 18 deletions(-) create mode 100755 backend/initramfs-tools/grml.hook diff --git a/backend/initramfs-tools/grml.hook b/backend/initramfs-tools/grml.hook new file mode 100755 index 0000000..54efc47 --- /dev/null +++ b/backend/initramfs-tools/grml.hook @@ -0,0 +1,21 @@ +#!/bin/sh + +set -e + +if [ -r /etc/grml_version ] +then + cp /etc/grml_version "${DESTDIR}"/etc +fi + +# vlan support +if [ -x /sbin/vconfig ] +then + copy_exec /sbin/vconfig + manual_add_modules 8021q +fi + +if [ -x /sbin/ethtool ] +then + copy_exec /sbin/ethtool +fi + diff --git a/backend/initramfs-tools/live.hook b/backend/initramfs-tools/live.hook index 7a2bd13..ee89c45 100755 --- a/backend/initramfs-tools/live.hook +++ b/backend/initramfs-tools/live.hook @@ -16,12 +16,6 @@ do fi done -# Grml version information: -if [ -r /etc/grml_version ] -then - cp /etc/grml_version "${DESTDIR}"/etc -fi - # Checking live-boot if [ ! -e /bin/live-boot ] then @@ -257,16 +251,4 @@ then echo "hosts: files dns" > "${DESTDIR}/etc/nsswitch.conf" fi -# vlan support -if [ -x /sbin/vconfig ] -then - copy_exec /sbin/vconfig - manual_add_modules 8021q -fi - -if [ -x /sbin/ethtool ] -then - copy_exec /sbin/ethtool -fi - [ "${QUIET}" ] || echo . From 83b85dee337dfa728ea47db86ac4b0be9ca6abb1 Mon Sep 17 00:00:00 2001 From: Chris Hofstaedtler Date: Fri, 3 Jan 2025 23:27:25 +0100 Subject: [PATCH 2/5] 9990-initramfs-tools.sh: extract our panic into 9995-panic.sh --- components/9990-initramfs-tools.sh | 16 +++----- components/9995-panic.sh | 59 ++++++++++++++++++++++++++++++ 2 files changed, 64 insertions(+), 11 deletions(-) create mode 100755 components/9995-panic.sh diff --git a/components/9990-initramfs-tools.sh b/components/9990-initramfs-tools.sh index e6b4282..b251754 100755 --- a/components/9990-initramfs-tools.sh +++ b/components/9990-initramfs-tools.sh @@ -52,20 +52,14 @@ panic() printf "\n\n" printf " \033[1;37mBOOT FAILED!\033[0m\n" printf "\n" - printf " This image failed to boot.\n\n" + printf " This Live System image failed to boot.\n\n" - printf " Please file a bug at your distributors bug tracking system, making\n" - printf " sure to note the exact version, name and distribution of the image\n" - printf " you were attempting to boot.\n\n" - - if [ -r /etc/grml_version ] - then - GRML_VERSION="$(cat /etc/grml_version)" - printf " $GRML_VERSION\n\n" - fi + printf " Please file a bug against the 'live-boot' package or email the Debian Live\n" + printf " mailing list at , making sure to note the\n" + printf " exact version, name and distribution of the image you were attempting to boot.\n\n" printf " The file ${LIVELOG} contains some debugging information but booting with the\n" - printf " ${DEBUG}=1 command-line parameter will greatly increase its verbosity which is\n" + printf " ${DEBUG} command-line parameter will greatly increase its verbosity which is\n" printf " extremely useful when diagnosing issues.\n\n" if [ -n "${panic}" ]; then diff --git a/components/9995-panic.sh b/components/9995-panic.sh new file mode 100755 index 0000000..8f3523d --- /dev/null +++ b/components/9995-panic.sh @@ -0,0 +1,59 @@ +#!/bin/sh + +#set -e + +# Override panic from scripts/functions, _AND_ from 9990-initramfs-tools.sh +panic() +{ + for _PARAMETER in ${LIVE_BOOT_CMDLINE} + do + case "${_PARAMETER}" in + panic=*) + panic="${_PARAMETER#*panic=}" + ;; + esac + done + + DEB_1="\033[1;31m .''\`. \033[0m" + DEB_2="\033[1;31m: :' : \033[0m" + DEB_3="\033[1;31m\`. \`'\` \033[0m" + DEB_4="\033[1;31m \`- \033[0m" + + LIVELOG="\033[1;37m/boot.log\033[0m" + DEBUG="\033[1;37mdebug\033[0m" + + # Reset redirections to avoid buffering + exec 1>&6 6>&- + exec 2>&7 7>&- + kill ${tailpid} + + printf "\n\n" + printf " \033[1;37mBOOT FAILED!\033[0m\n" + printf "\n" + printf " This image failed to boot.\n\n" + + printf " Please file a bug at your distributors bug tracking system, making\n" + printf " sure to note the exact version, name and distribution of the image\n" + printf " you were attempting to boot.\n\n" + + if [ -r /etc/grml_version ] + then + GRML_VERSION="$(cat /etc/grml_version)" + printf " $GRML_VERSION\n\n" + fi + + printf " The file ${LIVELOG} contains some debugging information but booting with the\n" + printf " ${DEBUG}=1 command-line parameter will greatly increase its verbosity which is\n" + printf " extremely useful when diagnosing issues.\n\n" + + if [ -n "${panic}" ]; then + printf " live-boot will now restart your system. " + else + printf " live-boot will now start a shell. " + fi + printf "The error message was:\n\n " + + # Call original panic + . /scripts/functions + panic "$@" +} From bbf3284c2a87d0ca1d5a1da3dbf1bbcb9f1383ff Mon Sep 17 00:00:00 2001 From: Chris Hofstaedtler Date: Fri, 3 Jan 2025 23:34:12 +0100 Subject: [PATCH 3/5] Move mdadm.conf deletion logic into a build-time hook Don't need to do this at boot time, and this eases the patching too. --- .../initramfs-tools/grml_rm_mdadm_conf.hook | 27 +++++++++++++++++++ components/9990-misc-helpers.sh | 15 ----------- 2 files changed, 27 insertions(+), 15 deletions(-) create mode 100755 backend/initramfs-tools/grml_rm_mdadm_conf.hook diff --git a/backend/initramfs-tools/grml_rm_mdadm_conf.hook b/backend/initramfs-tools/grml_rm_mdadm_conf.hook new file mode 100755 index 0000000..2de66b9 --- /dev/null +++ b/backend/initramfs-tools/grml_rm_mdadm_conf.hook @@ -0,0 +1,27 @@ +#!/bin/sh +# +# The mdadm hook installs /etc/mdadm/mdadm.conf from the build chroot +# into the initramfs. This contains the build host configuration, and +# is certainly wrong for the live system. +# +# This hook deletes the installed mdadm.conf, so mdadm default +# behaviour runs once again. + +set -eu + +PREREQ="mdadm" +prereqs() +{ + echo "$PREREQ" +} + +case "${1:-}" in + prereqs) + prereqs + exit 0 + ;; +esac + +DESTMDADMCONF=$DESTDIR/etc/mdadm/mdadm.conf +rm -f "$DESTMDADMCONF" + diff --git a/components/9990-misc-helpers.sh b/components/9990-misc-helpers.sh index d14b072..535d592 100755 --- a/components/9990-misc-helpers.sh +++ b/components/9990-misc-helpers.sh @@ -268,21 +268,6 @@ check_dev () # Adding raid support if [ -x /scripts/local-block/mdadm ] then - # Before actually doing anything, make sure that no auto-generated - # mdadm.conf is around in the initramfs. - # Short explanation of why this is needed: - # /usr/share/initramfs-tools/hooks/mdadm is executed as part of - # mkinitramfs, which generates an /etc/mdadm/mdadm.conf file if one - # doesn't exist yet (which should always be the case in our new - # chroot) based on the host system configuration. Eventually, this - # is copied into the generated initramfs and then causes issues on - # other systems. - # It's safe to delete the file within the initramfs. The actual - # squashfs root will not be affected by that (and, additionally, - # a FAI script makes sure that the mdadm.conf in there gets wiped - # of any auto-generated arrays). - rm -rf '/etc/mdadm/mdadm.conf' - # Back in the day, when there was still a local-top mdadm script, we # used to select specific devices to be auto-assembled. # This functionality was dropped in the local-block script, so just From 3d1b3ca78d719f4353c88af924483dec5ecb0ecd Mon Sep 17 00:00:00 2001 From: Chris Hofstaedtler Date: Sat, 4 Jan 2025 00:15:43 +0100 Subject: [PATCH 4/5] 9990-misc-helpers.sh: extract our bootid code into 9995-bootid.sh --- components/9990-misc-helpers.sh | 38 +------------------------------- components/9995-bootid.sh | 39 +++++++++++++++++++++++++++++++++ 2 files changed, 40 insertions(+), 37 deletions(-) create mode 100755 components/9995-bootid.sh diff --git a/components/9990-misc-helpers.sh b/components/9990-misc-helpers.sh index 535d592..8bdea8b 100755 --- a/components/9990-misc-helpers.sh +++ b/components/9990-misc-helpers.sh @@ -15,42 +15,6 @@ is_live_path() return 1 } -grml_match_bootid() -{ - path="$1" - - if [ -n "$IGNORE_BOOTID" ] ; then - echo " * Ignoring verification of bootid.txt as requested via ignore_bootid.">>/boot.log - return 0 - fi - - if [ -n "$BOOTID" ] && ! [ -r "${path}/conf/bootid.txt" ] ; then - echo " * Warning: bootid=... specified but no bootid.txt found on currently requested device.">>/boot.log - return 1 - fi - - [ -r "${path}/conf/bootid.txt" ] || return 0 - - bootid_conf=$(cat "${path}/conf/bootid.txt") - - if [ -z "$BOOTID" -a -z "$IGNORE_BOOTID" ] - then - echo " * Warning: bootid.txt found but ignore_bootid / bootid=.. bootoption missing...">>/boot.log - return 1 - fi - - if [ "$BOOTID" = "$bootid_conf" ] - then - echo " * Successfully verified /conf/bootid.txt from ISO, continuing... ">>/boot.log - else - echo " * Warning: BOOTID of ISO does not match. Retrying and continuing search...">>/boot.log - return 1 - fi - - return 0 -} - - matches_uuid () { if [ "${IGNORE_UUID}" ] || [ ! -e /conf/uuid.conf ] @@ -378,7 +342,7 @@ check_dev () fi if is_live_path ${mountpoint} && \ - ([ "${skip_uuid_check}" ] || grml_match_bootid ${mountpoint}) + ([ "${skip_uuid_check}" ] || matches_uuid ${mountpoint}) then echo ${mountpoint} return 0 diff --git a/components/9995-bootid.sh b/components/9995-bootid.sh new file mode 100755 index 0000000..f306620 --- /dev/null +++ b/components/9995-bootid.sh @@ -0,0 +1,39 @@ +#!/bin/sh + +#set -e + +# override matches_uuid from 9990-misc-helpers.sh to implement grml bootid feature +matches_uuid () +{ + path="$1" + + if [ -n "$IGNORE_BOOTID" ] ; then + echo " * Ignoring verification of bootid.txt as requested via ignore_bootid.">>/boot.log + return 0 + fi + + if [ -n "$BOOTID" ] && ! [ -r "${path}/conf/bootid.txt" ] ; then + echo " * Warning: bootid=... specified but no bootid.txt found on currently requested device.">>/boot.log + return 1 + fi + + [ -r "${path}/conf/bootid.txt" ] || return 0 + + bootid_conf=$(cat "${path}/conf/bootid.txt") + + if [ -z "$BOOTID" -a -z "$IGNORE_BOOTID" ] + then + echo " * Warning: bootid.txt found but ignore_bootid / bootid=.. bootoption missing...">>/boot.log + return 1 + fi + + if [ "$BOOTID" = "$bootid_conf" ] + then + echo " * Successfully verified /conf/bootid.txt from ISO, continuing... ">>/boot.log + else + echo " * Warning: BOOTID of ISO does not match. Retrying and continuing search...">>/boot.log + return 1 + fi + + return 0 +} From 2465ab05694854548e6e10a58f0bd4287e4be939 Mon Sep 17 00:00:00 2001 From: Chris Hofstaedtler Date: Sat, 4 Jan 2025 00:23:40 +0100 Subject: [PATCH 5/5] 9990-cmdline-old: extract our bootid code into 9995-cmdline.sh --- components/9990-cmdline-old | 20 -------------------- components/9995-cmdline.sh | 35 +++++++++++++++++++++++++++++++++++ 2 files changed, 35 insertions(+), 20 deletions(-) create mode 100755 components/9995-cmdline.sh diff --git a/components/9990-cmdline-old b/components/9990-cmdline-old index 1504e1e..652f0a4 100755 --- a/components/9990-cmdline-old +++ b/components/9990-cmdline-old @@ -24,11 +24,6 @@ Cmdline_old () unset DNS ;; - bootid=*) - BOOTID="${_PARAMETER#bootid=}" - export BOOTID - ;; - dhcp) # Force dhcp even while netbooting # Use for debugging in case somebody works on fixing dhclient @@ -92,11 +87,6 @@ Cmdline_old () export FROMISO ;; - ignore_bootid) - IGNORE_BOOTID="Yes" - export IGNORE_BOOTID - ;; - ignore_uuid) IGNORE_UUID="true" export IGNORE_UUID @@ -158,11 +148,6 @@ Cmdline_old () export NFS_COW ;; - nodhcphostname) - NODHCPHOSTNAME="Yes" - export NODHCPHOSTNAME - ;; - nofstab) NOFSTAB="true" export NOFSTAB @@ -269,11 +254,6 @@ Cmdline_old () UNIONTYPE="${_PARAMETER#union=}" export UNIONTYPE ;; - - vlan=*) - VLANS="${VLANS} ${_PARAMETER#vlan=}" - export VLANS - ;; esac done diff --git a/components/9995-cmdline.sh b/components/9995-cmdline.sh new file mode 100755 index 0000000..1e034af --- /dev/null +++ b/components/9995-cmdline.sh @@ -0,0 +1,35 @@ +#!/bin/sh + +#set -e + +Cmdline_old () +{ + for _PARAMETER in ${LIVE_BOOT_CMDLINE} + do + case "${_PARAMETER}" in + bootid=*) + BOOTID="${_PARAMETER#bootid=}" + export BOOTID + ;; + + ignore_bootid) + IGNORE_BOOTID="Yes" + export IGNORE_BOOTID + ;; + + nodhcphostname) + NODHCPHOSTNAME="Yes" + export NODHCPHOSTNAME + ;; + + vlan=*) + VLANS="${VLANS} ${_PARAMETER#vlan=}" + export VLANS + ;; + esac + done + + # Call original function + . /usr/lib/live/boot/9990-cmdline-old + Cmdline_old "$@" +}