chore: handle /var/cache/pacman

This commit is contained in:
Rudra Saraswat 2024-02-09 17:24:51 +05:30
parent deb302a20e
commit afd6cbb149
2 changed files with 13 additions and 7 deletions

View file

@ -124,9 +124,7 @@ def update_system():
os.chdir('/')
if os.path.isdir('/.new_rootfs'):
# add code here to unmount any directories under the new rootfs dir
exec('rm', '-rf', '/.new_rootfs')
exec('rm', '-rf', '/.new_rootfs', '/.new.etc', '/.new.var.lib')
# Check if update is available
if not os.path.isfile('/system.yaml'):
@ -376,6 +374,8 @@ Server = {package_repo["repo-url"]}
exec('rm', '-rf', os.path.join(dir_name, name))
exec('cp', '/.new_rootfs/etc/pacman.conf', '/.new.etc')
exec('rm', '-rf', '/.new.var.lib/pacman')
exec('cp', '-ax', '/.new_rootfs/var/lib/pacman', '/.new.var.lib/pacman')
exec('mv', '.new_rootfs', '.update_rootfs')

View file

@ -9,8 +9,10 @@ run_latehook() {
# 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
if [[ -d /new_root/.update_rootfs/usr ]]; then
mv /new_root/usr /new_root/.old.usr
mv /new_root/.update_rootfs/usr /new_root/usr
fi
# Same for /etc.
if [[ -d /new_root/.update_rootfs/etc ]]; then
@ -21,11 +23,15 @@ run_latehook() {
mv /new_root/.new.etc /new_root/etc
fi
# Same for /var/lib/pacman.
# Same for /var.
if [[ -d /new_root/.new.var.lib ]]; then
mv /new_root/var/lib /new_root/.old.var.lib
mv /new_root/.new.var.lib /new_root/var/lib
fi
if [[ -d /new_root/.update_rootfs/var/cache/pacman ]]; then
mv /new_root/var/cache/pacman /new_root/.old.var.cache.pacman
mv /new_root/.update_rootfs/var/cache/pacman /new_root/var/cache/pacman
fi
mv /new_root/.update_rootfs /new_root/.old.update_rootfs
touch /new_root/.successful-update