Skip to content

Conversation

@jschmidt-icinga
Copy link
Contributor

@jschmidt-icinga jschmidt-icinga commented Oct 1, 2025

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

@cla-bot cla-bot bot added the cla/signed label Oct 1, 2025
@jschmidt-icinga jschmidt-icinga force-pushed the get-version-from-git-export-subst branch from 7dec8c1 to bf37496 Compare October 1, 2025 12:56
Copy link
Contributor

@julianbrost julianbrost left a comment

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

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? That makes the fixes for #10016 and #8960 more interleaved than I had expected: I would have expected that package version to be an informative thing for the icinga2 --version output only, so can you please elaborate why you chose to use it in more places?

Please tell me if a more complex approach is needed.

If anything, this should become simpler :D

Copy link
Contributor

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

I don't see why this shouldn't just become part of https://github.com/Icinga/icinga2/blob/master/config.h.cmake

That's already used for passing all kinds of information from CMake to C++.

Copy link
Contributor Author

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Done. However to remain consistent with the constant names in that file I added the ICINGA_ prefix to all of them, which meant touching a few additional lines in check_nscp_api.cpp which is using them directly.

@jschmidt-icinga jschmidt-icinga force-pushed the get-version-from-git-export-subst branch from bf37496 to 377098f Compare October 17, 2025 09:26
@jschmidt-icinga
Copy link
Contributor Author

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 jschmidt-icinga force-pushed the get-version-from-git-export-subst branch from 377098f to 57fc2a8 Compare October 17, 2025 09:38
@jschmidt-icinga jschmidt-icinga force-pushed the get-version-from-git-export-subst branch from 57fc2a8 to 6cef993 Compare October 17, 2025 09:45
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment

Projects

None yet

Development

Successfully merging this pull request may close these issues.

The version of the master is not the latest release Add package version and vendor to icinga2 --version

3 participants