daandemeyer / rpms / systemd

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