meson: Fix various versions
authorDaan De Meyer <daan.j.demeyer@gmail.com>
Thu, 4 Jul 2024 12:44:21 +0000 (14:44 +0200)
committerLuca Boccassi <luca.boccassi@gmail.com>
Fri, 5 Jul 2024 09:38:42 +0000 (11:38 +0200)
Follow up for 8b3b01c4b7e0fde39b4be354990ee68f5e612c52

We switch to PROJECT_VERSION instead of PROJECT_VERSION_FULL where
we report our version and which is likely being parsed to avoid
breaking compat. If we didn't, the output would change from systemd
255 to systemd 255.1 which could break various tools.

(cherry picked from commit 6a4fcf8cefceba151e11f85e784c8962b6fc383b)

meson.build
src/basic/build.c
src/boot/efi/meson.build
src/kernel-install/60-ukify.install.in
src/ukify/ukify.py

index e42151998b960300a5b8e675f9168f7c327cf43a..fe382736276e00b92caf2ffe8ce8eebe92991db7 100644 (file)
@@ -13,12 +13,19 @@ project('systemd', 'c',
         meson_version : '>= 0.60.0',
        )
 
+project_major_version = meson.project_version().split('.')[0].split('~')[0]
+if meson.project_version().contains('.')
+        project_minor_version = meson.project_version().split('.')[-1].split('~')[0]
+else
+        project_minor_version = '0'
+endif
+
 libsystemd_version = '0.39.0'
 libudev_version = '1.7.9'
 
 conf = configuration_data()
 conf.set_quoted('PROJECT_URL', 'https://systemd.io/')
-conf.set('PROJECT_VERSION', meson.project_version().split('~')[0],
+conf.set('PROJECT_VERSION', project_major_version,
          description : 'Numerical project version (used where a simple number is expected)')
 conf.set_quoted('PROJECT_VERSION_FULL', meson.project_version(), description : 'Full project version')
 
@@ -1993,7 +2000,7 @@ version_h = vcs_tag(
 
 shared_lib_tag = get_option('shared-lib-tag')
 if shared_lib_tag == ''
-        shared_lib_tag = meson.project_version().split('~')[0]
+        shared_lib_tag = project_major_version
 endif
 
 #####################################################################
@@ -2754,17 +2761,11 @@ 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(),
-                             version],
+                             project_major_version],
                      depends: exec)
         endif
 endforeach
index 3ab25f72a7c671705488797fb82b4b8987aa2e05..488ed2071382175ce3d8dbf40ffbed14982613d1 100644 (file)
@@ -287,8 +287,8 @@ int version(void) {
         if (colors_enabled())
                 b = systemd_features_with_color();
 
-        printf("%ssystemd " PROJECT_VERSION_FULL "%s (" GIT_VERSION ")\n%s\n",
-               ansi_highlight(), ansi_normal(),
+        printf("%ssystemd %i%s (" GIT_VERSION ")\n%s\n",
+               ansi_highlight(), PROJECT_VERSION, ansi_normal(),
                b ?: systemd_features);
         return 0;
 }
index aefe3739d2d57b1125de820f03b52c6d99b7d824..a1bdd58c583ba6e6c5025eba0ed70a03252b9564 100644 (file)
@@ -63,7 +63,7 @@ foreach ctype : ['color-normal', 'color-entry', 'color-highlight', 'color-edit']
                 'EFI_' + c[1].strip().underscorify().to_upper()))
 endforeach
 
-efi_conf.set_quoted('PROJECT_VERSION', meson.project_version().split('~')[0])
+efi_conf.set_quoted('PROJECT_VERSION', project_major_version)
 efi_conf.set_quoted('VERSION_TAG', version_tag)
 efi_conf.set('PROJECT_URL', conf.get('PROJECT_URL'))
 
@@ -389,8 +389,8 @@ foreach efi_elf_binary : efi_elf_binaries
                 install_tag : 'systemd-boot',
                 command : [
                         elf2efi_py,
-                        '--version-major=' + meson.project_version().split('.')[0].split('~')[0],
-                        '--version-minor=' + meson.project_version().split('.')[-1].split('~')[0],
+                        '--version-major=' + project_major_version,
+                        '--version-minor=' + project_minor_version,
                         '--efi-major=1',
                         '--efi-minor=1',
                         '--subsystem=10',
index 54a5dafa72e63ff0833ee78e138423b7a7612c1a..076390dd0475e2bc6d75348b3869fca7d03c5fff 100755 (executable)
@@ -27,7 +27,7 @@ from shutil import which
 from pathlib import Path
 from typing import Optional
 
-__version__ = '{{PROJECT_VERSION_FULL}} ({{VERSION_TAG}})'
+__version__ = '{{PROJECT_VERSION}} ({{VERSION_TAG}})'
 
 try:
     VERBOSE = int(os.environ['KERNEL_INSTALL_VERBOSE']) > 0
index f1db9ba57875b52c74f4d0842b85e24cd8f8aeea..75e4286cca5489c6f4e77d44dac3c12f02852bbf 100755 (executable)
@@ -51,7 +51,7 @@ from typing import (Any,
 
 import pefile  # type: ignore
 
-__version__ = '{{PROJECT_VERSION_FULL}} ({{VERSION_TAG}})'
+__version__ = '{{PROJECT_VERSION}} ({{VERSION_TAG}})'
 
 EFI_ARCH_MAP = {
     # host_arch glob : [efi_arch, 32_bit_efi_arch if mixed mode is supported]