Send patches - preferably formatted by git format-patch - to patches at archlinux32 dot org.
summaryrefslogtreecommitdiff
diff options
context:
space:
mode:
-rw-r--r--arch-nspawn.in12
-rw-r--r--mkarchroot.in11
2 files changed, 21 insertions, 2 deletions
diff --git a/arch-nspawn.in b/arch-nspawn.in
index 316dfa8..535a97b 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 <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
}
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"
}
# }}}
diff --git a/mkarchroot.in b/mkarchroot.in
index 656c74e..8499ed1 100644
--- a/mkarchroot.in
+++ b/mkarchroot.in
@@ -16,23 +16,27 @@ CHROOT_VERSION='v3'
working_dir=''
+files=()
+
usage() {
echo "Usage: ${0##*/} [options] working-dir package-list..."
echo ' options:'
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
}
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
@@ -70,6 +74,11 @@ if [[ $(stat -f -c %T "$working_dir") == btrfs ]]; then
chmod 0755 "$working_dir"
fi
+for file in "${files[@]}"; do
+ mkdir -p "$(dirname "$working_dir$file")"
+ cp "$file" "$working_dir$file"
+done
+
pacstrap -GMcd ${pac_conf:+-C "$pac_conf"} "$working_dir" \
"${cache_dirs[@]/#/--cachedir=}" "$@" || die 'Failed to install all packages'