akshara/akshara.hook

95 lines
3.8 KiB
Text
Raw Normal View History

2023-05-06 08:17:56 -05:00
#!/bin/bash
run_latehook() {
echo
2023-05-09 01:21:59 -05:00
2023-05-12 02:12:46 -05:00
touch /new_root/.custom_pkg_list
2023-05-09 01:21:59 -05:00
# Remove /new_root/mnt/iso-update/.successful-update if exists
rm -f /new_root/mnt/iso-update/.successful-update
2023-05-06 08:17:56 -05:00
# Detect if update downloaded.
if [[ -f /new_root/mnt/iso-update/.ready-for-update ]]; then
# Available, rename old /usr and move new /usr to /.
mv /new_root/usr /new_root/.old.usr
mv /new_root/mnt/iso-update/squashfs-root/usr /new_root/usr
2023-05-07 10:18:07 -05:00
2023-05-12 02:12:46 -05:00
# Copy package list
mv /new_root/mnt/iso-update/squashfs-root/.custom_pkg_list /new_root
2023-05-07 10:18:07 -05:00
# Update /usr/lib/modules for current kernel version.
for kversion in /new_root/.old.usr/lib/modules/*; do
if [[ ! -d /new_root/usr/lib/modules/"$(basename "$kversion")" ]]; then
mv "$kversion" /new_root/usr/lib/modules/"$(basename "$kversion")"
fi
done
2023-05-07 01:16:13 -05:00
# Same for /var/lib/pacman.
mv /new_root/var/lib/pacman /new_root/.old.var.lib.pacman
mv /new_root/mnt/iso-update/squashfs-root/var/lib/pacman /new_root/var/lib
2023-05-07 10:18:07 -05:00
# Move to /etc stage.
2023-05-06 08:17:56 -05:00
rm -f /new_root/mnt/iso-update/.ready-for-update
touch /new_root/mnt/iso-update/.etc-stage
fi
2023-05-07 01:16:13 -05:00
2023-05-06 08:17:56 -05:00
# Detect if /etc stage is active.
if [[ -f /new_root/mnt/iso-update/.etc-stage ]]; then
# Rename existing /etc.
mv /new_root/etc /new_root/.old.etc &>/dev/null || :
2023-05-07 01:16:13 -05:00
2023-05-06 08:17:56 -05:00
# Create new /etc.
cp -a /new_root/.old.etc /new_root/etc
2023-05-07 01:16:13 -05:00
2023-05-06 08:17:56 -05:00
# Only copy non-existent files.
cp -a -n /new_root/mnt/iso-update/squashfs-root/etc/* /new_root/etc
2023-05-07 01:16:13 -05:00
# Update pacman config, and other system files that aren't
# supposed to be edited.
cp /new_root/mnt/iso-update/squashfs-root/etc/pacman.conf /new_root/etc
rm -rf /new_root/etc/pacman.d
cp -r /new_root/mnt/iso-update/squashfs-root/etc/pacman.d /new_root/etc
2023-05-07 01:16:13 -05:00
cp /new_root/mnt/iso-update/squashfs-root/etc/blend_release /new_root/etc
cp /new_root/mnt/iso-update/squashfs-root/etc/os-release /new_root/etc
cp /new_root/mnt/iso-update/squashfs-root/etc/lsb-release /new_root/etc
2023-05-07 10:18:07 -05:00
# Replace kernel and microcode images.
mv /new_root/mnt/iso-update/iso/boot/initramfs-linux-zen.img /new_root/boot/initramfs-linux-zen.img
if [[ -f /boot/amd-ucode.img ]]; then
mv /new_root/mnt/iso-update/iso/boot/amd-ucode.img /new_root/boot/amd-ucode.img
fi
2023-05-07 01:16:13 -05:00
2023-05-07 10:18:07 -05:00
if [[ -f /boot/intel-ucode.img ]]; then
mv /new_root/mnt/iso-update/iso/boot/intel-ucode.img /new_root/boot/intel-ucode.img
fi
2023-05-16 13:14:46 -05:00
for i in usr varlibpacman; do
2023-05-16 13:16:11 -05:00
rm -f /new_root/.blend-overlays/future-$i/.okay
2023-05-16 13:14:46 -05:00
done
# Successful update.
rm -f /new_root/mnt/iso-update/.etc-stage
touch /new_root/mnt/iso-update/.successful-update
2023-05-06 08:17:56 -05:00
fi
2023-05-07 01:16:13 -05:00
2023-05-07 10:18:07 -05:00
# Handle overlays.
2023-05-31 06:43:03 -05:00
if [[ -f '/new_root/.blend-overlays/future-usr/.okay' ]] && [[ -f '/new_root/.blend-overlays/future-varlibpacman/.okay' ]]; then
for i in usr varlibpacman; do
rm -rf /new_root/.blend-overlays/$i
mv /new_root/.blend-overlays/future-$i /new_root/.blend-overlays/$i
done
2023-05-09 01:21:59 -05:00
else
2023-05-31 06:43:03 -05:00
rm -rf /new_root/.blend-overlays/usr.workdir /new_root/.blend-overlays/varlibpacman.workdir
2023-05-09 01:21:59 -05:00
fi
2023-05-07 01:16:13 -05:00
for i in usr varlibpacman; do
mkdir -p /new_root/.blend-overlays/$i
mkdir -p /new_root/.blend-overlays/$i.workdir
done
mount -t overlay overlay -o index=off -o metacopy=off -o ro,lowerdir=/new_root/usr,upperdir=/new_root/.blend-overlays/usr,workdir=/new_root/.blend-overlays/usr.workdir /new_root/usr
mount -t overlay overlay -o index=off -o metacopy=off -o ro,lowerdir=/new_root/var/lib/pacman,upperdir=/new_root/.blend-overlays/varlibpacman,workdir=/new_root/.blend-overlays/varlibpacman.workdir /new_root/var/lib/pacman
2023-05-06 08:17:56 -05:00
}