diff --git a/include/tests_kernel b/include/tests_kernel index a5725083..369d3727 100644 --- a/include/tests_kernel +++ b/include/tests_kernel @@ -627,7 +627,7 @@ fi # 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" FIND=$(${LSBINARY} ${ROOTDIR}boot/* 2> /dev/null) if [ -n "${FIND}" ]; then @@ -653,18 +653,17 @@ else ReportException "${TEST_NO}:1" "Can't determine kernel version on disk, need debug data" 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 - if [ -L ${ROOTDIR}boot/vmlinuz-linux ]; then - LogText "Result: found symlink ${ROOTDIR}boot/vmlinuz-linux" - FOUND_VMLINUZ=$(readlink ${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 ] || [ -f ${ROOTDIR}boot/vmlinuz-linux-lts ] || [ -f "$(${LSBINARY} -t ${ROOTDIR}boot/vm[l0-9]* 2> /dev/null | ${HEADBINARY} -1)" ]; then + if [ -f ${ROOTDIR}boot/vmlinuz-linux ]; then + LogText "Result: found ${ROOTDIR}boot/vmlinuz-linux" + FOUND_VMLINUZ=${ROOTDIR}boot/vmlinuz-linux 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 else # 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 if [ -L "${FOUND_VMLINUZ}" ]; then @@ -676,7 +675,6 @@ fi if [ -z "${VERSION_ON_DISK}" ]; then - LogText "Result: found ${FOUND_VMLINUZ}" LogText "Test: checking kernel version on disk" NEXTLINE=0 VERSION_ON_DISK="" @@ -689,6 +687,11 @@ if [ "${I}" = "version" ]; then NEXTLINE=1; fi fi 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 LogText "Result: found version ${VERSION_ON_DISK}" 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" 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 if [ -L ${ROOTDIR}boot/vmlinuz ]; then LogText "Result: found symlink of ${ROOTDIR}boot/vmlinuz, skipping file"