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