Skip to content

Commit

Permalink
fix --print-foreign-architectures parsing
Browse files Browse the repository at this point in the history
The amount foreign archs may be 0, 1, or more. Currently the cross-arch
parsing fails if no foreign archs or more than 1. Use a fore loop to
compare.
  • Loading branch information
Riku Voipio authored and Thomas Lange committed Apr 25, 2018
1 parent 377b313 commit a0792ee
Show file tree
Hide file tree
Showing 2 changed files with 16 additions and 5 deletions.
10 changes: 8 additions & 2 deletions lib/check-cross-arch
Original file line number Diff line number Diff line change
Expand Up @@ -45,10 +45,16 @@ cross=1
# debugging echo myarch: $myarch targetarch: $targetarch
if [ $myarch = $targetarch ]; then
cross=0
elif [ $targetarch = $(dpkg --print-foreign-architectures) ]; then
cross=0
fi

for arch in $(dpkg --print-foreign-architectures)
do
if [ $myarch = $arch ]; then
cross=0
break
fi
done


if [ $cross -eq 1 ]; then
[ X$verbose = X1 ] && echo "Using qemu-$targetarch-static for cross architecture chroot."
Expand Down
11 changes: 8 additions & 3 deletions lib/subroutines
Original file line number Diff line number Diff line change
Expand Up @@ -948,16 +948,21 @@ call_debootstrap() {
# Check if we need cross architecture debootstrap
targetarch=$(expr "$FAI_DEBOOTSTRAP_OPTS" : '.*--arch=\([^[:space:]]*\)' || true)
hostarch1=$(dpkg --print-architecture)
hostarch2=$(dpkg --print-foreign-architectures)

_debootstrap=qemu-debootstrap
if [ -z "$targetarch" ]; then
_debootstrap=debootstrap
else
if [ $targetarch = $hostarch1 -o $targetarch = $hostarch2 ]; then
if [ $targetarch = $hostarch1 ]; then
_debootstrap=debootstrap
fi
fi
for arch in $(dpkg --print-foreign-architectures)
do
if [ $targetarch = $arch ]; then
_debootstrap=debootstrap
break
fi
done
if [ $_debootstrap = "qemu-debootstrap" ]; then
if ! type -P $_debootstrap >/dev/null; then
die 1 "qemu-debootstrap not found. Please install the package qemu-user-static."
Expand Down

0 comments on commit a0792ee

Please sign in to comment.