4ee649
From 860be9427dff48efc5e486b039be932094572047 Mon Sep 17 00:00:00 2001
Harald Hoyer 2e2e24
From: Harald Hoyer <harald@redhat.com>
Zbigniew Jędrzejewski-Szmek 126222
Date: Tue, 14 Jan 2014 17:48:08 -0500
Harald Hoyer 2e2e24
Subject: [PATCH] kernel-install: add fedora specific callouts to
Harald Hoyer 2e2e24
 new-kernel-pkg
Harald Hoyer 2e2e24
Harald Hoyer 2e2e24
---
4ee649
 src/kernel-install/kernel-install | 44 +++++++++++++++++++++++++++++++++++++++
4ee649
 1 file changed, 44 insertions(+)
Harald Hoyer bd236f
 mode change 100644 => 100755 src/kernel-install/kernel-install
Harald Hoyer 2e2e24
Harald Hoyer 2e2e24
diff --git a/src/kernel-install/kernel-install b/src/kernel-install/kernel-install
Harald Hoyer bd236f
old mode 100644
Harald Hoyer bd236f
new mode 100755
4ee649
index 3ae1d77..5c1e4fc
Harald Hoyer 2e2e24
--- a/src/kernel-install/kernel-install
Harald Hoyer 2e2e24
+++ b/src/kernel-install/kernel-install
4ee649
@@ -71,6 +71,50 @@ fi
Harald Hoyer bd236f
 KERNEL_VERSION="$1"
Harald Hoyer bd236f
 KERNEL_IMAGE="$2"
Harald Hoyer 2e2e24
 
Harald Hoyer 2e2e24
+if [[ -x /sbin/new-kernel-pkg ]]; then
Harald Hoyer bd236f
+    KERNEL_DIR="${KERNEL_IMAGE%/*}"
4ee649
+    if [[ "${KERNEL_DIR}" != "/boot" ]]; then
4ee649
+        for i in \
4ee649
+            "$KERNEL_IMAGE" \
4ee649
+            "$KERNEL_DIR"/System.map \
4ee649
+            "$KERNEL_DIR"/config \
4ee649
+            "$KERNEL_DIR"/zImage.stub \
4ee649
+            "$KERNEL_DIR"/dtb \
4ee649
+            ; do
4ee649
+            [[ -e "$i" ]] || continue
4ee649
+            cp -a "$i" "/boot/${i##*/}-${KERNEL_VERSION}"
4ee649
+            command -v restorecon &>/dev/null && \
4ee649
+                restorecon "/boot/${i##*/}-${KERNEL_VERSION}"
4ee649
+        done
4ee649
+        # hmac is .vmlinuz-<version>.hmac so needs a special treatment
4ee649
+        i="$KERNEL_DIR/.${KERNEL_IMAGE##*/}.hmac"
4ee649
+        if [[ -e "$i" ]]; then
4ee649
+            cp -a "$i" "/boot/.${KERNEL_IMAGE##*/}-${KERNEL_VERSION}.hmac"
4ee649
+            command -v restorecon &>/dev/null && \
4ee649
+                restorecon "/boot/.${KERNEL_IMAGE##*/}-${KERNEL_VERSION}.hmac"
4ee649
+        fi
4ee649
+    fi
4ee649
+
Harald Hoyer bd236f
+    [[ "$KERNEL_VERSION" == *\+* ]] && flavor=-"${KERNEL_VERSION##*+}"
Harald Hoyer bd236f
+    case "$COMMAND" in
Harald Hoyer 2e2e24
+        add)
Harald Hoyer bd236f
+            /sbin/new-kernel-pkg --package "kernel${flavor}" --install "$KERNEL_VERSION" || exit $?
Harald Hoyer bd236f
+            /sbin/new-kernel-pkg --package "kernel${flavor}" --mkinitrd --dracut --depmod --update "$KERNEL_VERSION" || exit $?
Harald Hoyer bd236f
+            /sbin/new-kernel-pkg --package "kernel${flavor}" --rpmposttrans "$KERNEL_VERSION" || exit $?
Harald Hoyer 2e2e24
+            ;;
Harald Hoyer 2e2e24
+        remove)
Harald Hoyer bd236f
+            /sbin/new-kernel-pkg --package "kernel${flavor+-$flavor}" --rminitrd --rmmoddep --remove "$KERNEL_VERSION" || exit $?
Harald Hoyer 2e2e24
+            ;;
Harald Hoyer 2e2e24
+        *)
Harald Hoyer 2e2e24
+            ;;
Harald Hoyer 2e2e24
+    esac
Harald Hoyer 2e2e24
+
Harald Hoyer 2e2e24
+    # exit, if we can't find a boot loader spec conforming setup
Harald Hoyer 2e2e24
+    if ! [[ -d /boot/loader/entries || -L /boot/loader/entries ]]; then
Harald Hoyer 2e2e24
+        exit 0
Harald Hoyer 2e2e24
+    fi
Harald Hoyer 2e2e24
+fi
Harald Hoyer 2e2e24
+
Harald Hoyer bd236f
 if [[ -f /etc/machine-id ]]; then
Harald Hoyer bd236f
     read MACHINE_ID < /etc/machine-id
Harald Hoyer bd236f
 fi
Harald Hoyer bd236f
-- 
4ee649
2.6.0
Harald Hoyer bd236f