From b28158c54794c63088f66eb60ffb897d79dcef5a Mon Sep 17 00:00:00 2001
From: Matthew Pickering <matthewtpickering@gmail.com>
Date: Tue, 16 Jul 2024 11:56:08 +0100
Subject: [PATCH] Update to debian12 job names

---
 ci/discover_tarball.sh | 113 ++++++++++++++++++++++++++++-------------
 1 file changed, 78 insertions(+), 35 deletions(-)

diff --git a/ci/discover_tarball.sh b/ci/discover_tarball.sh
index a0b24c8e..bd5feef2 100755
--- a/ci/discover_tarball.sh
+++ b/ci/discover_tarball.sh
@@ -15,41 +15,84 @@ ARCH="$(uname -m)"
 # `needs` field in ghc/ghc .gitlab-ci.yml to avoid triggering the downstream job
 # too early.
 
-case $ARCH in
-  aarch64)
-    if [ -n "$NIGHTLY" ]; then
-      BINDIST_NAME="ghc-aarch64-linux-deb10-validate.tar.xz"
-      JOB_NAME="nightly-aarch64-linux-deb10-validate"
-    elif [ "$RELEASE_JOB" == "yes" ]; then
-      BINDIST_NAME="ghc-aarch64-linux-deb10-release+no_split_sections.tar.xz"
-      JOB_NAME="release-aarch64-linux-deb10-release+no_split_sections"
-    else
-      BINDIST_NAME="ghc-aarch64-linux-deb10-validate.tar.xz"
-      JOB_NAME="aarch64-linux-deb10-validate"
-    fi
-  ;;
-  *)
-    if [ -n "$SLOW_VALIDATE" ]; then
-      BINDIST_NAME="ghc-x86_64-linux-deb10-numa-slow-validate.tar.xz"
-      if [ -n "$NIGHTLY" ]; then
-        JOB_NAME="nightly-x86_64-linux-deb10-numa-slow-validate"
-      elif [ "$RELEASE_JOB" == "yes" ]; then
-        echo "No slow validate build in release job"
-        exit 2
-      else
-        JOB_NAME="x86_64-linux-deb10-numa-slow-validate"
-      fi
-    else
-      BINDIST_NAME="ghc-x86_64-linux-fedora33-release.tar.xz"
-      if [ -n "$NIGHTLY" ]; then
-        JOB_NAME="nightly-x86_64-linux-fedora33-release"
-      elif [ "$RELEASE_JOB" == "yes" ]; then
-        JOB_NAME="release-x86_64-linux-fedora33-release"
-      else
-        JOB_NAME="x86_64-linux-fedora33-release"
-      fi
-    fi
-  ;;
+# Before the update to deb12, we use the deb10 bindists
+case $UPSTREAM_BRANCH_NAME in
+  ghc-9.6|ghc-9.8|ghc-9.10)
+    case $ARCH in
+      aarch64)
+        if [ -n "$NIGHTLY" ]; then
+          BINDIST_NAME="ghc-aarch64-linux-deb10-validate.tar.xz"
+          JOB_NAME="nightly-aarch64-linux-deb10-validate"
+        elif [ "$RELEASE_JOB" == "yes" ]; then
+          BINDIST_NAME="ghc-aarch64-linux-deb10-release+no_split_sections.tar.xz"
+          JOB_NAME="release-aarch64-linux-deb10-release+no_split_sections"
+        else
+          BINDIST_NAME="ghc-aarch64-linux-deb10-validate.tar.xz"
+          JOB_NAME="aarch64-linux-deb10-validate"
+        fi
+      ;;
+      *)
+        if [ -n "$SLOW_VALIDATE" ]; then
+          BINDIST_NAME="ghc-x86_64-linux-deb10-numa-slow-validate.tar.xz"
+          if [ -n "$NIGHTLY" ]; then
+            JOB_NAME="nightly-x86_64-linux-deb10-numa-slow-validate"
+          elif [ "$RELEASE_JOB" == "yes" ]; then
+            echo "No slow validate build in release job"
+            exit 2
+          else
+            JOB_NAME="x86_64-linux-deb10-numa-slow-validate"
+          fi
+        else
+          BINDIST_NAME="ghc-x86_64-linux-fedora33-release.tar.xz"
+          if [ -n "$NIGHTLY" ]; then
+            JOB_NAME="nightly-x86_64-linux-fedora33-release"
+          elif [ "$RELEASE_JOB" == "yes" ]; then
+            JOB_NAME="release-x86_64-linux-fedora33-release"
+          else
+            JOB_NAME="x86_64-linux-fedora33-release"
+          fi
+        fi
+      ;;
+    esac
+    ;;
+  *) # Post update to use deb12
+    case $ARCH in
+      aarch64)
+        if [ -n "$NIGHTLY" ]; then
+          BINDIST_NAME="ghc-aarch64-linux-deb12-validate.tar.xz"
+          JOB_NAME="nightly-aarch64-linux-deb12-validate"
+        elif [ "$RELEASE_JOB" == "yes" ]; then
+          BINDIST_NAME="ghc-aarch64-linux-deb12-release+no_split_sections.tar.xz"
+          JOB_NAME="release-aarch64-linux-deb12-release+no_split_sections"
+        else
+          BINDIST_NAME="ghc-aarch64-linux-deb12-validate.tar.xz"
+          JOB_NAME="aarch64-linux-deb12-validate"
+        fi
+      ;;
+      *)
+        if [ -n "$SLOW_VALIDATE" ]; then
+          BINDIST_NAME="ghc-x86_64-linux-deb12-numa-slow-validate.tar.xz"
+          if [ -n "$NIGHTLY" ]; then
+            JOB_NAME="nightly-x86_64-linux-deb12-numa-slow-validate"
+          elif [ "$RELEASE_JOB" == "yes" ]; then
+            echo "No slow validate build in release job"
+            exit 2
+          else
+            JOB_NAME="x86_64-linux-deb12-numa-slow-validate"
+          fi
+        else
+          BINDIST_NAME="ghc-x86_64-linux-fedora33-release.tar.xz"
+          if [ -n "$NIGHTLY" ]; then
+            JOB_NAME="nightly-x86_64-linux-fedora33-release"
+          elif [ "$RELEASE_JOB" == "yes" ]; then
+            JOB_NAME="release-x86_64-linux-fedora33-release"
+          else
+            JOB_NAME="x86_64-linux-fedora33-release"
+          fi
+        fi
+      ;;
+    esac
+    ;;
 esac
 
 >&2 echo "BINDIST_NAME=${BINDIST_NAME}"
-- 
GitLab