Send patches - preferably formatted by git format-patch - to patches at archlinux32 dot org.
summaryrefslogtreecommitdiff
path: root/arch-nspawn.in
diff options
context:
space:
mode:
authorLuke Shumaker <lukeshu@parabola.nu>2017-02-15 14:37:10 -0500
committerLuke Shumaker <lukeshu@parabola.nu>2017-04-05 14:42:43 -0400
commitccb26ff1435a79f13bbed6a0f46d985138eedb75 (patch)
tree0e020e38f27b5a9ae1f6a9ce53242e9c0ce80398 /arch-nspawn.in
parent05ff74daefaa878a82e82e4b025bb3d8bd23ddf1 (diff)
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.
Diffstat (limited to 'arch-nspawn.in')
-rw-r--r--arch-nspawn.in12
1 files changed, 11 insertions, 1 deletions
diff --git a/arch-nspawn.in b/arch-nspawn.in
index 7481d82..dceb3ed 100644
--- a/arch-nspawn.in
+++ b/arch-nspawn.in
@@ -15,6 +15,8 @@ m4_include(lib/archroot.sh)
working_dir=''
+files=()
+
usage() {
echo "Usage: ${0##*/} [options] working-dir [systemd-nspawn arguments]"
echo "A wrapper around systemd-nspawn. Provides support for pacman."
@@ -23,15 +25,17 @@ usage() {
echo ' -C <file> Location of a pacman config file'
echo ' -M <file> Location of a makepkg config file'
echo ' -c <dir> Set pacman cache'
+ echo ' -f <file> Copy file from the host to the chroot'
echo ' -h This message'
exit 1
}
-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
@@ -77,6 +81,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"
}
# }}}