[Git][ghc/ghc][wip/T25390] configure: Check version number validity

Ben Gamari (@bgamari) gitlab at gitlab.haskell.org
Wed Oct 30 15:00:41 UTC 2024



Ben Gamari pushed to branch wip/T25390 at Glasgow Haskell Compiler / GHC


Commits:
2985af36 by Ben Gamari at 2024-10-30T11:00:29-04:00
configure: Check version number validity

Here we verify the previously informal invariant that stable release
version numbers must have three components, preventing costly failed
releases.

Specifically, the check fails in the following scenarios:

 * `version=9.13` while `RELEASE=YES` since this would imply a
   release made from an unstable branch
 * `version=9.13.0` since unstable versions should only have two
   components
 * `version=9.12` since this has the wrong number of version components
   for a stable branch

Fixes #25390.

- - - - -


1 changed file:

- m4/fp_setup_project_version.m4


Changes:

=====================================
m4/fp_setup_project_version.m4
=====================================
@@ -2,6 +2,9 @@
 # ---------------------
 AC_DEFUN([FP_SETUP_PROJECT_VERSION],
 [
+    # number of version number components
+    NumVersionComponents="$(( $(echo "$PACKAGE_VERSION" | tr -cd . | wc -c) + 1 ))"
+
     if test "$RELEASE" = "NO"; then
         AC_MSG_CHECKING([for GHC version date])
         if test -f VERSION_DATE; then
@@ -62,6 +65,22 @@ AC_DEFUN([FP_SETUP_PROJECT_VERSION],
     VERSION_MINOR=`echo $VERSION_TMP | sed 's/^\(@<:@^.@:>@*\)\(\.\{0,1\}\(.*\)\)$/\1'/`
     ProjectPatchLevel=`echo $VERSION_TMP | sed 's/^\(@<:@^.@:>@*\)\(\.\{0,1\}\(.*\)\)$/\3'/`
 
+    # Verify that the version number has three components if a release version
+    # (that is, even minor version number).
+    AC_MSG_CHECKING([package version validity])
+    StableRelease="$(( ($VERSION_MINOR & 1) == 0))"
+    if test "$StableRelease" = "1" -a "$NumVersionComponents" != "3"; then
+        AC_MSG_ERROR([Stable (even) version numbers must have three components])
+    elif test "$StableRelease" = "0" -a "$NumVersionComponents" != "2"; then
+        AC_MSG_ERROR([Unstable (odd) version numbers must have two components])
+    elif test "$RELEASE" = "YES" -a "$StableRelease" = "0"; then
+        AC_MSG_ERROR([RELEASE=YES despite having an unstable odd minor version number])
+    elif test "$StableRelease" = "1"; then
+        AC_MSG_RESULT([okay stable branch version])
+    else
+        AC_MSG_RESULT([okay unstable branch version])
+    fi
+
     # Calculate project version as an integer, using 2 digits for minor version
     case $VERSION_MINOR in
       ?) ProjectVersionInt=${VERSION_MAJOR}0${VERSION_MINOR} ;;



View it on GitLab: https://gitlab.haskell.org/ghc/ghc/-/commit/2985af3605ad7aeb527b35da23ba79f12c4979eb

-- 
View it on GitLab: https://gitlab.haskell.org/ghc/ghc/-/commit/2985af3605ad7aeb527b35da23ba79f12c4979eb
You're receiving this email because of your account on gitlab.haskell.org.


-------------- next part --------------
An HTML attachment was scrubbed...
URL: <http://mail.haskell.org/pipermail/ghc-commits/attachments/20241030/bd891b41/attachment-0001.html>


More information about the ghc-commits mailing list