From 6df7039ba142faf46b9ea7ebadc69ec41134f2bb Mon Sep 17 00:00:00 2001 From: Jan Grant Date: Wed, 19 Mar 2014 14:17:58 +0000 Subject: [PATCH] Parameterise PXE kernel and initrd selection When using custom-built kernels, their filenames may not necessarily follow the standard naming conventions for the stock systems in question. This patch permits the specification of an alternative pattern to use when looking for the correct kernel to construct the PXE images from. Example: export DIB_BAREMETAL_KERNEL_PATTERN="kernel*jang" export DIB_BAREMETAL_INITRD_PATTERN="initrd*jang" Change-Id: I86e5254051addd5e89dd4e363e9bba117e65353d --- elements/baremetal/README.md | 8 ++++++++ .../baremetal/cleanup.d/99-extract-kernel-and-ramdisk | 5 ++++- 2 files changed, 12 insertions(+), 1 deletion(-) diff --git a/elements/baremetal/README.md b/elements/baremetal/README.md index 9c6482450..bfbbb2d93 100644 --- a/elements/baremetal/README.md +++ b/elements/baremetal/README.md @@ -3,3 +3,11 @@ This is the baremetal (IE: real hardware) element. Does the following: * extracts the kernel and initial ramdisk of the built image. + +Optional parameters: + + * DIB_BAREMETAL_KERNEL_PATTERN and DIB_BAREMETAL_INITRD_PATTERN + may be supplied to specify which kernel files are preferred; this + can be of use when using custom kernels that don't fit the + standard naming patterns. Both variables must be provided in + order for them to have any effect. diff --git a/elements/baremetal/cleanup.d/99-extract-kernel-and-ramdisk b/elements/baremetal/cleanup.d/99-extract-kernel-and-ramdisk index 6c136577b..21cfb0a17 100755 --- a/elements/baremetal/cleanup.d/99-extract-kernel-and-ramdisk +++ b/elements/baremetal/cleanup.d/99-extract-kernel-and-ramdisk @@ -23,7 +23,10 @@ set -o pipefail BOOTDIR="$TARGET_ROOT/boot" KERNEL= RAMDISK= -if [ -f $TARGET_ROOT/etc/redhat-release ]; then +if [ -n "${DIB_BAREMETAL_KERNEL_PATTERN:-}" -a -n "${DIB_BAREMETAL_INITRD_PATTERN:-}" ]; then + KERNEL=$(basename `eval ls -1rv "$BOOTDIR/${DIB_BAREMETAL_KERNEL_PATTERN}" | head -1`) + RAMDISK=$(basename `eval ls -1rv "$BOOTDIR/${DIB_BAREMETAL_INITRD_PATTERN}" | head -1`) +elif [ -f $TARGET_ROOT/etc/redhat-release ]; then # Prioritize PAE if present KERNEL=$(ls -1rv $BOOTDIR/vmlinuz* | grep PAE | grep -v debug | head -1 || echo "")