daandemeyer / rpms / systemd

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