dcavalca / rpms / systemd

Forked from rpms/systemd 4 months ago
Clone
Harald Hoyer 253663
From 859a022f807bbab2d072c7299743b527156e7f7d Mon Sep 17 00:00:00 2001
Harald Hoyer 253663
From: Harald Hoyer <harald@redhat.com>
Harald Hoyer 253663
Date: Tue, 14 Jan 2014 17:48:08 -0500
Harald Hoyer 253663
Subject: [PATCH] kernel-install: add fedora specific callouts to
Harald Hoyer 253663
 new-kernel-pkg
Harald Hoyer 2e2e24
Harald Hoyer 253663
---
Harald Hoyer 253663
 src/kernel-install/kernel-install | 43 +++++++++++++++++++++++++++++++++++++++
Harald Hoyer 253663
 1 file changed, 43 insertions(+)
Harald Hoyer 253663
 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 70cb85
index 3ae1d77..2b8fe1e
Harald Hoyer 2e2e24
--- a/src/kernel-install/kernel-install
Harald Hoyer 2e2e24
+++ b/src/kernel-install/kernel-install
Harald Hoyer 70cb85
@@ -71,6 +71,49 @@ 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
+    [[ "$KERNEL_VERSION" == *\+* ]] && flavor=-"${KERNEL_VERSION##*+}"
Harald Hoyer bd236f
+    case "$COMMAND" in
Harald Hoyer 2e2e24
+        add)
Harald Hoyer f9a221
+            if [[ "${KERNEL_DIR}" != "/boot" ]]; then
Harald Hoyer f9a221
+                for i in \
Harald Hoyer f9a221
+                    "$KERNEL_IMAGE" \
Harald Hoyer f9a221
+                        "$KERNEL_DIR"/System.map \
Harald Hoyer f9a221
+                        "$KERNEL_DIR"/config \
Harald Hoyer f9a221
+                        "$KERNEL_DIR"/zImage.stub \
Harald Hoyer f9a221
+                        "$KERNEL_DIR"/dtb \
Harald Hoyer f9a221
+                    ; do
Harald Hoyer f9a221
+                    [[ -e "$i" ]] || continue
Harald Hoyer 70cb85
+                    cp -aT "$i" "/boot/${i##*/}-${KERNEL_VERSION}"
Harald Hoyer f9a221
+                    command -v restorecon &>/dev/null && \
Harald Hoyer f9a221
+                        restorecon -R "/boot/${i##*/}-${KERNEL_VERSION}"
Harald Hoyer f9a221
+                done
Harald Hoyer f9a221
+                # hmac is .vmlinuz-<version>.hmac so needs a special treatment
Harald Hoyer f9a221
+                i="$KERNEL_DIR/.${KERNEL_IMAGE##*/}.hmac"
Harald Hoyer f9a221
+                if [[ -e "$i" ]]; then
Harald Hoyer f9a221
+                    cp -a "$i" "/boot/.${KERNEL_IMAGE##*/}-${KERNEL_VERSION}.hmac"
Harald Hoyer f9a221
+                    command -v restorecon &>/dev/null && \
Harald Hoyer f9a221
+                        restorecon "/boot/.${KERNEL_IMAGE##*/}-${KERNEL_VERSION}.hmac"
Harald Hoyer f9a221
+                fi
Harald Hoyer f9a221
+            fi
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 253663
-- 
Harald Hoyer 253663
2.7.2
Harald Hoyer 253663