From c23f66e6cfaf5db8ad3ac1b6be928f4ee207846a Mon Sep 17 00:00:00 2001
From: Johannes Schauer Marin Rodrigues <josch@mister-muffin.de>
Date: Sat, 22 Oct 2022 23:24:40 +0200
Subject: [PATCH] Only build natively if there are either arch:all or arch:any
 packages to build for the host architecture

---
 build.sh | 11 +++++++----
 1 file changed, 7 insertions(+), 4 deletions(-)

diff --git a/build.sh b/build.sh
index 31b4f68..aebbc3e 100755
--- a/build.sh
+++ b/build.sh
@@ -133,13 +133,16 @@ for p in patches/*; do
 			sbuild -d "$BASESUITE" --host="$HOST_ARCH" --no-arch-all --arch-any --nolog --no-clean-source --no-source-only-changes --no-run-lintian --no-run-autopkgtest --extra-repository="$SRC_LIST_PATCHED" --no-apt-upgrade --no-apt-distupgrade
 			reprepro include "$OURSUITE" ../*.changes
 		fi
-		# natively build everything
+		# natively build arch:all packages and build-arch packages
 		# just building arch:all packages is not enough in case later
 		# packages need to install native arch versions of m-a:same
 		# packages and we need to prevent a version skew
-		rm -f ../*.changes
-		sbuild -d "$BASESUITE" --arch-all --arch-any --nolog --no-clean-source --no-source-only-changes --no-run-lintian --no-run-autopkgtest --extra-repository="$SRC_LIST_PATCHED" --no-apt-upgrade --no-apt-distupgrade
-		reprepro include "$OURSUITE" ../*.changes
+		if [ -n "$(env DEB_HOST_ARCH=$BUILD_ARCH dh_listpackages -i)" ] \
+		|| [ -n "$(env DEB_HOST_ARCH=$BUILD_ARCH dh_listpackages -a)" ]; then
+			rm -f ../*.changes
+			sbuild -d "$BASESUITE" --arch-all --arch-any --nolog --no-clean-source --no-source-only-changes --no-run-lintian --no-run-autopkgtest --extra-repository="$SRC_LIST_PATCHED" --no-apt-upgrade --no-apt-distupgrade
+			reprepro include "$OURSUITE" ../*.changes
+		fi
 		cd ..
 	)
 	rm -Rf "$WORKDIR"
-- 
GitLab