summaryrefslogtreecommitdiff
path: root/src/chroot-tools/librechroot
diff options
context:
space:
mode:
Diffstat (limited to 'src/chroot-tools/librechroot')
-rwxr-xr-xsrc/chroot-tools/librechroot39
1 files changed, 35 insertions, 4 deletions
diff --git a/src/chroot-tools/librechroot b/src/chroot-tools/librechroot
index e6b3a3a..cc416d5 100755
--- a/src/chroot-tools/librechroot
+++ b/src/chroot-tools/librechroot
@@ -49,28 +49,59 @@ readonly _makechrootpkg="$(librelib chroot/makechrootpkg.sh)"
arch_nspawn_flags=()
sysd_nspawn_flags=()
+hack_arch_nspawn_flags() {
+ local copydir="$1"
+
+ local makepkg_conf="$copydir/etc/makepkg.conf"
+
+ OPTIND=1
+ set -- ${arch_nspawn_flags+"${arch_nspawn_flags[@]}"}
+ while getopts 'hC:M:c:f:s' arg; do
+ case "$arg" in
+ M) makepkg_conf="$OPTARG" ;;
+ *) :;;
+ esac
+ done
+
+ local CARCH
+ if [[ -f "$makepkg_conf" ]]; then
+ eval $(grep '^CARCH=' "$makepkg_conf")
+ else
+ CARCH="$(uname -m)"
+ fi
+
+ if [[ "$CARCH" == armv7h ]] && ! setarch armv7l 2>/dev/null; then
+ arch_nspawn_flags+=(-f /usr/bin/qemu-arm-static -s)
+ fi
+}
+
# Usage: arch-nspawn $copydir $cmd...
-arch-nspawn() {
+arch-nspawn() (
local copydir=$1; shift
local cmd=("$@")
+ hack_arch_nspawn_flags "$copydir"
+
"$_arch_nspawn" \
${arch_nspawn_flags+"${arch_nspawn_flags[@]}"} \
"$copydir" \
${sysd_nspawn_flags+"${sysd_nspawn_flags[@]}"} \
-- \
"${cmd[@]}"
-}
+)
# Usage: mkarchroot $copydir $pkgs...
-mkarchroot() {
+mkarchroot() (
local copydir=$1; shift
local pkgs=("$@")
+
+ hack_arch_nspawn_flags "$copydir"
+
unshare -m "$_mkarchroot" \
${arch_nspawn_flags+"${arch_nspawn_flags[@]}"} \
"$copydir" \
"${pkgs[@]}"
-}
+)
# Usage: _makechrootpkg $function $arguments...
# Don't load $_makechrootpkg directly because it doesn't work with -euE