icinga2 icon indicating copy to clipboard operation
icinga2 copied to clipboard

Get version string from git-describe, git-archive or CMake config

Open jschmidt-icinga opened this issue 1 year ago • 1 comments

Currently if the source directory is not a git repo, the version string will be the last released version set in the ICINGA2_VERSION file.

This PR makes the following improvements:

  • If git-describe fails because the source directory isn't a git repo or ICINGA2_GIT_VERSION_INFO is OFF, the version is read from a file processed by git-archive.
  • The version file ICINGA2_VERSION is removed and replaced with a variable at the top of the main CMakeLists.txt that will need to be updated manually on a new release.
  • New variables ICINGA2_PACKAGE_(VERSION|REVISION|VENDOR) are added that can be customized by package build process. These are utilized for Windows MSI builds (via CPACK)
  • Package version information can be printed in icinga2 --version if the new option ICINGA2_INCLUDE_PACKAGE_INFO is set to ON (defaults to OFF). I added an additional option for this because I wanted to use defaults, description and type for the package version/revision/vendor cache variables, and otherwise there is no reliable way to detect that the user has changed the information and include the --version section based on that.

Here is an overview of how the variables/constants and their meaning has changed:

Before:

CMake C++ (and Windows cruft) meaning
GIT_VERSION VERSION The best approximation of the actual version, either git describe or spec version + revision from the ICINGA2_VERSION file
ICINGA2_VERSION ICINGA2_VERSION Like above with the 'v' prefix removed and no package revision suffix in case no git version was found
SPEC_VERSION SPEC_VERSION The package version defined manually in the ICINGA2_VERSION file

After:

CMake C++ (and Windows cruft) meaning
ICINGA2_VERSION ICINGA_VERSION The best approximation of the actual version, going from git-describe -> git-archive info -> package version + revision
ICINGA2_RC_VERSION ICINGA_RC_VERSION Like above, but with removed 'v' prefix
ICINGA2_PACKAGE_VERSION ICINGA_PACKAGE_VERSION The manually defined, abbreviated version string

Fixes #10016 Fixes #8960

jschmidt-icinga avatar Oct 01 '25 08:10 jschmidt-icinga

You found a thing here that I wasn't really aware of so far: GetAppSpecVersion(). It looks like you started using that new package version thing where this was used before, can you summarize why you did it that way?

Firstly, the icinga.rc file using the PACKAGE_VERSION constant was a misunderstanding from me, because I didn't see that it could also use the full git version, just with the 'v' removed.

Mostly I tried to get some consistency into what the variables mean. SPEC_VERSION is replaced with ICINGA_PACKAGE_VERSION and ICINGA2_VERSION (which previously was just a copy of SPEC_VERSION) is now the "real" version, that only defaults to the package version if all other means of getting a version string fail.

I'll update the PR description with a comparison between master and this PR.

jschmidt-icinga avatar Oct 17 '25 09:10 jschmidt-icinga