From b0bee6584389dec8fbfe95176246b22904e861a6 Mon Sep 17 00:00:00 2001 From: Michael Boelen Date: Wed, 21 Jul 2021 15:26:48 +0200 Subject: KRNL-5830: sort kernels by version (ls -v) instead of date on disk (ls -t) --- include/tests_kernel | 5 +++-- 1 file changed, 3 insertions(+), 2 deletions(-) (limited to 'include/tests_kernel') diff --git a/include/tests_kernel b/include/tests_kernel index 19ed4dae..610fd325 100644 --- a/include/tests_kernel +++ b/include/tests_kernel @@ -673,9 +673,9 @@ LogText "Result: found ${ROOTDIR}boot/vmlinuz-lts" FOUND_VMLINUZ=${ROOTDIR}boot/vmlinuz-lts else - # Match on items like /boot/vm5.3.7 or /boot/vmlinuz-5.3.7-1-default. Get newest file (ls -t and pipe into head) + # Match on items like /boot/vm5.3.7 or /boot/vmlinuz-5.3.7-1-default. Sort based on versions (-v) and then find the last item # Note: ignore a rescue kernel (e.g. CentOS) - FOUND_VMLINUZ=$(${LSBINARY} -t ${ROOTDIR}boot/vm[l0-9]* 2> /dev/null | ${GREPBINARY} -v '\-rescue\-' | ${HEADBINARY} -1) + FOUND_VMLINUZ=$(${LSBINARY} -v ${ROOTDIR}boot/vm[l0-9]* 2> /dev/null | ${GREPBINARY} -v '\-rescue\-' | ${TAILBINARY} -1) LogText "Result: found ${FOUND_VMLINUZ}" fi @@ -749,6 +749,7 @@ done # Display kernels, extract version numbers and ${SORTBINARY} them numeric per column (up to 6 numbers) # Ignore rescue images. Remove generic. and huge. for Slackware machines + # TODO: see if this can be simplified using ls -v sorting LogText "Action: checking relevant kernels" KERNELS=$(${LSBINARY} /boot/vmlinuz* | ${GREPBINARY} -v rescue | ${SEDBINARY} 's/vmlinuz-//' | ${SEDBINARY} 's/generic.//' | ${SEDBINARY} 's/huge.//' | ${SEDBINARY} 's/\.[a-z].*.//g' | ${SEDBINARY} 's/-[a-z].*.//g' | ${SEDBINARY} 's./boot/..' | ${SEDBINARY} 's/-/./g' | ${SORTBINARY} -n -k1,1 -k2,2 -k3,3 -k4,4 -k5,5 -k6,6 -t \.) KERNELS_ONE_LINE=$(${ECHOCMD} ${KERNELS} | ${TRBINARY} '\n' ' ') -- cgit v1.2.3