diff --git a/bin/disk-image-get-kernel b/bin/disk-image-get-kernel index ac631ee7..f75bc51d 100755 --- a/bin/disk-image-get-kernel +++ b/bin/disk-image-get-kernel @@ -85,8 +85,25 @@ BOOTDIR="$WORK_DIR/boot" KERNEL= RAMDISK= if [ -f $WORK_DIR/etc/redhat-release ]; then - KERNEL=$(basename `ls -1rv $BOOTDIR/vmlinuz* | head -1`) - RAMDISK=$(basename `ls -1rv $BOOTDIR/initramfs* | head -1`) + + # Prioritize PAE if present + KERNEL=$(basename `ls -1rv $BOOTDIR/vmlinuz* | grep PAE | grep -v debug | head -1`) + if [ ! $KERNEL ]; then + KERNEL=$(basename `ls -1rv $BOOTDIR/vmlinuz* | grep -v debug | head -1`) + if [ ! $KERNEL ]; then + echo "No suitable kernel found." + exit 1 + fi + fi + + KERNEL_VERSION=`echo $KERNEL | sed 's/vmlinuz-//g'` + + RAMDISK=$(basename `ls $BOOTDIR/initramfs-$KERNEL_VERSION.img`) + if [ ! $RAMDISK ]; then + echo "Can't find an initramfs for the $KERNEL_VERSION version of the kernel." + exit 1 + fi + elif [ -f $WORK_DIR/etc/debian_version ]; then KERNEL=$(basename `ls -1rv $BOOTDIR/vmlinuz*generic | head -1`) RAMDISK=$(basename `ls -1rv $BOOTDIR/initrd*generic | head -1`)