1
0
mirror of https://github.com/systemd/systemd.git synced 2024-10-27 18:55:40 +03:00

meson: Bring back use of vcs_tag

The use of vcs_tag was dropped in #28567, which results in builds having
stale version information once new commit are made.

This also fixes a case where CI builds would have no version information
because they are checked out without any tags for git-describe to use.

Additionally, use `--git-dir` now, as that particular issues seems to
have been fixed by now.
This commit is contained in:
Jan Janssen 2023-08-25 13:07:55 +02:00 committed by Yu Watanabe
parent 82007efa44
commit c78b611e48
3 changed files with 28 additions and 23 deletions

View File

@ -1808,29 +1808,31 @@ xml_helper_py = find_program('tools/xml_helper.py')
############################################################ ############################################################
version_tag = get_option('version-tag') version_tag = get_option('version-tag')
if version_tag == '' # Check that we have either .git/ (a normal clone) or a .git file (a work-tree) and that we don't
# 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.
# get confused if a tarball is extracted in a higher-level git repository. if version_tag == '' and git.found() and fs.exists(project_source_root / '.git')
if git.found() and fs.exists(project_source_root / '.git') version_h = vcs_tag(
# Apparently git describe has a bug where it always considers the work-tree dirty when input : 'src/version/version.h.in',
# invoked with --git-dir (even though 'git status' is happy). Work around this issue by output : 'version.h',
# cd-ing to the source directory. # If the working tree has no tags (CI builds), the first git-describe will fail
version_tag = run_command( # and we fall back to project_version-commitid instead.
sh, '-c', # TODO: Use 'sh' variable with meson >= 0.63.0
'cd "$MESON_SOURCE_ROOT"; git describe --abbrev=7 --dirty=^ 2>/dev/null | sed "s/^v//; s/-rc/~rc/"', command: ['sh',
check : true, '-euc',
).stdout().strip() '''git -C "$1" describe --abbrev=7 --dirty=^ 2>/dev/null ||
else echo "$2-$(git -C "$1" describe --always --abbrev=7)" |
version_tag = meson.project_version() sed 's/^v//; s/-rc/~rc/' ''',
endif '_',
project_source_root,
meson.project_version()])
else
vcs_data = configuration_data()
vcs_data.set('VCS_TAG', version_tag == '' ? meson.project_version() : version_tag)
version_h = configure_file(configuration : vcs_data,
input : 'src/version/version.h.in',
output : 'version.h')
endif endif
vcs_data = configuration_data()
vcs_data.set('VCS_TAG', version_tag)
version_h = configure_file(configuration : vcs_data,
input : 'src/version/version.h.in',
output : 'version.h')
versiondep = declare_dependency( versiondep = declare_dependency(
sources : version_h, sources : version_h,
include_directories : include_directories('.'), include_directories : include_directories('.'),

View File

@ -92,9 +92,11 @@ elif get_option('sbat-distro') != ''
pkgver = get_option('sbat-distro-version') pkgver = get_option('sbat-distro-version')
if pkgver == '' if pkgver == ''
pkgver = version_tag # This is determined during build, not configuration, so we can't display it yet.
efi_conf.set('SBAT_DISTRO_VERSION', 'GIT_VERSION')
else
efi_conf.set_quoted('SBAT_DISTRO_VERSION', pkgver)
endif endif
efi_conf.set_quoted('SBAT_DISTRO_VERSION', pkgver)
endif endif
summary({'UEFI architectures' : efi_arch + (efi_arch_alt == '' ? '' : ', ' + efi_arch_alt)}, summary({'UEFI architectures' : efi_arch + (efi_arch_alt == '' ? '' : ', ' + efi_arch_alt)},

View File

@ -1,6 +1,7 @@
/* SPDX-License-Identifier: LGPL-2.1-or-later */ /* SPDX-License-Identifier: LGPL-2.1-or-later */
#ifdef SBAT_DISTRO #ifdef SBAT_DISTRO
# include "version.h"
# define SBAT_SECTION_TEXT \ # define SBAT_SECTION_TEXT \
"sbat,1,SBAT Version,sbat,1,https://github.com/rhboot/shim/blob/main/SBAT.md\n" \ "sbat,1,SBAT Version,sbat,1,https://github.com/rhboot/shim/blob/main/SBAT.md\n" \
SBAT_PROJECT ",1,The systemd Developers," SBAT_PROJECT "," PROJECT_VERSION "," PROJECT_URL "\n" \ SBAT_PROJECT ",1,The systemd Developers," SBAT_PROJECT "," PROJECT_VERSION "," PROJECT_URL "\n" \