Group :: Sistema/Kernel e hardware
RPM: grub
Main Changelog Spec Patches Sources Download Gear Bugs e FR Repocop
Patch: grub-2.02-alt-os-prober-compat.patch
Download
Download
From 76dcfb4eac3cce6fdde8d4a38d99eb6c17056cae Mon Sep 17 00:00:00 2001
From: Nikolai Kostrigin <nickel@altlinux.org>
Date: Mon, 16 Dec 2019 08:15:19 +0300
Subject: [PATCH] 30_os-prober.in: make compatible with os-prober 1.77
- skip removable devices which could most probably be installation media
to grub.cfg entries list
- rearrange submenu item strings to make kernel version visible
- filter out not matching pairs of kernels and initrd.img provided by
os-prober's 90fallback script
---
grub/util/grub.d/30_os-prober.in | 35 ++++++++++++++++++++++++++++++--
1 file changed, 33 insertions(+), 2 deletions(-)
diff --git a/grub/util/grub.d/30_os-prober.in b/grub/util/grub.d/30_os-prober.in
index 515a68c7a..3f5dc3534 100644
--- a/grub/util/grub.d/30_os-prober.in
+++ b/grub/util/grub.d/30_os-prober.in
@@ -128,6 +128,23 @@ for OS in ${OSPROBED} ; do
fi
fi
+ # Skip removable devices which could most probably be installation media
+ DEVICE_KDNAME="${DEVICE%@*}"
+ DEVICE_KDNAME="${DEVICE_KDNAME##*/}"
+ if [ "x$(echo "$DEVICE_KDNAME"| grep -e "[0-9]$")" != "x" ]; then
+ if [ "x$(echo "$DEVICE_KDNAME"| sed "s/mmcblk[0-9]$//")" != "x" ] && [ "x$(echo "$DEVICE_KDNAME"| sed "s/nvme[0-9]n[0-9]$//")" != "x" ]; then
+ DEVICE_KDNAME="$(readlink -f "/sys/class/block/$DEVICE_KDNAME/..")"
+ if [ "$?" != "0" ]; then
+ echo "Warning! No such device $DEVICE_KDNAME"
+ fi
+ fi
+ fi
+ DEVICE_KDNAME="${DEVICE_KDNAME##*/}"
+ if [ "x$(cat /sys/block/${DEVICE_KDNAME}/removable)" = "x1" ]; then
+ echo "Skipped ${LONGNAME} on removable ${DEVICE}." >&2
+ continue
+ fi
+
BTRFS="`echo ${OS} | cut -d ':' -f 5`"
if [ "x$BTRFS" = "xbtrfs" ]; then
BTRFSuuid="`echo ${OS} | cut -d ':' -f 6`"
@@ -200,7 +217,10 @@ EOF
boot_device_id=
is_top_level=true
title_correction_code=
- OS="${LONGNAME}"
+ # supress OS ALT distribution codename to shorten string length
+ # as it makes kernel versions invisible on the boot menu
+ OS="$(echo $LONGNAME| sed "/ALT/s|(.*)||")"
+
for LINUX in ${LINUXPROBED} ; do
LROOT="`echo ${LINUX} | cut -d ':' -f 1`"
@@ -211,7 +231,7 @@ EOF
LPARAMS="`echo ${LINUX} | cut -d ':' -f 6- | tr '^' ' '`"
if [ -z "${LLABEL}" ] ; then
- LLABEL="${LONGNAME}"
+ LLABEL="${OS}, ${LKERNEL}"
fi
if [ "${LROOT}" != "${LBOOT}" ]; then
@@ -219,6 +239,17 @@ EOF
LINITRD="${LINITRD#/boot}"
fi
+ # skip kernels not matching to selected initrd as os-prober's 90fallback
+ # produces a lot of weird combinations
+ FILT_LKERNEL="${LKERNEL#/*/}"
+ FILT_LINITRD="${LINITRD#/*/}"
+ FILT_LKERNEL="$(echo ${FILT_LKERNEL}| sed "s/^[\/]\{0,\}vmlinu[zx][-]\{0,\}//")"
+ FILT_LINITRD="$(echo ${FILT_LINITRD}| sed "s/^[\/]\{0,\}\(initrd\|initramfs\)[-]\{0,\}//"| sed "s/\.img[-]\{0,\}//")"
+ if [ "${FILT_LKERNEL}" != "${FILT_LINITRD}" ]; then
+ echo "Skip kernel ${LKERNEL} not matching to selected initrd ${LINITRD}" >&2
+ continue
+ fi
+
onstr="$(gettext_printf "(on %s)" "${DEVICE}")"
recovery_params="$(echo "${LPARAMS}" | grep single)" || true
counter=1
--
2.25.1