summaryrefslogtreecommitdiff
path: root/src/chroot-tools/librechroot
diff options
context:
space:
mode:
authorLuke Shumaker <lukeshu@sbcglobal.net>2016-05-09 22:48:09 -0400
committerLuke Shumaker <lukeshu@sbcglobal.net>2016-05-09 22:48:09 -0400
commit9f16ca1852e0461f493ccfbd33792623774d6e1e (patch)
treea1c70f43c4046fa53b7bd2d7365df4358ee344f7 /src/chroot-tools/librechroot
parent4c55c0216c1efe94eeb9cad91b6052e463c9d57b (diff)
librechroot: Support using qemu for ARM builds on x86 via binfmt_misc.
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