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:
Diffstat (limited to 'arch-nspawn.in')
-rw-r--r--arch-nspawn.in29
1 files changed, 14 insertions, 15 deletions
diff --git a/arch-nspawn.in b/arch-nspawn.in
index adee72e..0b0dc68 100644
--- a/arch-nspawn.in
+++ b/arch-nspawn.in
@@ -11,8 +11,7 @@
# GNU General Public License for more details.
m4_include(lib/common.sh)
-
-CHROOT_VERSION='v3'
+m4_include(lib/archroot.sh)
working_dir=''
@@ -32,8 +31,6 @@ usage() {
exit 1
}
-orig_argv=("$@")
-
while getopts 'hC:M:c:f:s' arg; do
case "$arg" in
C) pac_conf="$OPTARG" ;;
@@ -45,10 +42,10 @@ while getopts 'hC:M:c:f:s' arg; do
*) error "invalid argument '%s'" "$arg"; usage ;;
esac
done
-shift $(($OPTIND - 1))
+shift $((OPTIND - 1))
(( $# < 1 )) && die 'You must specify a directory.'
-check_root "$0" "${orig_argv[@]}"
+check_root
working_dir=$(readlink -f "$1")
shift 1
@@ -61,7 +58,9 @@ else
cache_dirs=("$cache_dir")
fi
+# shellcheck disable=2016
host_mirror=$(pacman --cachedir /doesnt/exist -Sddp extra/devtools 2>/dev/null | sed -r 's#(.*/)extra/os/.*#\1$repo/os/$arch#')
+# shellcheck disable=2016
[[ $host_mirror == *file://* ]] && host_mirror_path=$(echo "$host_mirror" | sed -r 's#file://(/.*)/\$repo/os/\$arch#\1#g')
# {{{ functions
@@ -69,13 +68,13 @@ build_mount_args() {
declare -g mount_args=()
if [[ -n $host_mirror_path ]]; then
- mount_args+=(--bind-ro="$host_mirror_path")
+ mount_args+=("--bind-ro=$host_mirror_path")
fi
- mount_args+=(--bind="${cache_dirs[0]}")
+ mount_args+=("--bind=${cache_dirs[0]}")
- for cache_dir in ${cache_dirs[@]:1}; do
- mount_args+=(--bind-ro="$cache_dir")
+ for cache_dir in "${cache_dirs[@]:1}"; do
+ mount_args+=("--bind-ro=$cache_dir")
done
}
@@ -83,8 +82,8 @@ copy_hostconf () {
cp -a /etc/pacman.d/gnupg "$working_dir/etc/pacman.d"
echo "Server = $host_mirror" >"$working_dir/etc/pacman.d/mirrorlist"
- [[ -n $pac_conf ]] && cp $pac_conf "$working_dir/etc/pacman.conf"
- [[ -n $makepkg_conf ]] && cp $makepkg_conf "$working_dir/etc/makepkg.conf"
+ [[ -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
@@ -92,7 +91,7 @@ copy_hostconf () {
cp -T "$file" "$working_dir$file"
done
- sed -r "s|^#?\\s*CacheDir.+|CacheDir = $(echo -n ${cache_dirs[@]})|g" -i "$working_dir/etc/pacman.conf"
+ sed -r "s|^#?\\s*CacheDir.+|CacheDir = $(echo -n "${cache_dirs[@]}")|g" -i "$working_dir/etc/pacman.conf"
}
# }}}
@@ -101,7 +100,7 @@ umask 0022
# Sanity check
if [[ ! -f "$working_dir/.arch-chroot" ]]; then
die "'%s' does not appear to be an Arch chroot." "$working_dir"
-elif [[ $(cat "$working_dir/.arch-chroot") != $CHROOT_VERSION ]]; then
+elif [[ $(cat "$working_dir/.arch-chroot") != "$CHROOT_VERSION" ]]; then
die "chroot '%s' is not at version %s. Please rebuild." "$working_dir" "$CHROOT_VERSION"
fi
@@ -109,7 +108,7 @@ build_mount_args
cache_dirs+=('/repo/')
copy_hostconf
-eval $(grep '^CARCH=' "$working_dir/etc/makepkg.conf")
+eval "$(grep '^CARCH=' "$working_dir/etc/makepkg.conf")"
case "$CARCH" in
armv7h) CARCH=armv7l;;
esac