`cache_dirs` gets corrupter on consecutive `arch-nspawn` calls
Created by: bartoszek
Current behavior is to append all cache_dirs
to each line containing (#)CacheDir
in $working_dir/etc/pacman.conf
https://github.com/archlinux/devtools/blob/90ba07d9be2883cccb1dd42aa0c8f974a2ff055c/arch-nspawn.in#L111
Witch results in redundant entries appearing in $working_dir/etc/pacman.conf
each time arch-nspawn
is started.
[options]
CacheDir= /var/cache/pacman/pkg /var/cache/aur /var/cache/pacman/pkg/ /var/cache/aur ...
Beside producing extra entries if pacman.conf
contains more then single CacheDir=
line
This behavior collides with rw/ro
mount point logic producing unusable chroot environment.
https://github.com/archlinux/devtools/blob/90ba07d9be2883cccb1dd42aa0c8f974a2ff055c/arch-nspawn.in#L89-L93
mount_args=(--bind=/var/cache/pacman/pkg --bind-ro=/var/cache/aur --bind-ro=/var/cache/pacman/pkg/ --bind-ro=/var/cache/aru ... )
This produces container without writable cache on second arch-nspawn
call.
$arch-nspawn /tmp/roo
$$mount|grep sd
/dev/sdb3 on /var/cache/pacman/pkg type ext4 (rw,realtime,commit=60,data=ordered)
/dev/sdb3 on /var/cache/aur type ext4 (ro,realtime,commit=60,data=ordered)
$$touch /var/cache/pacman/pkg/test
$$exit
$arch-nspawn /tmp/roo
$$mount|grep sd
/dev/sdb3 on /var/cache/pacman/pkg type ext4 (rw,realtime,commit=60,data=ordered)
/dev/sdb3 on /var/cache/pacman/pkg type ext4 (ro,realtime,commit=60,data=ordered)
/dev/sdb3 on /var/cache/aur type ext4 (ro,realtime,commit=60,data=ordered)
/dev/sdb3 on /var/cache/aur type ext4 (ro,realtime,commit=60,data=ordered)
$$touch /var/cache/pacman/pkg/test
touch: cannot touch '/var/cache/pacman/pkg/test/' : Read-only file system