Description: fix autopkgtest failure on 32-bit architectures
 The memory calculation system may erroneously attribute far more memory than
 is addressable on 32-bit platforms.  This adjustment makes sure the calculated
 amount of RAM is capped appropriately on such platforms.
Author: Étienne Mollier <emollier@debian.org>
Forwarded: no
Last-Update: 2021-10-06
---
This patch header follows DEP-3: http://dep.debian.net/deps/dep3/
--- bbmap.orig/calcmem.sh
+++ bbmap/calcmem.sh
@@ -203,6 +203,11 @@
 		# available (ram - 500k) * 85% / 1024kb = megs of ram to use
 		# not sure where this formula came from
 		RAM=$(( ((x-500000)*mult/100)/1024 ))
+		# cap to 2.2GiB on 32bit systems
+		if [ "$(dpkg-architecture -qDEB_HOST_ARCH_BITS)" = 32 ] \
+		   && [ "$RAM" -gt "2200" ]
+		then RAM="2200"
+		fi
 		#echo $RAM
 	fi
 	#local z="-Xmx${RAM}m"
