Merge pull request #830 from Schmuuu/fix/vmlinuz-check

restructered test and fixed vmlinuz detection
This commit is contained in:
Michael Boelen 2020-03-19 10:58:27 +01:00 committed by GitHub
commit b523352a59
No known key found for this signature in database
GPG Key ID: 4AEE18F83AFDEB23
1 changed files with 13 additions and 14 deletions

View File

@ -627,7 +627,7 @@
fi fi
# Check if /boot exists # Check if /boot exists
if [ ${PRIVILEGED} -eq 1 -a -d "${ROOTDIR}boot" ]; then if [ -d "${ROOTDIR}boot" ]; then
LogText "Result: /boot exists, performing more tests from here" LogText "Result: /boot exists, performing more tests from here"
FIND=$(${LSBINARY} ${ROOTDIR}boot/* 2> /dev/null) FIND=$(${LSBINARY} ${ROOTDIR}boot/* 2> /dev/null)
if [ -n "${FIND}" ]; then if [ -n "${FIND}" ]; then
@ -653,18 +653,17 @@
else else
ReportException "${TEST_NO}:1" "Can't determine kernel version on disk, need debug data" ReportException "${TEST_NO}:1" "Can't determine kernel version on disk, need debug data"
fi fi
elif [ -f ${ROOTDIR}boot/vmlinuz-linux -o -f ${ROOTDIR}boot/vmlinuz-linux-lts -o -f $(ls -t ${ROOTDIR}boot/vm[l-]* 2> /dev/null | head -1) ]; then elif [ -f ${ROOTDIR}boot/vmlinuz-linux ] || [ -f ${ROOTDIR}boot/vmlinuz-linux-lts ] || [ -f "$(${LSBINARY} -t ${ROOTDIR}boot/vm[l0-9]* 2> /dev/null | ${HEADBINARY} -1)" ]; then
if [ -L ${ROOTDIR}boot/vmlinuz-linux ]; then if [ -f ${ROOTDIR}boot/vmlinuz-linux ]; then
LogText "Result: found symlink ${ROOTDIR}boot/vmlinuz-linux" LogText "Result: found ${ROOTDIR}boot/vmlinuz-linux"
FOUND_VMLINUZ=$(readlink ${ROOTDIR}boot/vmlinuz-linux) FOUND_VMLINUZ=${ROOTDIR}boot/vmlinuz-linux
LogText "Result: symlinked target is ${FOUND_VMLINUZ}"
VERSION_ON_DISK=$(echo ${FOUND_VMLINUZ} | ${SEDBINARY} 's/^vmlinuz-//')
elif [ -f ${ROOTDIR}boot/vmlinuz-linux-lts ]; then elif [ -f ${ROOTDIR}boot/vmlinuz-linux-lts ]; then
LogText "Result: found boot/vmlinuz-linux-lts" LogText "Result: found ${ROOTDIR}boot/vmlinuz-linux-lts"
FOUND_VMLINUZ=${ROOTDIR}boot/vmlinuz-linux-lts FOUND_VMLINUZ=${ROOTDIR}boot/vmlinuz-linux-lts
else else
# Match on /boot/vm5.3.7 or /boot/vmlinuz-5.3.7-1-default # Match on /boot/vm5.3.7 or /boot/vmlinuz-5.3.7-1-default
FOUND_VMLINUZ=$(ls -t ${ROOTDIR}boot/vm[l-]* 2> /dev/null | head -1) FOUND_VMLINUZ=$(${LSBINARY} -t ${ROOTDIR}boot/vm[l0-9]* 2> /dev/null | ${HEADBINARY} -1)
LogText "Result: found ${FOUND_VMLINUZ}"
fi fi
if [ -L "${FOUND_VMLINUZ}" ]; then if [ -L "${FOUND_VMLINUZ}" ]; then
@ -676,7 +675,6 @@
fi fi
if [ -z "${VERSION_ON_DISK}" ]; then if [ -z "${VERSION_ON_DISK}" ]; then
LogText "Result: found ${FOUND_VMLINUZ}"
LogText "Test: checking kernel version on disk" LogText "Test: checking kernel version on disk"
NEXTLINE=0 NEXTLINE=0
VERSION_ON_DISK="" VERSION_ON_DISK=""
@ -689,6 +687,11 @@
if [ "${I}" = "version" ]; then NEXTLINE=1; fi if [ "${I}" = "version" ]; then NEXTLINE=1; fi
fi fi
done done
fi
if [ -z "${VERSION_ON_DISK}" ]; then
LogText "Result: could not find the version on disk"
ReportException "${TEST_NO}:4" "Could not find the kernel version"
else else
LogText "Result: found version ${VERSION_ON_DISK}" LogText "Result: found version ${VERSION_ON_DISK}"
ACTIVE_KERNEL=$(uname -r) ACTIVE_KERNEL=$(uname -r)
@ -701,10 +704,6 @@
LogText "Result: reboot needed, as there is a difference between active kernel and the one on disk" LogText "Result: reboot needed, as there is a difference between active kernel and the one on disk"
fi fi
fi fi
if [ -z "${VERSION_ON_DISK}" ]; then
LogText "Result: could not find the version on disk"
ReportException "${TEST_NO}:4" "Could not find the kernel version"
fi
else else
if [ -L ${ROOTDIR}boot/vmlinuz ]; then if [ -L ${ROOTDIR}boot/vmlinuz ]; then
LogText "Result: found symlink of ${ROOTDIR}boot/vmlinuz, skipping file" LogText "Result: found symlink of ${ROOTDIR}boot/vmlinuz, skipping file"