2023-05-06 08:17:56 -05:00
|
|
|
#!/bin/bash
|
|
|
|
|
|
|
|
run_latehook() {
|
|
|
|
echo
|
2023-05-09 01:21:59 -05:00
|
|
|
|
2023-11-17 14:21:53 -06:00
|
|
|
# Remove /new_root/.successful-update if exists
|
|
|
|
rm -f /new_root/.successful-update
|
2023-05-09 01:21:59 -05:00
|
|
|
|
2023-05-06 08:17:56 -05:00
|
|
|
# Detect if update downloaded.
|
2023-11-17 14:21:53 -06:00
|
|
|
if [[ -d /new_root/.update_rootfs ]]; then
|
2023-05-06 08:17:56 -05:00
|
|
|
# Available, rename old /usr and move new /usr to /.
|
|
|
|
mv /new_root/usr /new_root/.old.usr
|
2023-11-17 14:21:53 -06:00
|
|
|
mv /new_root/.update_rootfs/usr /new_root/usr
|
2023-05-12 02:12:46 -05:00
|
|
|
|
2023-11-17 14:21:53 -06:00
|
|
|
# Same for /var/cache/pacman.
|
|
|
|
mv /new_root/var/cache/pacman /new_root/.old.pacmancache
|
|
|
|
mv /new_root/.update_rootfs/var/cache/pacman /new_root/var/cache
|
2023-06-10 08:17:45 -05:00
|
|
|
|
2023-05-07 01:55:50 -05:00
|
|
|
# Same for /var/lib/pacman.
|
|
|
|
mv /new_root/var/lib/pacman /new_root/.old.var.lib.pacman
|
2023-11-17 14:21:53 -06:00
|
|
|
mv /new_root/.update_rootfs/var/lib/pacman /new_root/var/lib
|
2023-05-07 10:18:07 -05:00
|
|
|
|
2023-05-06 11:47:58 -05:00
|
|
|
# Move to /etc stage.
|
2023-11-17 14:21:53 -06:00
|
|
|
touch /new_root/.etc-stage
|
2023-05-06 08:17:56 -05:00
|
|
|
fi
|
2023-05-07 01:16:13 -05:00
|
|
|
|
2023-05-06 08:17:56 -05:00
|
|
|
# Detect if /etc stage is active.
|
2023-11-17 14:21:53 -06:00
|
|
|
if [[ -f /new_root/.etc-stage ]]; then
|
2023-06-10 08:17:45 -05:00
|
|
|
# Create new /etc.
|
2023-11-17 14:21:53 -06:00
|
|
|
rm -rf /new_root/.new_etc
|
|
|
|
cp -a /new_root/etc /new_root/.new_etc
|
2023-11-20 00:55:24 -06:00
|
|
|
(cd /new_root/etc && find . -type f -print0 | grep -Fxvz -f <(cd "/new_root/.update_rootfs/etc" && find . -type f) | xargs -0 rm -rf)
|
2023-11-17 14:21:53 -06:00
|
|
|
cp /new_root/.update_rootfs/etc/pacman.conf /new_root/.new_etc/pacman.conf
|
|
|
|
rm -rf /new_root/.new_etc/pacman.d
|
|
|
|
cp -a /new_root/.update_rootfs/etc/pacman.d /new_root/.new_etc/pacman.d
|
|
|
|
cp -an /new_root/.update_rootfs/etc/* /new_root/.new_etc
|
|
|
|
mv /new_root/etc /new_root/.old.etc || :
|
|
|
|
mv /new_root/.new_etc /new_root/etc
|
2023-05-07 10:18:07 -05:00
|
|
|
|
2023-11-20 02:21:49 -06:00
|
|
|
mv /new_root/etc/systemd/system /new_root/.old.etc.systemd.system
|
|
|
|
mv /new_root/.update_rootfs/etc/systemd/system /new_root/etc/systemd
|
|
|
|
|
2023-05-06 11:47:58 -05:00
|
|
|
# Successful update.
|
2023-11-17 14:21:53 -06:00
|
|
|
rm -f /new_root/.etc-stage
|
2023-11-20 00:55:24 -06:00
|
|
|
|
|
|
|
mv /new_root/.update_rootfs /new_root/.old.update_rootfs
|
2023-11-17 14:21:53 -06:00
|
|
|
touch /new_root/.successful-update
|
2023-05-09 01:21:59 -05:00
|
|
|
fi
|
2023-05-06 08:17:56 -05:00
|
|
|
}
|