50 lines
1.9 KiB
Bash
Executable file
50 lines
1.9 KiB
Bash
Executable file
#!/bin/bash
|
|
|
|
run_latehook() {
|
|
echo
|
|
|
|
# Remove /new_root/.successful-update if exists
|
|
rm -f /new_root/.successful-update
|
|
|
|
# Detect if update downloaded.
|
|
if [[ -d /new_root/.update_rootfs ]]; then
|
|
# Available, rename old /usr and move new /usr to /.
|
|
mv /new_root/usr /new_root/.old.usr
|
|
mv /new_root/.update_rootfs/usr /new_root/usr
|
|
|
|
# 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
|
|
|
|
# Same for /var/lib/pacman.
|
|
mv /new_root/var/lib/pacman /new_root/.old.var.lib.pacman
|
|
mv /new_root/.update_rootfs/var/lib/pacman /new_root/var/lib
|
|
|
|
# Move to /etc stage.
|
|
touch /new_root/.etc-stage
|
|
fi
|
|
|
|
# Detect if /etc stage is active.
|
|
if [[ -f /new_root/.etc-stage ]]; then
|
|
# Create new /etc.
|
|
rm -rf /new_root/.new_etc
|
|
cp -a /new_root/etc /new_root/.new_etc
|
|
(cd /new_root/.new_etc && find . -type f -print0 | grep -Fxvz -f <(cd "/new_root/.update_rootfs/etc" && find . -type f) | xargs -0 rm -f)
|
|
(cd /new_root/.new_etc && find . -type l -print0 | grep -Fxvz -f <(cd "/new_root/.update_rootfs/etc" && find . -type l) | xargs -0 rm -f)
|
|
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
|
|
|
|
mv /new_root/etc/systemd/system /new_root/.old.etc.systemd.system
|
|
mv /new_root/.update_rootfs/etc/systemd/system /new_root/etc/systemd
|
|
|
|
# Successful update.
|
|
rm -f /new_root/.etc-stage
|
|
|
|
mv /new_root/.update_rootfs /new_root/.old.update_rootfs
|
|
touch /new_root/.successful-update
|
|
fi
|
|
}
|