Harald Hoyer f6039f
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
---
Harald Hoyer f6039f
 src/kernel-install/kernel-install | 44 +++++++++++++++++++++++++++++++++++++++
Harald Hoyer f6039f
 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
Harald Hoyer f6039f
index 3ae1d77..5c1e4fc
Harald Hoyer 2e2e24
--- a/src/kernel-install/kernel-install
Harald Hoyer 2e2e24
+++ b/src/kernel-install/kernel-install
Zbigniew Jędrzejewski-Szmek 35c1f6
@@ -71,7 +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%/*}"
Harald Hoyer bd236f
+    if [[ "${KERNEL_DIR}" != "/boot" ]]; then
Harald Hoyer bd236f
+        for i in \
Harald Hoyer bd236f
+            "$KERNEL_IMAGE" \
Harald Hoyer bd236f
+            "$KERNEL_DIR"/System.map \
Harald Hoyer bd236f
+            "$KERNEL_DIR"/config \
Harald Hoyer bd236f
+            "$KERNEL_DIR"/zImage.stub \
Harald Hoyer bd236f
+            "$KERNEL_DIR"/dtb \
Harald Hoyer bd236f
+            ; do
Harald Hoyer bd236f
+            [[ -e "$i" ]] || continue
Harald Hoyer bd236f
+            cp -a "$i" "/boot/${i##*/}-${KERNEL_VERSION}"
Harald Hoyer d4f265
+            command -v restorecon &>/dev/null && \
Harald Hoyer d4f265
+                restorecon "/boot/${i##*/}-${KERNEL_VERSION}"
Harald Hoyer bd236f
+        done
Harald Hoyer f6039f
+        # hmac is .vmlinuz-<version>.hmac so needs a special treatment
Harald Hoyer f6039f
+        i="$KERNEL_DIR/.${KERNEL_IMAGE##*/}.hmac"
Harald Hoyer f6039f
+        if [[ -e "$i" ]]; then
Harald Hoyer f6039f
+            cp -a "$i" "/boot/.${KERNEL_IMAGE##*/}-${KERNEL_VERSION}.hmac"
Harald Hoyer f6039f
+            command -v restorecon &>/dev/null && \
Harald Hoyer f6039f
+                restorecon "/boot/.${KERNEL_IMAGE##*/}-${KERNEL_VERSION}.hmac"
Zbigniew Jędrzejewski-Szmek 35c1f6
+        fi
Harald Hoyer bd236f
+    fi
Harald Hoyer bd236f
+
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
-- 
Harald Hoyer d4f265
2.6.0
Harald Hoyer bd236f