Skip to content

Commit

Permalink
configure: add check for valid version
Browse files Browse the repository at this point in the history
Problem: autoconf will accept junk at configure time as a valid
version, then go off and generate an invalid version.h file. This
happens frequently with shallow clones, setups in CI, or other
constrained user environments. It has caused new contributors a
lot of confusion in the past.

Solution: Like flux-framework/flux-sched#1219 suggested, reject
invalid versions at configure time and provide appropriate
suggestions to the user to remedy this.
  • Loading branch information
wihobbs committed Sep 10, 2024
1 parent aef4447 commit 7d51b50
Showing 1 changed file with 17 additions and 0 deletions.
17 changes: 17 additions & 0 deletions configure.ac
Original file line number Diff line number Diff line change
Expand Up @@ -35,6 +35,23 @@ AX_POINT_VERSION=$(echo $AX_POINT_VERSION | $SED 's/-.*$//')
AC_SUBST([AX_MAJOR_VERSION])
AC_SUBST([AX_MINOR_VERSION])
AC_SUBST([AX_POINT_VERSION])
if ! echo ${AX_MAJOR_VERSION} | grep -q [[0-9]][[0-9]]* ||
! echo ${AX_MINOR_VERSION} | grep -q [[0-9]][[0-9]]* ; then
version_err_msg="
VERSION ${VERSION} is invalid.
Try the following to remedy this:

1. Set the variable manually, with FLUX_VERSION=<version>
in your environment.
2. If you are running in a CI environment, run \`git fetch tags\`
before building. Versions in flux-core are derived from
\`git describe\` which uses the most recent tag.
3. If you are running in a fork of the main repository, try
\`git push --tags\` to make sure tags are synchronized in
your fork.
"
AC_MSG_ERROR(["${version_err_msg}"])
fi

##
# Initialize pkg-config for PKG_CHECK_MODULES to avoid conditional issues
Expand Down

0 comments on commit 7d51b50

Please sign in to comment.