diff --git a/man/kernel-install.xml b/man/kernel-install.xml index bb22443854b..bde30ab16ae 100644 --- a/man/kernel-install.xml +++ b/man/kernel-install.xml @@ -250,13 +250,18 @@ Environment variables understood by <command>kernel-install</command> + $KERNEL_INSTALL_CONF_ROOT can be set to override the location of the + configuration files read by kernel-install. When set, + install.conf, entry-token, and other files will be + read from this directory. + $MACHINE_ID can be set for kernel-install to override $KERNEL_INSTALL_MACHINE_ID, the machine ID. $BOOT_ROOT can be set for kernel-install to override $KERNEL_INSTALL_BOOT_ROOT, the installation location for boot entries. - Those variables may also be set in install.conf. Variables set in the + The last two variables may also be set in install.conf. Variables set in the environment take precedence over the values specified in the config file. @@ -286,9 +291,10 @@ Read by 90-loaderentry.install. The content of the file - /etc/kernel/cmdline specifies the kernel command line to use. If that file does not - exist, /usr/lib/kernel/cmdline is used. If that also does not exist, - /proc/cmdline is used. + /etc/kernel/cmdline specifies the kernel command line to use. If that file + does not exist, /usr/lib/kernel/cmdline is used. If that also does not + exist, /proc/cmdline is used. $KERNEL_INSTALL_CONF_ROOT + may be used to override the path. @@ -301,7 +307,8 @@ $BOOT/loader/entries/MACHINE-ID-KERNEL-VERSION+TRIES.conf. This is useful for boot loaders such as systemd-boot7 which - implement boot attempt counting with a counter embedded in the entry file name. + implement boot attempt counting with a counter embedded in the entry file name. + $KERNEL_INSTALL_CONF_ROOT may be used to override the path. @@ -310,8 +317,9 @@ If this file exists it is read and used as "entry token" for this system, i.e. is used for - naming Boot Loader Specification entries, see - $KERNEL_INSTALL_ENTRY_TOKEN above for details. + naming Boot Loader Specification entries, see $KERNEL_INSTALL_ENTRY_TOKEN + above for details. $KERNEL_INSTALL_CONF_ROOT may be used to override the + path. @@ -346,6 +354,7 @@ os-release5. /etc/kernel/install.conf will be read if present, and /usr/lib/kernel/install.conf otherwise. This file is optional. + $KERNEL_INSTALL_CONF_ROOT may be used to override the path. Currently, the following keys are supported: diff --git a/src/kernel-install/90-loaderentry.install b/src/kernel-install/90-loaderentry.install index ee559651100..b700a7b2a60 100644 --- a/src/kernel-install/90-loaderentry.install +++ b/src/kernel-install/90-loaderentry.install @@ -65,7 +65,11 @@ fi SORT_KEY="$IMAGE_ID" [ -z "$SORT_KEY" ] && SORT_KEY="$ID" -if [ -f /etc/kernel/cmdline ]; then +if [ -n "$KERNEL_INSTALL_CONF_ROOT" ]; then + if [ -f "$KERNEL_INSTALL_CONF_ROOT/cmdline" ]; then + BOOT_OPTIONS="$(tr -s "$IFS" ' ' <"$KERNEL_INSTALL_CONF_ROOT/cmdline")" + fi +elif [ -f /etc/kernel/cmdline ]; then BOOT_OPTIONS="$(tr -s "$IFS" ' ' &2 + echo "$TRIES_FILE does not contain an integer." >&2 exit 1 fi LOADER_ENTRY="$BOOT_ROOT/loader/entries/$ENTRY_TOKEN-$KERNEL_VERSION+$TRIES.conf" diff --git a/src/kernel-install/kernel-install.in b/src/kernel-install/kernel-install.in index 044ba9f6f27..96595fa295e 100755 --- a/src/kernel-install/kernel-install.in +++ b/src/kernel-install/kernel-install.in @@ -108,7 +108,9 @@ initrd_generator= _MACHINE_ID_SAVED="$MACHINE_ID" _BOOT_ROOT_SAVED="$BOOT_ROOT" -if [ -f "/etc/kernel/install.conf" ]; then +if [ -n "$KERNEL_INSTALL_CONF_ROOT" ]; then + install_conf="$KERNEL_INSTALL_CONF_ROOT/install.conf" +elif [ -f "/etc/kernel/install.conf" ]; then install_conf="/etc/kernel/install.conf" elif [ -f "/usr/lib/kernel/install.conf" ]; then install_conf="/usr/lib/kernel/install.conf" @@ -116,7 +118,7 @@ else install_conf= fi -if [ -n "$install_conf" ]; then +if [ -f "$install_conf" ]; then [ "$KERNEL_INSTALL_VERBOSE" -gt 0 ] && echo "Reading $install_conf…" # shellcheck source=/dev/null . "$install_conf" @@ -171,10 +173,12 @@ fi # $BOOT where we want to place the kernel/initrd and related resources, as well # for naming the .conf boot loader spec entry. Typically this is just the # machine ID, but it can be anything else, too, if we are told so. -if [ -z "$ENTRY_TOKEN" ] && [ -f /etc/kernel/entry-token ]; then - read -r ENTRY_TOKEN