12da22
#!/bin/bash
12da22
d4d36e
if [[ ! -x /sbin/new-kernel-pkg ]]; then
d81bdc
    exit 0
12da22
fi
12da22
12da22
COMMAND="$1"
12da22
KERNEL_VERSION="$2"
12da22
BOOT_DIR_ABS="$3"
12da22
KERNEL_IMAGE="$4"
12da22
12da22
KERNEL_DIR="${KERNEL_IMAGE%/*}"
12da22
[[ "$KERNEL_VERSION" == *\+* ]] && flavor=-"${KERNEL_VERSION##*+}"
12da22
case "$COMMAND" in
12da22
    add)
12da22
        if [[ "${KERNEL_DIR}" != "/boot" ]]; then
12da22
            for i in \
12da22
                "$KERNEL_IMAGE" \
12da22
                    "$KERNEL_DIR"/System.map \
12da22
                    "$KERNEL_DIR"/config \
12da22
                    "$KERNEL_DIR"/zImage.stub \
12da22
                    "$KERNEL_DIR"/dtb \
12da22
                ; do
12da22
                [[ -e "$i" ]] || continue
12da22
                cp -aT "$i" "/boot/${i##*/}-${KERNEL_VERSION}"
12da22
                command -v restorecon &>/dev/null && \
12da22
                    restorecon -R "/boot/${i##*/}-${KERNEL_VERSION}"
12da22
            done
12da22
            # hmac is .vmlinuz-<version>.hmac so needs a special treatment
12da22
            i="$KERNEL_DIR/.${KERNEL_IMAGE##*/}.hmac"
12da22
            if [[ -e "$i" ]]; then
12da22
                cp -a "$i" "/boot/.${KERNEL_IMAGE##*/}-${KERNEL_VERSION}.hmac"
12da22
                command -v restorecon &>/dev/null && \
12da22
                    restorecon "/boot/.${KERNEL_IMAGE##*/}-${KERNEL_VERSION}.hmac"
12da22
            fi
12da22
        fi
12da22
        /sbin/new-kernel-pkg --package "kernel${flavor}" --install "$KERNEL_VERSION" || exit $?
12da22
        /sbin/new-kernel-pkg --package "kernel${flavor}" --mkinitrd --dracut --depmod --update "$KERNEL_VERSION" || exit $?
12da22
        /sbin/new-kernel-pkg --package "kernel${flavor}" --rpmposttrans "$KERNEL_VERSION" || exit $?
12da22
        ;;
12da22
    remove)
12da22
        /sbin/new-kernel-pkg --package "kernel${flavor+-$flavor}" --rminitrd --rmmoddep --remove "$KERNEL_VERSION" || exit $?
12da22
        ;;
12da22
    *)
12da22
        ;;
12da22
esac
d4d36e
d4d36e
# skip other installation plugins, if we can't find a boot loader spec conforming setup
d4d36e
if ! [[ -d /boot/loader/entries || -L /boot/loader/entries ]]; then
d4d36e
    exit 77
d4d36e
fi