[arch-projects] [devtools] [PATCH] mkarchroot: Avoid binding cache dirs in the host mirror path

Jan Alexander Steffens (heftig) jan.steffens at gmail.com
Sat Sep 1 21:42:19 EDT 2012

From: "Jan Alexander Steffens (heftig)" <jan.steffens at gmail.com>

This is a workaround that should prevent the zombie mounts we've been seeing
on brynhild that crept up when combining systemd's shared-by-default mounts,
nested bind mounts and concurrent mkarchroots.

So get rid of the nested bind mounts.

A more proper fix would probably be to --make-slave every bind we're making.
I've been looking into doing that along with using systemd-nspawn. Alas, nspawn
currently seems to be interactive-use only, as it expects a terminal on STDIN
and epoll-able STDOUT.
 mkarchroot.in | 9 ++++++++-
 1 file changed, 8 insertions(+), 1 deletion(-)

diff --git a/mkarchroot.in b/mkarchroot.in
index 5bcde76..519837a 100644
--- a/mkarchroot.in
+++ b/mkarchroot.in
@@ -75,6 +75,8 @@ fi
 host_mirror=$(pacman -Sddp extra/devtools 2>/dev/null | sed -E 's#(.*/)extra/os/.*#\1$repo/os/$arch#')
 if echo "${host_mirror}" | grep -q 'file://'; then
 	host_mirror_path=$(echo "${host_mirror}" | sed -E 's#file://(/.*)/\$repo/os/\$arch#\1#g')
+	# Remove cache dirs in host mirror path, those are handled specially to avoid additional binds
+	cache_dirs=( "${cache_dirs[@]/${host_mirror_path}*/}" )
 # {{{ functions
@@ -149,7 +151,12 @@ copy_hostconf () {
 		cp ${makepkg_conf} ${working_dir}/etc/makepkg.conf
-	sed -r "s|^#?\\s*CacheDir.+|CacheDir = $(echo -n ${cache_dirs[@]})|g" -i ${working_dir}/etc/pacman.conf
+	local conf_cache_dirs=( "${cache_dirs[@]}" )
+	if [[ -n ${host_mirror_path} ]]; then
+		conf_cache_dirs+=( "${host_mirror_path}"/pool/{packages,community} )
+	fi
+	sed -r "s|^#?\\s*CacheDir.+|CacheDir = $(echo -n ${conf_cache_dirs[@]})|" -i ${working_dir}/etc/pacman.conf
 chroot_umount () {

More information about the arch-projects mailing list