meson: Start adding devel and rc suffixes to the project version

Let's make sure that versions generated by meson-vcs-tag.sh always
sort higher than official and stable releases. We achieve this by
immediately updating the meson version in meson.build after a new
release. To make sure this version always sorts lower than future
rcs, we suffix it with "~devel" which will sort lower than "~rcX".

The new release workflow is to update the version in meson.build
for each rc and the official release and to also update the version
number after a new release to the next development version.

The full version is exposed as PROJECT_VERSION_FULL and used where
it makes sense over PROJECT_VERSION.

We also switch to reading the version from a meson.version file in
the repo instead of hardcoding it in meson.build. This makes it
easier to access both inside and outside of the project.

The meson-vcs-tag.sh script is rewritten to query the version from
meson.version instead of passing it in via the command line. This
makes it easier to use outside of systemd since users don't have to
query the version themselves first.
This commit is contained in:
Daan De Meyer 2024-02-14 11:04:36 +01:00
parent c0561a05f5
commit ea2a57bee3
15 changed files with 52 additions and 37 deletions

View File

@ -12,17 +12,19 @@ SPDX-License-Identifier: LGPL-2.1-or-later
3. Update the time and place in NEWS
4. Update hwdb (`ninja -C build update-hwdb`, `ninja -C build update-hwdb-autosuspend`, commit separately).
5. Update syscall numbers (`ninja -C build update-syscall-tables update-syscall-header`).
6. [RC1] Update version and library numbers in `meson.build`
7. Check dbus docs with `ninja -C build update-dbus-docs`
8. Update translation strings (`cd build`, `meson compile systemd-pot`, `meson compile systemd-update-po`) - drop the header comments from `systemd.pot` + re-add SPDX before committing. If the only change in a file is the 'POT-Creation-Date' field, then ignore that file.
9. Tag the release: `version=vXXX~rcY && git tag -s "${version}" -m "systemd ${version}"`. Note that this uses a tilde (\~) instead of a hyphen (-) because tildes sort lower in version comparisons according to the [version format specification](https://uapi-group.org/specifications/specs/version_format_specification/), and we want `v255~rc1` to sort lower than `v255`.
10. Do `ninja -C build`
11. Make sure that the version string and package string match: `build/systemctl --version`
12. [FINAL] Close the github milestone and open a new one (https://github.com/systemd/systemd/milestones)
13. "Draft" a new release on github (https://github.com/systemd/systemd/releases/new), mark "This is a pre-release" if appropriate.
14. Check that announcement to systemd-devel, with a copy&paste from NEWS, was sent. This should happen automatically.
15. Update IRC topic (`/msg chanserv TOPIC #systemd Version NNN released | Online resources https://systemd.io/`)
16. [FINAL] Push commits to stable, create an empty -stable branch: `git push systemd-stable --atomic origin/main:main origin/main:refs/heads/${version}-stable`.
17. [FINAL] Build and upload the documentation (on the -stable branch): `ninja -C build doc-sync`
18. [FINAL] Change the default branch to latest release (https://github.com/systemd/systemd-stable/settings/branches).
19. [FINAL] Change the Github Pages branch in the stable repository to the newly created branch (https://github.com/systemd/systemd-stable/settings/pages) and set the 'Custom domain' to 'systemd.io'
6. [RC1] Update library numbers in `meson.build`
7. Update version number in `meson.version` (e.g. from `v256~devel` to `v256~rc1` or from `v256~rc3` to `v256`)
8. Check dbus docs with `ninja -C build update-dbus-docs`
9. Update translation strings (`cd build`, `meson compile systemd-pot`, `meson compile systemd-update-po`) - drop the header comments from `systemd.pot` + re-add SPDX before committing. If the only change in a file is the 'POT-Creation-Date' field, then ignore that file.
10. Tag the release: `version=vXXX~rcY && git tag -s "${version}" -m "systemd ${version}"`. Note that this uses a tilde (\~) instead of a hyphen (-) because tildes sort lower in version comparisons according to the [version format specification](https://uapi-group.org/specifications/specs/version_format_specification/), and we want `v255~rc1` to sort lower than `v255`.
11. Do `ninja -C build`
12. Make sure that the version string and package string match: `build/systemctl --version`
13. [FINAL] Close the github milestone and open a new one (https://github.com/systemd/systemd/milestones)
14. "Draft" a new release on github (https://github.com/systemd/systemd/releases/new), mark "This is a pre-release" if appropriate.
15. Check that announcement to systemd-devel, with a copy&paste from NEWS, was sent. This should happen automatically.
16. Update IRC topic (`/msg chanserv TOPIC #systemd Version NNN released | Online resources https://systemd.io/`)
17. [FINAL] Push commits to stable, create an empty -stable branch: `git push systemd-stable --atomic origin/main:main origin/main:refs/heads/${version}-stable`.
18. [FINAL] Build and upload the documentation (on the -stable branch): `ninja -C build doc-sync`
19. [FINAL] Change the default branch to latest release (https://github.com/systemd/systemd-stable/settings/branches).
20. [FINAL] Change the Github Pages branch in the stable repository to the newly created branch (https://github.com/systemd/systemd-stable/settings/pages) and set the 'Custom domain' to 'systemd.io'
21. [FINAL] Update version number in `meson.version` to the devel version of the next release (e.g. from `v256` to `v257~devel`)

View File

@ -1,7 +1,7 @@
# SPDX-License-Identifier: LGPL-2.1-or-later
project('systemd', 'c',
version : '255',
version : files('meson.version'),
license : 'LGPLv2+',
default_options: [
'c_std=gnu11',
@ -18,8 +18,9 @@ libudev_version = '1.7.8'
conf = configuration_data()
conf.set_quoted('PROJECT_URL', 'https://systemd.io/')
conf.set('PROJECT_VERSION', meson.project_version(),
conf.set('PROJECT_VERSION', meson.project_version().split('~')[0],
description : 'Numerical project version (used where a simple number is expected)')
conf.set_quoted('PROJECT_VERSION_FULL', meson.project_version(), description : 'Full project version')
# This is to be used instead of meson.source_root(), as the latter will return
# the wrong result when systemd is being built as a meson subproject
@ -1859,13 +1860,12 @@ version_h = vcs_tag(
output : 'version.h',
command: [project_source_root / 'tools/meson-vcs-tag.sh',
project_source_root,
meson.project_version(),
version_tag,
])
shared_lib_tag = get_option('shared-lib-tag')
if shared_lib_tag == ''
shared_lib_tag = meson.project_version()
shared_lib_tag = meson.project_version().split('~')[0]
endif
#####################################################################
@ -2559,11 +2559,17 @@ foreach exec : public_programs
args : exec.full_path(),
depends: exec)
version = meson.project_version()
if name == 'udevadm'
# For compatibility reasons we can't use the full version in udevadm.
version = version.split('~')[0]
endif
test('check-version-' + name,
check_version,
suite : 'dist',
args : [exec.full_path(),
meson.project_version()],
version],
depends: exec)
endif
endforeach

1
meson.version Normal file
View File

@ -0,0 +1 @@
256~devel

View File

@ -288,7 +288,7 @@ int version(void) {
if (colors_enabled())
b = systemd_features_with_color();
printf("%ssystemd " STRINGIFY(PROJECT_VERSION) "%s (" GIT_VERSION ")\n%s\n",
printf("%ssystemd " PROJECT_VERSION_FULL "%s (" GIT_VERSION ")\n%s\n",
ansi_highlight(), ansi_normal(),
b ?: systemd_features);
return 0;

View File

@ -67,7 +67,7 @@ if meson.is_cross_build() and get_option('sbat-distro') == 'auto'
warning('Auto detection of SBAT information not supported when cross-building, disabling SBAT.')
elif get_option('sbat-distro') != ''
efi_conf.set_quoted('SBAT_PROJECT', meson.project_name())
efi_conf.set_quoted('PROJECT_VERSION', meson.project_version())
efi_conf.set_quoted('PROJECT_VERSION', meson.project_version().split('~')[0])
efi_conf.set('PROJECT_URL', conf.get('PROJECT_URL'))
if get_option('sbat-distro-generation') < 1
error('SBAT Distro Generation must be a positive integer')
@ -385,7 +385,7 @@ foreach efi_elf_binary : efi_elf_binaries
install_tag : 'systemd-boot',
command : [
elf2efi_py,
'--version-major=' + meson.project_version(),
'--version-major=' + meson.project_version().split('~')[0],
'--version-minor=0',
'--efi-major=1',
'--efi-minor=1',

View File

@ -1366,7 +1366,7 @@ static int verb_monitor(int argc, char **argv, void *userdata) {
static int verb_capture(int argc, char **argv, void *userdata) {
_cleanup_free_ char *osname = NULL;
static const char info[] =
"busctl (systemd) " STRINGIFY(PROJECT_VERSION) " (Git " GIT_VERSION ")";
"busctl (systemd) " PROJECT_VERSION_FULL " (Git " GIT_VERSION ")";
int r;
if (isatty(STDOUT_FILENO))

View File

@ -64,7 +64,7 @@ static void manager_dump_header(Manager *m, FILE *f, const char *prefix) {
* stable between versions. We take the liberty to restructure it entirely between versions and
* add/remove fields at will. */
fprintf(f, "%sManager: systemd " STRINGIFY(PROJECT_VERSION) " (" GIT_VERSION ")\n", strempty(prefix));
fprintf(f, "%sManager: systemd " PROJECT_VERSION_FULL " (" GIT_VERSION ")\n", strempty(prefix));
fprintf(f, "%sFeatures: %s\n", strempty(prefix), systemd_features);
for (ManagerTimestamp q = 0; q < _MANAGER_TIMESTAMP_MAX; q++) {

View File

@ -18,7 +18,7 @@
/* for libcryptsetup debug purpose */
_public_ const char *cryptsetup_token_version(void) {
return TOKEN_VERSION_MAJOR "." TOKEN_VERSION_MINOR " systemd-v" STRINGIFY(PROJECT_VERSION) " (" GIT_VERSION ")";
return TOKEN_VERSION_MAJOR "." TOKEN_VERSION_MINOR " systemd-v" PROJECT_VERSION_FULL " (" GIT_VERSION ")";
}
_public_ int cryptsetup_token_open_pin(

View File

@ -18,7 +18,7 @@
/* for libcryptsetup debug purpose */
_public_ const char *cryptsetup_token_version(void) {
return TOKEN_VERSION_MAJOR "." TOKEN_VERSION_MINOR " systemd-v" STRINGIFY(PROJECT_VERSION) " (" GIT_VERSION ")";
return TOKEN_VERSION_MAJOR "." TOKEN_VERSION_MINOR " systemd-v" PROJECT_VERSION_FULL " (" GIT_VERSION ")";
}
_public_ int cryptsetup_token_open_pin(

View File

@ -20,7 +20,7 @@
/* for libcryptsetup debug purpose */
_public_ const char *cryptsetup_token_version(void) {
return TOKEN_VERSION_MAJOR "." TOKEN_VERSION_MINOR " systemd-v" STRINGIFY(PROJECT_VERSION) " (" GIT_VERSION ")";
return TOKEN_VERSION_MAJOR "." TOKEN_VERSION_MINOR " systemd-v" PROJECT_VERSION_FULL " (" GIT_VERSION ")";
}
static int log_debug_open_error(struct crypt_device *cd, int r) {

View File

@ -27,7 +27,7 @@ from shutil import which
from pathlib import Path
from typing import Optional
__version__ = '{{PROJECT_VERSION}} ({{GIT_VERSION}})'
__version__ = '{{PROJECT_VERSION_FULL}} ({{GIT_VERSION}})'
try:
VERBOSE = int(os.environ['KERNEL_INSTALL_VERBOSE']) > 0

View File

@ -8,7 +8,7 @@
TEST(systemd_installation_has_version) {
int r;
FOREACH_STRING(version, "0", "231", STRINGIFY(PROJECT_VERSION), "999") {
FOREACH_STRING(version, "0", "231", PROJECT_VERSION_FULL, "999") {
r = systemd_installation_has_version(saved_argv[1], version);
assert_se(r >= 0);
log_info("%s has systemd >= %s: %s",

View File

@ -1310,7 +1310,7 @@ static int generic_method_get_info(
return varlink_replyb(link, JSON_BUILD_OBJECT(
JSON_BUILD_PAIR_STRING("vendor", "The systemd Project"),
JSON_BUILD_PAIR_STRING("product", product),
JSON_BUILD_PAIR_STRING("version", STRINGIFY(PROJECT_VERSION) " (" GIT_VERSION ")"),
JSON_BUILD_PAIR_STRING("version", PROJECT_VERSION_FULL " (" GIT_VERSION ")"),
JSON_BUILD_PAIR_STRING("url", "https://systemd.io/"),
JSON_BUILD_PAIR_STRV("interfaces", interfaces)));
}

View File

@ -50,7 +50,7 @@ from typing import (Any,
import pefile # type: ignore
__version__ = '{{PROJECT_VERSION}} ({{GIT_VERSION}})'
__version__ = '{{PROJECT_VERSION_FULL}} ({{GIT_VERSION}})'
EFI_ARCH_MAP = {
# host_arch glob : [efi_arch, 32_bit_efi_arch if mixed mode is supported]

View File

@ -4,14 +4,15 @@
set -u
set -o pipefail
dir="${1:?}"
fallback="${2:?}"
version_tag="${3:-}"
dir="${1:-.}"
version_tag="${2:-}"
if [ -n "${version_tag}" ]; then
# If -Dversion_tag= was used, just use that without further changes.
echo "${version_tag}"
else
read -r project_version <"${dir}/meson.version"
# Check that we have either .git/ (a normal clone) or a .git file (a work-tree)
# and that we don't get confused if a tarball is extracted in a higher-level
# git repository.
@ -22,13 +23,18 @@ else
c=''
if [ -e "${dir}/.git" ]; then
c="$(git -C "$dir" describe --abbrev=7 --dirty=^ 2>/dev/null)"
if [ -z "$c" ]; then
if [ -n "$c" ]; then
# git describe uses the most recent tag. However, for development versions (e.g. v256~devel), the
# most recent tag will be v255 as there is no tag for development versions. To deal with this, we
# replace the tag with the project version instead.
c="${project_version}-${c#*-}"
else
# This call might still fail with permission issues
suffix="$(git -C "$dir" describe --always --abbrev=7 --dirty=^ 2>/dev/null)"
[ -n "$suffix" ] && c="${fallback}-${suffix}"
[ -n "$suffix" ] && c="${project_version}-${suffix}"
fi
fi
[ -z "$c" ] && c="${fallback}"
[ -z "$c" ] && c="${project_version}"
# Replace any hyphens with carets which are allowed in versions by pacman whereas hyphens are not. Git
# versions with carets will also sort higher than their non-git version counterpart both in pacman
# versioning and in version comparison spec versioning.