2024-02-05 10:37:43 +01:00
|
|
|
#!/bin/sh
|
2024-11-04 11:30:01 +01:00
|
|
|
# arch_post_update_update_boot.sh
|
|
|
|
#
|
|
|
|
# In your /etc/profile, export the following variables
|
|
|
|
# LVM_VG_BOOT=vg0
|
|
|
|
# LVM_LG_BOOT_NAME=boot
|
|
|
|
# BOOT_DIR_SUFFIX=/archlinux
|
|
|
|
#
|
|
|
|
# Optional variables:
|
|
|
|
# PACMAN_BIN=/usr/bin/pacman # Alternative pacman binary (eg: aura)
|
|
|
|
# BOOT_SYMLINK=current (in good boot dir)
|
|
|
|
|
|
|
|
set -e
|
|
|
|
|
|
|
|
source /etc/profile
|
|
|
|
|
|
|
|
ask_overwrite() {
|
|
|
|
echo "Existing destination folder ($ARCH_BOOT_DST_CURRENT_VERSION), do you want to overwrite? (y/n)";
|
|
|
|
read OVERWRITE;
|
|
|
|
test "$OVERWRITE" = "y" && return
|
|
|
|
echo "Do not overwrite. Exitting gently..."
|
|
|
|
exit 0;
|
|
|
|
}
|
|
|
|
|
|
|
|
PACMAN_BIN=${PACMAN_BIN:-/usr/bin/pacman}
|
|
|
|
BOOT_SYMLINK=${BOOT_SYMLINK:-current}
|
|
|
|
|
|
|
|
CURRENT_VERSION=`${PACMAN_BIN} -Qi linux \
|
|
|
|
| sed -n '/^Version *:/p' \
|
|
|
|
| grep -o '[^ ]*$'`
|
|
|
|
BOOT_BLK=/dev/$LVM_VG_BOOT/$LVM_LG_BOOT_NAME
|
2024-02-05 10:37:43 +01:00
|
|
|
BOOT_ORIG=/boot
|
2024-11-04 11:30:01 +01:00
|
|
|
TMP_BOOT_DST=`mktemp -d`
|
|
|
|
|
|
|
|
ARCH_BOOT_DST=$TMP_BOOT_DST/$BOOT_DIR_SUFFIX
|
2024-02-05 10:37:43 +01:00
|
|
|
ARCH_BOOT_DST_CURRENT_VERSION=$ARCH_BOOT_DST/$CURRENT_VERSION
|
|
|
|
ARCH_INITRAMFS=initramfs-linux.img
|
|
|
|
ARCH_INITRAMFS_FALLBACK=initramfs-linux-fallback.img
|
|
|
|
ARCH_VMLINUZ=vmlinuz-linux
|
|
|
|
|
2024-11-04 11:30:01 +01:00
|
|
|
mount $BOOT_BLK $TMP_BOOT_DST;
|
|
|
|
test -d $ARCH_BOOT_DST_CURRENT_VERSION \
|
|
|
|
&& test `realpath $ARCH_BOOT_DST/$BOOT_SYMLINK` = $ARCH_BOOT_DST_CURRENT_VERSION \
|
|
|
|
&& echo "Linux version already up to date ($CURRENT_VERSION)" && exit 0;
|
2024-02-05 10:37:43 +01:00
|
|
|
|
2024-11-04 11:30:01 +01:00
|
|
|
mkdir $ARCH_BOOT_DST_CURRENT_VERSION || ask_overwrite;
|
2024-02-05 10:37:43 +01:00
|
|
|
|
|
|
|
(
|
2024-11-04 11:30:01 +01:00
|
|
|
cd $BOOT_ORIG;
|
|
|
|
# Copy the new kernel files to the real destination in boot fs
|
|
|
|
cp -t $ARCH_BOOT_DST_CURRENT_VERSION $ARCH_INITRAMFS $ARCH_INITRAMFS_FALLBACK $ARCH_VMLINUZ;
|
2024-02-05 10:37:43 +01:00
|
|
|
)
|
|
|
|
|
|
|
|
(
|
2024-11-04 11:30:01 +01:00
|
|
|
cd $ARCH_BOOT_DST;
|
|
|
|
# Re-link the good version
|
2024-11-04 12:48:10 +01:00
|
|
|
test -h $BOOT_SYMLINK && rm $BOOT_SYMLINK;
|
2024-11-04 11:30:01 +01:00
|
|
|
ln -s $CURRENT_VERSION current;
|
2024-02-05 10:37:43 +01:00
|
|
|
)
|
|
|
|
|
2024-11-04 11:30:01 +01:00
|
|
|
|
2024-02-05 10:37:43 +01:00
|
|
|
echo "Linux version updated to $CURRENT_VERSION"
|
2024-11-04 11:30:01 +01:00
|
|
|
umount $TMP_BOOT_DST;
|
2024-11-04 11:54:07 +01:00
|
|
|
rmdir $TMP_BOOT_DST;
|
2024-02-05 10:37:43 +01:00
|
|
|
exit 0;
|