meson: Fix various versions

Follow up for 8b3b01c4b7

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.
This commit is contained in:
Daan De Meyer 2024-07-04 14:44:21 +02:00
parent a79b6dc070
commit 6a4fcf8cef
5 changed files with 17 additions and 16 deletions

View 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')
@ -1996,7 +2003,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
#####################################################################
@ -2749,17 +2756,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

View 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;
}

View 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'))
@ -391,8 +391,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',

View file

@ -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

View file

@ -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]