diff --git a/man/kernel-install.xml b/man/kernel-install.xml index db0a0b8256..73b582c848 100644 --- a/man/kernel-install.xml +++ b/man/kernel-install.xml @@ -67,17 +67,20 @@ add KERNEL-VERSION KERNEL-IMAGE [INITRD-FILE ...] This command expects a kernel version string and a path to a kernel image file as - arguments. kernel-install creates the directory - /boot/MACHINE-ID/KERNEL-VERSION/ - and calls the executables from /usr/lib/kernel/install.d/*.install and + arguments. kernel-install calls the executables from + /usr/lib/kernel/install.d/*.install and /etc/kernel/install.d/*.install with the following arguments: add KERNEL-VERSION /boot/MACHINE-ID/KERNEL-VERSION/ KERNEL-IMAGE [INITRD-FILE ...] - Two default plugins execute the following operations in this case: + Three default plugins execute the following operations in this case: + 00-entry-directory.install creates the directory + /boot/MACHINE-ID/KERNEL-VERSION/ + if /boot/MACHINE-ID/ already exists. + 50-depmod.install runs depmod8 for the @@ -94,7 +97,11 @@ /boot/loader/entries/MACHINE-ID-KERNEL-VERSION.conf. The title of the entry is the PRETTY_NAME parameter specified in /etc/os-release or /usr/lib/os-release (if the former is - missing), or "Linux KERNEL-VERSION", if unset. + missing), or "Linux KERNEL-VERSION", if unset. + + If the entry directory + /boot/MACHINE-ID/KERNEL-VERSION/ + does not exist, this plugin does nothing. diff --git a/src/kernel-install/00-entry-directory.install b/src/kernel-install/00-entry-directory.install new file mode 100644 index 0000000000..2aa8c58319 --- /dev/null +++ b/src/kernel-install/00-entry-directory.install @@ -0,0 +1,32 @@ +#!/bin/bash +# -*- mode: shell-script; indent-tabs-mode: nil; sh-basic-offset: 4; -*- +# ex: ts=8 sw=4 sts=4 et filetype=sh + +COMMAND="$1" +KERNEL_VERSION="$2" +ENTRY_DIR_ABS="$3" +KERNEL_IMAGE="$4" +INITRD_OPTIONS_START="5" + +if ! [[ $KERNEL_INSTALL_MACHINE_ID ]]; then + exit 0 +fi + +if [[ $COMMAND != add ]]; then + exit 0 +fi + +# If the boot dir exists (e.g. $ESP/), +# create the entry directory ($ESP//). +# This is the only function of this plugin. +MACHINE_ID_DIR="${ENTRY_DIR_ABS%/*}" +if ! [ -d "$MACHINE_ID_DIR" ]; then + exit 0 +fi + +if [ "$KERNEL_INSTALL_VERBOSE" -gt 0 ]; then + echo "+mkdir -v -p $ENTRY_DIR_ABS" + exec mkdir -v -p "$ENTRY_DIR_ABS" +else + exec mkdir -p "$ENTRY_DIR_ABS" +fi diff --git a/src/kernel-install/kernel-install b/src/kernel-install/kernel-install index fcf36f181f..610959ba9f 100644 --- a/src/kernel-install/kernel-install +++ b/src/kernel-install/kernel-install @@ -125,11 +125,6 @@ case $COMMAND in exit 1 fi - mkdir -p "$ENTRY_DIR_ABS" || { - echo "Could not create boot directory '$ENTRY_DIR_ABS'." >&2 - exit 1 - } - for f in "${PLUGINS[@]}"; do if [[ -x $f ]]; then [ "$KERNEL_INSTALL_VERBOSE" -gt 0 ] && \ diff --git a/src/kernel-install/meson.build b/src/kernel-install/meson.build index c6e6f816d9..261c3aaae4 100644 --- a/src/kernel-install/meson.build +++ b/src/kernel-install/meson.build @@ -4,7 +4,8 @@ install_data('kernel-install', install_mode : 'rwxr-xr-x', install_dir : bindir) -install_data('50-depmod.install', +install_data('00-entry-directory.install', + '50-depmod.install', '90-loaderentry.install', install_mode : 'rwxr-xr-x', install_dir : kernelinstalldir)