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