[Dev] [PATCHv2] make librechroot target arch agnostic
Andreas Grapentin
andreas at grapentin.org
Thu Mar 1 09:00:21 GMT 2018
Hi,
Thanks for the feedback :)
I have attached an updated patch.
-A
---
src/chroot-tools/librechroot | 21 +++++++++++++--------
1 file changed, 13 insertions(+), 8 deletions(-)
diff --git a/src/chroot-tools/librechroot b/src/chroot-tools/librechroot
index 27e17bd..dec14bc 100755
--- a/src/chroot-tools/librechroot
+++ b/src/chroot-tools/librechroot
@@ -69,17 +69,22 @@ hack_arch_nspawn_flags() {
CARCH="$(uname -m)"
fi
- if [[ "$CARCH" == armv7h ]] && ! setarch armv7l /bin/true 2>/dev/null; then
- # We're running an ARM chroot on a non-ARM processor
+ local setarch interpreter
+ case $CARCH in
+ armv7h) setarch=armv7l; interpreter=/usr/bin/qemu-arm-static ;;
+ *) setarch=$CARCH; interpreter=/usr/bin/qemu-$CARCH-static ;;
+ esac
+ if ! setarch $setarch /bin/true 2>/dev/null; then
+ # We're running a cross-arch chroot
# Make sure that qemu-static is set up with binfmt_misc
if [[ -z $(grep -l -xF \
- -e 'interpreter /usr/bin/qemu-arm-static' \
+ -e "interpreter $interpreter" \
-r -- /proc/sys/fs/binfmt_misc 2>/dev/null \
| xargs -r grep -xF 'enabled') ]]
then
- error 'Cannot cross-compile for ARM on x86'
- plain 'This requires a binfmt_misc entry for qemu-arm-static.'
+ error 'Cannot cross-compile for %s on %s' "$CARCH" "$(uname -m)"
+ plain 'This requires a binfmt_misc entry for %s.' "$interpreter"
prose 'Such a binfmt_misc entry is provided by the %s
package. If you have it installed, but still see
this message, you may need to restart %s.' \
@@ -88,13 +93,13 @@ hack_arch_nspawn_flags() {
fi
# Let qemu/binfmt_misc do its thing
- arch_nspawn_flags+=(-f /usr/bin/qemu-arm-static -s)
+ arch_nspawn_flags+=(-f $interpreter -s)
# The -any packages are built separately for ARM from
# x86, so if we use the same CacheDir as the x86 host,
# then there will be PGP errors.
- mkdir -p /var/cache/pacman/pkg-arm
- arch_nspawn_flags+=(-c /var/cache/pacman/pkg-arm)
+ mkdir -p /var/cache/pacman/pkg-$CARCH
+ arch_nspawn_flags+=(-c /var/cache/pacman/pkg-$CARCH)
fi
}
--
2.16.2
--
------------------------------------------------------------------------------
Andreas Grapentin, M.Sc. Research Assistant @ Hasso-Plattner-Institut
Operating Systems and Middleware Group www.dcl.hpi.uni-potsdam.de
Phone: +49 (0) 331 55 09-238 Fax: +49 (0) 331 55 09-229
my GPG Public Key: https://files.grapentin.org/.gpg/public.key
------------------------------------------------------------------------------
-------------- next part --------------
A non-text attachment was scrubbed...
Name: signature.asc
Type: application/pgp-signature
Size: 488 bytes
Desc: not available
URL: <https://lists.parabola.nu/pipermail/dev/attachments/20180301/e7723d47/attachment.sig>
More information about the Dev
mailing list