meson: specify project version with the -dev and -rc suffixes

This will create the tarball with names NetworkManager-1.56-rc2.tar.xz
or NetworkManager-1.57.1-dev.tar.xz. This way they will match with the
name of the Git tag, making easier for users, and specially for tools
like Packit, to understand the versioning scheme.

The goal is to make that there is only one public versioning scheme, the
one with -rc and -dev suffixes. Version numbers with micro>=90 for RC
releases is kept only as an internal thing for the C headers. Users of
the API can still use it.

Bump meson version to 0.56 to use str.substring().

(cherry picked from commit e422b1c3d9)
This commit is contained in:
Íñigo Huguet 2025-12-18 10:49:33 +01:00
parent d399ffbaba
commit 1b1612f064
2 changed files with 44 additions and 9 deletions

View file

@ -5,23 +5,48 @@ project(
# NOTE: When incrementing version also add corresponding
# NM_VERSION_x_y_z macros in
# "src/libnm-core-public/nm-version-macros.h.in"
version: '1.55.91',
version: '1.56-rc2',
license: 'GPL2+',
default_options: [
'buildtype=debugoptimized',
'c_std=gnu11',
'warning_level=2' # value "2" will add "-Wall" and "-Wextra" to the compiler flags
],
meson_version: '>= 0.53.0',
meson_version: '>= 0.56.0',
)
nm_name = meson.project_name()
nm_version = meson.project_version()
version_array = nm_version.split('.')
nm_major_version = version_array[0].to_int()
nm_minor_version = version_array[1].to_int()
nm_micro_version = version_array[2].to_int()
version_and_suffix = nm_version.split('-')
version_array = version_and_suffix[0].split('.')
if version_and_suffix.length() == 2
version_suffix = version_and_suffix[1]
else
assert(version_and_suffix.length() == 1)
version_suffix = ''
endif
# In the C API we encode the version in 90+ scheme (1.56-rc1 = 1.55.90, rc2 = .91, etc)
if version_suffix == '' or version_suffix == 'dev'
assert(version_array.length() == 3)
nm_major_version = version_array[0].to_int()
nm_minor_version = version_array[1].to_int()
nm_micro_version = version_array[2].to_int()
elif version_suffix.startswith('rc')
assert(version_array.length() == 2)
nm_major_version = version_array[0].to_int()
nm_minor_version = version_array[1].to_int() - 1
nm_micro_version = version_suffix.substring(2).to_int() + 89
else
error('Invalid suffix: ' + version_suffix)
endif
if nm_minor_version % 2 == 1 and version_suffix == ''
error('Expected a "-dev" or "-rc" suffix')
elif nm_minor_version %2 == 0 and version_suffix != ''
error('Unexpected "' + version_suffix + '" suffix')
endif
nm_id_prefix = 'NM'

View file

@ -688,7 +688,17 @@ class Util:
micro = ver & 0xFF
minor = (ver >> 8) & 0xFF
major = ver >> 16
return "%s.%s.%s" % (major, minor, micro)
# Convert 1.57.1 -> 1.57.1-dev and 1.55.90 -> 1.56-rc1
if micro >= 90:
minor += 1
micro = "-rc" + str(micro - 89)
elif minor % 2 == 1:
micro = f".{micro}-dev"
else:
micro = f".{micro}"
return "%s.%s%s" % (major, minor, micro)
###############################################################################
@ -3264,7 +3274,7 @@ def main():
sys.executable,
__file__,
"--started-with-dbus-session",
*sys.argv[1:]
*sys.argv[1:],
)
except OSError as e:
if e.errno != errno.ENOENT: