$ build/systemctl --version
systemd
239-3555-g6178cbb5b5
+PAM +AUDIT +SELINUX +IMA -APPARMOR +SMACK +SYSVINIT +UTMP +LIBCRYPTSETUP +GCRYPT +GNUTLS +ACL +XZ +LZ4 +SECCOMP +BLKID +ELFUTILS +KMOD -IDN2 +IDN +PCRE2 default-hierarchy=hybrid
$ git tag v240 -m 'v240'
$ ninja -C build
ninja: Entering directory `build'
[76/76] Linking target fuzz-unit-file.
$ build/systemctl --version
systemd 240
+PAM +AUDIT +SELINUX +IMA -APPARMOR +SMACK +SYSVINIT +UTMP +LIBCRYPTSETUP +GCRYPT +GNUTLS +ACL +XZ +LZ4 +SECCOMP +BLKID +ELFUTILS +KMOD -IDN2 +IDN +PCRE2 default-hierarchy=hybrid
This is very useful during development, because a precise version string is
embedded in the build product and displayed during boot, so we don't have to
guess answers for questions like "did I just boot the latest version or the one
from before?".
This change creates an overhead for "noop" builds. On my laptop, 'ninja -C
build' that does nothing goes from 0.1 to 0.5 s. It would be nice to avoid
this, but I think that <1 s is still acceptable.
Fixes #7183.
PACKAGE_VERSION is renamed to GIT_VERSION, to make it obvious that this is the
more dynamically changing version string.
Why save to a file? It would be easy to generate the version tag using
run_command(), but we want to go through a file so that stuff gets rebuilt when
this file changes. If we just defined an variable in meson, ninja wouldn't know
it needs to rebuild things.
# set. Ugh, ugh, ugh!
conf = configuration_data()
conf.set('PROJECT_VERSION', meson.project_version())
-conf.set_quoted('PACKAGE_VERSION', meson.project_version())
substs = configuration_data()
substs.set('PROJECT_URL', 'https://www.freedesktop.org/wiki/Software/systemd')
#####################################################################
+vcs_tagger = [meson.source_root() + '/tools/meson-vcs-tag.sh',
+ '@0@/.git'.format(meson.source_root()),
+ meson.project_version()]
+
sed = find_program('sed')
awk = find_program('awk')
m4 = find_program('m4')
#include "alloc-util.h"
#include "analyze-security.h"
#include "analyze-verify.h"
+#include "build.h"
#include "bus-error.h"
#include "bus-unit-util.h"
#include "bus-util.h"
"<!-- that render these files properly but much slower are ImageMagick, -->\n"
"<!-- gimp, inkscape, etc. To display the files on your system, just -->\n"
"<!-- point your browser to this file. -->\n\n"
- "<!-- This plot was generated by systemd-analyze version %-16.16s -->\n\n", PACKAGE_VERSION);
+ "<!-- This plot was generated by systemd-analyze version %-16.16s -->\n\n", GIT_VERSION);
/* style sheet */
svg("<defs>\n <style type=\"text/css\">\n <![CDATA[\n"
/* SPDX-License-Identifier: LGPL-2.1+ */
#pragma once
+#include "version.h"
+
#if HAVE_PAM
#define _PAM_FEATURE_ "+PAM"
#else
# SPDX-License-Identifier: LGPL-2.1+
+version_h = vcs_tag(
+ command: vcs_tagger,
+ input : 'version.h.in',
+ output : 'version.h')
+
basic_sources = files('''
MurmurHash2.c
MurmurHash2.h
}
int version(void) {
- puts("systemd " PACKAGE_VERSION "\n"
+ puts("systemd " GIT_VERSION "\n"
SYSTEMD_FEATURES);
return 0;
}
--- /dev/null
+#define GIT_VERSION "@VCS_TAG@"
#endif
/* magic string to find in the binary image */
-static const char __attribute__((used)) magic[] = "#### LoaderInfo: systemd-boot " PACKAGE_VERSION " ####";
+static const char __attribute__((used)) magic[] = "#### LoaderInfo: systemd-boot " GIT_VERSION " ####";
static const EFI_GUID global_guid = EFI_GLOBAL_VARIABLE;
uefi_call_wrapper(ST->ConOut->SetAttribute, 2, ST->ConOut, EFI_LIGHTGRAY|EFI_BACKGROUND_BLACK);
uefi_call_wrapper(ST->ConOut->ClearScreen, 1, ST->ConOut);
- Print(L"systemd-boot version: " PACKAGE_VERSION "\n");
+ Print(L"systemd-boot version: " GIT_VERSION "\n");
Print(L"architecture: " EFI_MACHINE_TYPE_NAME "\n");
Print(L"loaded image: %s\n", loaded_image_path);
Print(L"UEFI specification: %d.%02d\n", ST->Hdr.Revision >> 16, ST->Hdr.Revision & 0xffff);
break;
case KEYPRESS(0, 0, 'v'):
- status = PoolPrint(L"systemd-boot " PACKAGE_VERSION " (" EFI_MACHINE_TYPE_NAME "), UEFI Specification %d.%02d, Vendor %s %d.%02d",
+ status = PoolPrint(L"systemd-boot " GIT_VERSION " (" EFI_MACHINE_TYPE_NAME "), UEFI Specification %d.%02d, Vendor %s %d.%02d",
ST->Hdr.Revision >> 16, ST->Hdr.Revision & 0xffff,
ST->FirmwareVendor, ST->FirmwareRevision >> 16, ST->FirmwareRevision & 0xffff);
break;
InitializeLib(image, sys_table);
init_usec = time_usec();
efivar_set_time_usec(L"LoaderTimeInitUSec", init_usec);
- efivar_set(L"LoaderInfo", L"systemd-boot " PACKAGE_VERSION, FALSE);
+ efivar_set(L"LoaderInfo", L"systemd-boot " GIT_VERSION, FALSE);
infostr = PoolPrint(L"%s %d.%02d", ST->FirmwareVendor, ST->FirmwareRevision >> 16, ST->FirmwareRevision & 0xffff);
efivar_set(L"LoaderFirmwareInfo", infostr, FALSE);
if have_gnu_efi
efi_conf = configuration_data()
- efi_conf.set_quoted('PACKAGE_VERSION', meson.project_version())
efi_conf.set_quoted('EFI_MACHINE_TYPE_NAME', EFI_MACHINE_TYPE_NAME)
efi_conf.set10('ENABLE_TPM', get_option('tpm'))
efi_conf.set('SD_TPM_PCR', get_option('tpm-pcrindex'))
'-Wno-missing-field-initializers',
'-isystem', efi_incdir,
'-isystem', join_paths(efi_incdir, gnu_efi_path_arch),
- '-include', efi_config_h]
+ '-include', efi_config_h,
+ '-include', version_h]
if efi_arch == 'x86_64'
compile_args += ['-mno-red-zone',
'-mno-sse',
#include "util.h"
/* magic string to find in the binary image */
-static const char __attribute__((used)) magic[] = "#### LoaderInfo: systemd-stub " PACKAGE_VERSION " ####";
+static const char __attribute__((used)) magic[] = "#### LoaderInfo: systemd-stub " GIT_VERSION " ####";
static const EFI_GUID global_guid = EFI_GLOBAL_VARIABLE;
/* add StubInfo */
if (efivar_get_raw(&global_guid, L"StubInfo", &b, &size) != EFI_SUCCESS)
- efivar_set(L"StubInfo", L"systemd-stub " PACKAGE_VERSION, FALSE);
+ efivar_set(L"StubInfo", L"systemd-stub " GIT_VERSION, FALSE);
if (szs[3] > 0)
graphics_splash((UINT8 *)((UINTN)loaded_image->ImageBase + addrs[3]), szs[3], NULL);
(force ? UNIT_FILE_FORCE : 0);
}
-static BUS_DEFINE_PROPERTY_GET_GLOBAL(property_get_version, "s", PACKAGE_VERSION);
+static BUS_DEFINE_PROPERTY_GET_GLOBAL(property_get_version, "s", GIT_VERSION);
static BUS_DEFINE_PROPERTY_GET_GLOBAL(property_get_features, "s", SYSTEMD_FEATURES);
static BUS_DEFINE_PROPERTY_GET_GLOBAL(property_get_architecture, "s", architecture_to_string(uname_architecture()));
static BUS_DEFINE_PROPERTY_GET_GLOBAL(property_get_log_target, "s", log_target_to_string(log_get_target()));
if (arg_system) {
int v;
- log_info("systemd " PACKAGE_VERSION " running in %ssystem mode. (" SYSTEMD_FEATURES ")",
+ log_info("systemd " GIT_VERSION " running in %ssystem mode. (" SYSTEMD_FEATURES ")",
arg_action == ACTION_TEST ? "test " : "" );
v = detect_virtualization();
_cleanup_free_ char *t;
t = uid_to_name(getuid());
- log_debug("systemd " PACKAGE_VERSION " running in %suser mode for user " UID_FMT "/%s. (" SYSTEMD_FEATURES ")",
+ log_debug("systemd " GIT_VERSION " running in %suser mode for user " UID_FMT "/%s. (" SYSTEMD_FEATURES ")",
arg_action == ACTION_TEST ? " test" : "", getuid(), strna(t));
}
/* SPDX-License-Identifier: LGPL-2.1+ */
#include "alloc-util.h"
+#include "build.h"
#include "curl-util.h"
#include "fd-util.h"
#include "locale-util.h"
if (curl_easy_setopt(c, CURLOPT_PRIVATE, userdata) != CURLE_OK)
return -EIO;
- useragent = strjoina(program_invocation_short_name, "/" PACKAGE_VERSION);
+ useragent = strjoina(program_invocation_short_name, "/" GIT_VERSION);
if (curl_easy_setopt(c, CURLOPT_USERAGENT, useragent) != CURLE_OK)
return -EIO;
#include "sd-daemon.h"
#include "alloc-util.h"
+#include "build.h"
#include "conf-parser.h"
#include "daemon-util.h"
#include "def.h"
easy_setopt(curl, CURLOPT_VERBOSE, 1L, LOG_WARNING, );
easy_setopt(curl, CURLOPT_USERAGENT,
- "systemd-journal-upload " PACKAGE_VERSION,
+ "systemd-journal-upload " GIT_VERSION,
LOG_WARNING, );
if (arg_key || startswith(u->url, "https://")) {
#include <unistd.h>
#include "alloc-util.h"
+#include "build.h"
#include "fd-util.h"
#include "libudev-list-internal.h"
#include "libudev-util.h"
return EXIT_SUCCESS;
case 'V':
- printf("%s\n", PACKAGE_VERSION);
+ printf("%s\n", GIT_VERSION);
return EXIT_SUCCESS;
case 'm':
#include <sys/signalfd.h>
#include <unistd.h>
+#include "build.h"
#include "device-private.h"
#include "fs-util.h"
#include "log.h"
return 0;
}
- log_debug("version %s", PACKAGE_VERSION);
+ log_debug("version %s", GIT_VERSION);
mac_selinux_init();
action = argv[1];
#include <unistd.h>
#include "alloc-util.h"
+#include "build.h"
#include "fd-util.h"
#include "libudev-util.h"
#include "scsi_id.h"
break;
case 'V':
- printf("%s\n", PACKAGE_VERSION);
+ printf("%s\n", GIT_VERSION);
exit(EXIT_SUCCESS);
case 'x':
#include <stdio.h>
+#include "build.h"
+
int info_main(int argc, char *argv[], void *userdata);
int trigger_main(int argc, char *argv[], void *userdata);
int settle_main(int argc, char *argv[], void *userdata);
int builtin_main(int argc, char *argv[], void *userdata);
static inline int print_version(void) {
- puts(PACKAGE_VERSION);
+ puts(GIT_VERSION);
return 0;
}
#include "sd-event.h"
#include "alloc-util.h"
+#include "build.h"
#include "cgroup-util.h"
#include "cpu-set-util.h"
#include "dev-setup.h"
case 'h':
return help();
case 'V':
- printf("%s\n", PACKAGE_VERSION);
+ printf("%s\n", GIT_VERSION);
return 0;
case '?':
return -EINVAL;
if (arg_daemonize) {
pid_t pid;
- log_info("starting version " PACKAGE_VERSION);
+ log_info("starting version " GIT_VERSION);
/* connect /dev/null to stdin, stdout, stderr */
if (log_get_max_level() < LOG_DEBUG) {
--- /dev/null
+#!/bin/sh
+
+set -eu
+set -o pipefail
+
+gitdir="$1"
+fallback="$2"
+
+git --git-dir="$gitdir" describe --abbrev=7 --dirty=+ 2>/dev/null | sed 's/^v//' || echo "$fallback"