[arch-projects] [devtools] [PATCH] use nspawn to bind mount needed directories
Dave Reisner
dreisner at archlinux.org
Thu Feb 28 17:09:21 EST 2013
systemd-nspawn is capable of doing this as of systemd-198.
Signed-off-by: Dave Reisner <dreisner at archlinux.org>
---
mkarchroot.in | 21 ++++++++++++++-------
1 file changed, 14 insertions(+), 7 deletions(-)
diff --git a/mkarchroot.in b/mkarchroot.in
index 20de5e6..c7c7bcb 100644
--- a/mkarchroot.in
+++ b/mkarchroot.in
@@ -95,14 +95,21 @@ bind_mount() {
mount --make-slave "$target"
}
-chroot_mount() {
- trap 'trap_chroot_umount' EXIT INT QUIT TERM HUP
+build_mount_args() {
+ local p
+ declare -g mount_args=()
- [[ -n $host_mirror_path ]] && bind_mount "$host_mirror_path" ro
+ if [[ -n $host_mirror_path ]]; then
+ printf -v p '%q' "$host_mirror_path"
+ mount_args+=(--bind-ro="$p")
+ fi
+
+ printf -v p '%q' "${cache_dirs[0]}"
+ mount_args+=(--bind="$p")
- bind_mount "${cache_dirs[0]}"
for cache_dir in ${cache_dirs[@]:1}; do
- bind_mount "$cache_dir" ro
+ printf -v p '%q' "$cache_dir"
+ mount_args+=(--bind-ro="$p")
done
}
@@ -148,7 +155,7 @@ chroot_lock () {
chroot_run() {
local dir=$1
shift
- eval systemd-nspawn -D "${dir}" -- ${@} 2>/dev/null
+ eval systemd-nspawn -D "${dir}" "${mount_args[@]}" -- ${@} 2>/dev/null
}
# }}}
@@ -164,7 +171,7 @@ if [[ -n $RUN ]]; then
fi
chroot_lock
- chroot_mount
+ build_mount_args
copy_hostconf
chroot_run "${working_dir}" ${RUN}
--
1.8.1.4
More information about the arch-projects
mailing list