It is a bit confusing at this point how the Lustre version is set under what conditions. I'll keep some notes here as I go along, and maybe turn it into wiki doc later. The document under lustre/doc/VERSIONING is a bit out of date.
lustre/autoconf/lustre-version.ac contains m4 macros named LUSTRE_
{MAJOR,MINOR,PATCH,FIX}
. They are combine in a single LUSTRE_VERSION m4 macro that contains only the first three numbers if LUSTRE_FIX is zero, and all four numbers otherwise.
LUSTRE_VERSION is assigned to AC_LUSTRE_VERSION_STRING which is in turn made available more broadly with AC_SUBST. However AC_LUSTRE_VERSION_STRING is only currently used in one place, in lustre/include/lustre_ver.h.in and used to set a CPP define named LUSTRE_VERSION_STRING.
Partly m4 macros are used so that the LUSTRE_VERSION can be used in AC_INIT in configure.ac.
But it is not immediately clear to me why we use the extra steps of using AC_SUBST and later manually setting CPP macros with slightly different names when they could have just used AC_DEFINE directly.
Next, lets consider places that try to query the local git repo for information.
In config/lustre-build.m4, the LB_CONFIGURE macro calls LB_BUILDID.
LB_BUILDID first checks if we are in a local git repo by running "git branch" and ignoring the output. If that command returns success, the macro tries to use "git describe", only looking at tags that match the pattern of the old cvs-style tags with underscores in their name (why are we still doing that??), and pulling out hash portion to use as the buildid.
Alternatively, if "git branch" is unsuccessful LB_BUILDID tries to pull the buildid from a file named META. If that doesn't exist either, LB_BUILDID prints a scary warning but does not actually abort.
There are a number of strange things here. For instance, the code will warn if the starting part of the tag doesn't match $VERSION (where does that one get set?), but doesn't actually abort using the hash. That is kind of strange. Also this whole thing only happens once when configure is run the first time, and then cached. So if the developer makes 15 commits after running configure, presumably the hash that lustre gets built with will be completely wrong. That seems odd.
Also strange is that this code to parse git describe output is more or less duplicated, but not exactly, in lustre/scripts/version_tag-git.pl. For instance, version_tag-git.pl fails to employ the "--match" option with git describe the way that the configure script does.
lustre/scripts/version_tag-git.pl is one of the support scripts in the overly-complicated-for-what-it-does script named lustre/scripts/version_tag.pl. version_tag.pl is called from the special automake dist-hook target (or more specifically the dist-hook target calls the module-dist-hook target which runs version_tag.pl). So this script is called at "make dist" time to record the custom buildid that is partially assempled from the output of git --describe, and put that information into a file named "META" so that it is available in the canonical distribution tarball. When the tarball is used in the future, access to a local git repo will no longer be available.
This all seems much more convoluted than it needs to be. Open questions:
- Why don't we just do the parsing of "git --describe"'s output in one place instead of 2 or 3?
- Why don't we use the git --describe output in the version option of AC_INIT (we could use m4_esyscmd_s to call the same script that would be used elsewhere).
Change 18107 landed, so this is now fixed.