From: ikelos Date: Sat, 29 Dec 2018 19:01:10 +0000 (+0000) Subject: Improve kernel-install support for initrd files. (#11281) X-Git-Tag: v241-rc1~139 X-Git-Url: http://git.ipfire.org/gitweb.cgi?a=commitdiff_plain;h=04ca4d191b13e79e5701ed22dc972f08628d7bcc;p=thirdparty%2Fsystemd.git Improve kernel-install support for initrd files. (#11281) The current support in kernel-install for initrd images doesn't copy over the initrd file or allow a means for it to be specified (it requires a specific filename in a particular directory). This patchset adds support for (optionally) providing the name of initial ramdisk file to copied over and used by kernel-install. --- diff --git a/man/kernel-install.xml b/man/kernel-install.xml index 83e50c8d708..84204df150b 100644 --- a/man/kernel-install.xml +++ b/man/kernel-install.xml @@ -28,7 +28,8 @@ kernel-install COMMAND KERNEL-VERSION - KERNEL-IMAGE + KERNEL-IMAGE + INITRD-FILE @@ -61,7 +62,7 @@ The following commands are understood: - add KERNEL-VERSION KERNEL-IMAGE + 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 @@ -69,7 +70,7 @@ and 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 + add KERNEL-VERSION /boot/MACHINE-ID/KERNEL-VERSION/ KERNEL-IMAGE INITRD-FILE Two default plugins execute the following operations in this case: @@ -83,14 +84,15 @@ 90-loaderentry.install copies KERNEL-IMAGE to /boot/MACHINE-ID/KERNEL-VERSION/linux. + If INITRD-FILE is provided, it also copies INITRD-FILE + to + /boot/MACHINE-ID/KERNEL_VERSION/initrd. It also creates a boot loader entry according to the Boot Loader Specification in /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. If the file - initrd is found next to the kernel image file, the initrd will be added to the - configuration. + missing), or "Linux KERNEL-VERSION", if unset. diff --git a/src/kernel-install/90-loaderentry.install b/src/kernel-install/90-loaderentry.install index 39ec8a69c66..3437bb3cbcb 100644 --- a/src/kernel-install/90-loaderentry.install +++ b/src/kernel-install/90-loaderentry.install @@ -6,6 +6,7 @@ COMMAND="$1" KERNEL_VERSION="$2" BOOT_DIR_ABS="$3" KERNEL_IMAGE="$4" +INITRD_FILE="$5" if ! [[ $KERNEL_INSTALL_MACHINE_ID ]]; then exit 0 @@ -82,6 +83,15 @@ cp "$KERNEL_IMAGE" "$BOOT_DIR_ABS/linux" && exit 1 } +if [[ -f "${INITRD_FILE}" ]]; then + cp "${INITRD_FILE}" "$BOOT_DIR_ABS/initrd" && + chown root:root "$BOOT_DIR_ABS/initrd" && + chmod 0644 "$BOOT_DIR_ABS/initrd" || { + echo "Could not copy '$INITRD_FILE' to '$BOOT_DIR_ABS/initrd'." >&2 + exit 1 + } +fi + mkdir -p "${LOADER_ENTRY%/*}" || { echo "Could not create loader entry directory '${LOADER_ENTRY%/*}'." >&2 exit 1 diff --git a/src/kernel-install/kernel-install b/src/kernel-install/kernel-install index 732d584bbe4..7240df904c7 100644 --- a/src/kernel-install/kernel-install +++ b/src/kernel-install/kernel-install @@ -24,7 +24,7 @@ SKIP_REMAINING=77 usage() { echo "Usage:" - echo " $0 add KERNEL-VERSION KERNEL-IMAGE" + echo " $0 add KERNEL-VERSION KERNEL-IMAGE [INITRD-FILE]" echo " $0 remove KERNEL-VERSION" } @@ -72,6 +72,7 @@ fi KERNEL_VERSION="$1" KERNEL_IMAGE="$2" +INITRD_FILE="$3" if [[ -f /etc/machine-id ]]; then read MACHINE_ID < /etc/machine-id @@ -123,7 +124,7 @@ case $COMMAND in for f in "${PLUGINS[@]}"; do if [[ -x $f ]]; then - "$f" add "$KERNEL_VERSION" "$BOOT_DIR_ABS" "$KERNEL_IMAGE" + "$f" add "$KERNEL_VERSION" "$BOOT_DIR_ABS" "$KERNEL_IMAGE" "$INITRD_FILE" x=$? if [[ $x == $SKIP_REMAINING ]]; then ret=0