scripts/tarballs: add gapk

Closes: OS#6227
Change-Id: I6f26b6f5953701b383acb3b93058b66a286f7989
diff --git a/scripts/common.sh b/scripts/common.sh
index 8099499..194feff 100644
--- a/scripts/common.sh
+++ b/scripts/common.sh
@@ -77,11 +77,20 @@
 	local project="$1"
 	local amount="$2"
 	local default_str="$3"
-	local url ret
+	local url ret pattern
+
+	case "$project" in
+	gapk)
+		pattern='refs/tags/v[0-9.]*$'
+		;;
+	*)
+		pattern='refs/tags/[0-9.]*$'
+		;;
+	esac
 
 	url="$(osmo_git_clone_url "$project")"
 	ret="$(git ls-remote --tags "$url")"
-	ret="$(echo "$ret" | grep 'refs/tags/[0-9.]*$' || true)"
+	ret="$(echo "$ret" | grep "$pattern" || true)"
 	ret="$(echo "$ret" | sort -V -t/ -k3)"
 	if [ "$amount" != "all" ]; then
 		ret="$(echo "$ret" | tail -n "$amount")"
diff --git a/scripts/tarballs/prefer-configure.sh b/scripts/tarballs/prefer-configure.sh
new file mode 100755
index 0000000..f9f8613
--- /dev/null
+++ b/scripts/tarballs/prefer-configure.sh
@@ -0,0 +1,25 @@
+#!/bin/sh -ex
+# Decide whether to build a tarball from autotools logic (exit 0) or by
+# creating a simple git archive (exit 1)
+
+PROJECT="$1"
+TAG="$2"
+
+if ! [ -e configure.ac ]; then
+	exit 1
+fi
+
+case "$PROJECT" in
+gapk)
+	# Running gapk's configure involves running libgsmhr/fetch_sources.py,
+	# which according to git log doesn't really work unless using the
+	# version from master and it looks like we don't want to distribute
+	# these sources directly... or else we should just add them to the git
+	# repository and not rely on downloading a remote archive that may just
+	# change at any time. So create a simple git archive instead.
+	exit 1
+	;;
+*)
+	exit 0
+	;;
+esac
diff --git a/scripts/tarballs/publish-tarballs-for-tags.sh b/scripts/tarballs/publish-tarballs-for-tags.sh
index 3cd8a15..26e949f 100755
--- a/scripts/tarballs/publish-tarballs-for-tags.sh
+++ b/scripts/tarballs/publish-tarballs-for-tags.sh
@@ -8,6 +8,7 @@
 LOG_PREFIX="::"
 
 OSMO_RELEASE_REPOS="
+	gapk
 	libasn1c
 	libgtpnl
 	libosmo-abis
@@ -237,7 +238,7 @@
 
 			cd /src/$project_path
 
-			if [ -e configure.ac ]; then
+			if /tarballs/prefer-configure.sh \"$repo\" \"$tag\"; then
 				su build -c \"autoreconf -fi\"
 				case \"$repo\" in
 				osmo-trx)