[arch_post_update_update_boot] use variables present in profile to set boot path
This commit is contained in:
parent
c9ecf555c8
commit
1c4715ade0
|
@ -1,30 +1,64 @@
|
||||||
#!/bin/sh
|
#!/bin/sh
|
||||||
set -xe
|
# arch_post_update_update_boot.sh
|
||||||
AURA_BIN=/usr/bin/aura
|
#
|
||||||
CURRENT_VERSION=`${AURA_BIN} -Qi linux | sed -n '/^Version *:/p' | grep -o '[^ ]*$'`
|
# In your /etc/profile, export the following variables
|
||||||
BOOT_BLK=/dev/vg0/boot
|
# 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
|
||||||
BOOT_ORIG=/boot
|
BOOT_ORIG=/boot
|
||||||
BOOT_DST=/mnt/boot
|
TMP_BOOT_DST=`mktemp -d`
|
||||||
ARCH_BOOT_DST=$BOOT_DST/archlinux
|
|
||||||
|
ARCH_BOOT_DST=$TMP_BOOT_DST/$BOOT_DIR_SUFFIX
|
||||||
ARCH_BOOT_DST_CURRENT_VERSION=$ARCH_BOOT_DST/$CURRENT_VERSION
|
ARCH_BOOT_DST_CURRENT_VERSION=$ARCH_BOOT_DST/$CURRENT_VERSION
|
||||||
ARCH_INITRAMFS=initramfs-linux.img
|
ARCH_INITRAMFS=initramfs-linux.img
|
||||||
ARCH_INITRAMFS_FALLBACK=initramfs-linux-fallback.img
|
ARCH_INITRAMFS_FALLBACK=initramfs-linux-fallback.img
|
||||||
ARCH_VMLINUZ=vmlinuz-linux
|
ARCH_VMLINUZ=vmlinuz-linux
|
||||||
|
|
||||||
mount $BOOT_BLK $BOOT_DST;
|
mount $BOOT_BLK $TMP_BOOT_DST;
|
||||||
test -d $ARCH_BOOT_DST_CURRENT_VERSION && echo "Linux version already up to date ($CURRENT_VERSION)" && exit 0;
|
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;
|
||||||
|
|
||||||
mkdir $ARCH_BOOT_DST_CURRENT_VERSION;
|
mkdir $ARCH_BOOT_DST_CURRENT_VERSION || ask_overwrite;
|
||||||
|
|
||||||
(
|
(
|
||||||
cd $BOOT_ORIG;
|
cd $BOOT_ORIG;
|
||||||
cp -t $ARCH_BOOT_DST_CURRENT_VERSION $ARCH_INITRAMFS $ARCH_INITRAMFS_FALLBACK $ARCH_VMLINUZ;
|
# 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;
|
||||||
)
|
)
|
||||||
|
|
||||||
(
|
(
|
||||||
cd $ARCH_BOOT_DST;
|
cd $ARCH_BOOT_DST;
|
||||||
rm current && ln -s $CURRENT_VERSION current;
|
# Re-link the good version
|
||||||
|
test -f $BOOT_SYMLINK && rm $BOOT_SYMLINK;
|
||||||
|
ln -s $CURRENT_VERSION current;
|
||||||
)
|
)
|
||||||
|
|
||||||
|
|
||||||
echo "Linux version updated to $CURRENT_VERSION"
|
echo "Linux version updated to $CURRENT_VERSION"
|
||||||
|
umount $TMP_BOOT_DST;
|
||||||
exit 0;
|
exit 0;
|
||||||
|
|
Loading…
Reference in New Issue