[PATCH] kernel.filetrigger: ucode support

Konstantin A. Lepikhov lakostis на altlinux.ru
Ср Сен 6 14:49:26 MSK 2017


We need to rebuild initramfs on CPU ucode changes otherwise everything
will continue use outdated version till next kernel update.
---
 kernel.filetrigger | 27 ++++++++++++++++++++++++++-
 1 file changed, 26 insertions(+), 1 deletion(-)

diff --git a/kernel.filetrigger b/kernel.filetrigger
index 9cdf01e..38ea249 100755
--- a/kernel.filetrigger
+++ b/kernel.filetrigger
@@ -9,6 +9,7 @@
 BOOTDIR=/boot
 VMLINUZ_PREFIX=/boot/vmlinuz
 MODULES_PREFIX=/lib/modules
+UCODE_PREFIX=/lib/firmware
 INITRD_AUTOUPDATE=
 
 . /etc/sysconfig/installkernel
@@ -99,6 +100,27 @@ $VERSION"
 	last_added="$VERSION"
 }
 
+ucode_handled=
+handle_ucode()
+{
+	local f VENDOR VERSION
+	f="$1"; shift
+	# filename format: $UCODE_PREFIX/<vendor>-ucode/*
+	VENDOR=${f#$UCODE_PREFIX/}
+	VENDOR=${VENDOR%%-ucode/*}
+	ucode_handled="$ucode_handled $VENDOR"
+	set +f
+	f="$(readlink -e /boot/vmlinuz)"
+	if [ -n "$f" -a -n "$kernel_versions_handled" ]; then
+		VERSION=${f#$VMLINUZ_PREFIX-}
+		case "$kernel_version_handled" in
+			"* $VERSION*")
+			ucode_handled=
+			;;
+		esac
+	fi
+}
+
 while read f; do
 	case "$f" in
 		$VMLINUZ_PREFIX-[0-9].*-*-*)
@@ -107,10 +129,13 @@ while read f; do
 		$MODULES_PREFIX/*-*-*/*/*.ko*)
 			handle_module "$f"
 			;;
+		$UCODE_PREFIX/*-ucode/*)
+			handle_ucode "$f"
+			;;
 	esac
 done
 
-if [ -n "$kernel_versions_handled" -a "$INITRD_AUTOUPDATE" = all ]; then
+if [ -n "$kernel_versions_handled" -o -n "$ucode_handled" ] && [ "$INITRD_AUTOUPDATE" = all ]; then
 	set +f
 	ls -c $VMLINUZ_PREFIX-[0-9].*-*-* 2> /dev/null | while read f; do
 		[ "$f" != "$(readlink -e /boot/vmlinuz)" ] ||
-- 
2.10.4


--UlVJffcvxoiEqYs2--


Подробная информация о списке рассылки Devel