From e1ca5a0bc28697c545b619fe1f07bc6145ef5c38 Mon Sep 17 00:00:00 2001 From: Luke Shumaker Date: Wed, 15 Feb 2017 14:37:10 -0500 Subject: mkarchroot, arch-nspawn: Add an `-f` flag to add files to copy. This allows us to copy in files like `qemu-arm-static`, which is necessary for running an ARM chroot on an x86 box. --- arch-nspawn.in | 12 +++++++++++- 1 file changed, 11 insertions(+), 1 deletion(-) (limited to 'arch-nspawn.in') diff --git a/arch-nspawn.in b/arch-nspawn.in index fd4c583..19a1a89 100644 --- a/arch-nspawn.in +++ b/arch-nspawn.in @@ -16,6 +16,8 @@ CHROOT_VERSION='v3' working_dir='' +files=() + usage() { echo "Usage: ${0##*/} [options] working-dir [systemd-nspawn arguments]" echo "A wrapper around systemd-nspawn. Provides support for pacman." @@ -24,17 +26,19 @@ usage() { echo ' -C Location of a pacman config file' echo ' -M Location of a makepkg config file' echo ' -c Set pacman cache' + echo ' -f Copy file from the host to the chroot' echo ' -h This message' exit 1 } orig_argv=("$@") -while getopts 'hC:M:c:' arg; do +while getopts 'hC:M:c:f:' arg; do case "$arg" in C) pac_conf="$OPTARG" ;; M) makepkg_conf="$OPTARG" ;; c) cache_dir="$OPTARG" ;; + f) files+=("$OPTARG") ;; h|?) usage ;; *) error "invalid argument '%s'" "$arg"; usage ;; esac @@ -80,6 +84,12 @@ copy_hostconf () { [[ -n $pac_conf ]] && cp $pac_conf "$working_dir/etc/pacman.conf" [[ -n $makepkg_conf ]] && cp $makepkg_conf "$working_dir/etc/makepkg.conf" + local file + for file in "${files[@]}"; do + mkdir -p "$(dirname "$working_dir$file")" + cp -T "$file" "$working_dir$file" + done + sed -r "s|^#?\\s*CacheDir.+|CacheDir = $(echo -n ${cache_dirs[@]})|g" -i "$working_dir/etc/pacman.conf" } # }}} -- cgit v1.2.3-70-g09d2