[Git][ghc/ghc][wip/T25390] configure: Check version number validity
Ben Gamari (@bgamari)
gitlab at gitlab.haskell.org
Fri Oct 18 17:28:40 UTC 2024
Ben Gamari pushed to branch wip/T25390 at Glasgow Haskell Compiler / GHC
Commits:
279a5d2b by Ben Gamari at 2024-10-18T13:28:10-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,26 @@ 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 "$RELEASE" = "NO"; then
+ if test "$NumVersionComponents" != "2"; then
+ AC_MSG_ERROR([Version numbers on unstable branches must have two components])
+ else
+ AC_MSG_RESULT([okay unstable version])
+ fi
+ 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
+ if test "$NumVersionComponents" != "3"; then
+ AC_MSG_ERROR([Version numbers on stable branches must have three components])
+ else
+ AC_MSG_RESULT([okay stable version])
+ fi
+ 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/279a5d2b56f90a841dbad958704e81257f306ead
--
View it on GitLab: https://gitlab.haskell.org/ghc/ghc/-/commit/279a5d2b56f90a841dbad958704e81257f306ead
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/20241018/a64e09fc/attachment-0001.html>
More information about the ghc-commits
mailing list