daandemeyer / rpms / systemd

Forked from rpms/systemd 2 years ago
Clone
4cad4c
From 0065f2bf838dd0c24ec7be41439b4c0ba650029c Mon Sep 17 00:00:00 2001
4cad4c
From: Jan Synacek <jsynacek@redhat.com>
4cad4c
Date: Wed, 19 Feb 2020 15:36:13 +0100
4cad4c
Subject: [PATCH] meson: allow setting the version string during configuration
4cad4c
4cad4c
Very loosely based on upstream commits e1ca734edd17a90a325d5b566a4ea96e66c206e5
4cad4c
and 681bd2c524ed71ac04045c90884ba8d55eee7b66.
4cad4c
4cad4c
Resolves: #1804252
4cad4c
---
4cad4c
 meson.build          | 15 +++++++++++----
4cad4c
 meson_options.txt    |  3 +++
4cad4c
 src/udev/udev-ctrl.c |  5 ++++-
4cad4c
 3 files changed, 18 insertions(+), 5 deletions(-)
4cad4c
4cad4c
diff --git a/meson.build b/meson.build
4cad4c
index c8ae1e15bd..0ba3f924ea 100644
4cad4c
--- a/meson.build
4cad4c
+++ b/meson.build
4cad4c
@@ -15,17 +15,24 @@ project('systemd', 'c',
4cad4c
 libsystemd_version = '0.23.0'
4cad4c
 libudev_version = '1.6.11'
4cad4c
 
4cad4c
+dist_version = get_option('version-tag')
4cad4c
+if dist_version == ''
4cad4c
+        dist_version = meson.project_version()
4cad4c
+else
4cad4c
+        dist_version = meson.project_version() + ' (' + dist_version + ')'
4cad4c
+endif
4cad4c
+
4cad4c
 # We need the same data in two different formats, ugh!
4cad4c
 # Also, for hysterical reasons, we use different variable
4cad4c
 # names, sometimes. Not all variables are included in every
4cad4c
 # set. Ugh, ugh, ugh!
4cad4c
 conf = configuration_data()
4cad4c
-conf.set_quoted('PACKAGE_STRING',  meson.project_name() + ' ' + meson.project_version())
4cad4c
-conf.set_quoted('PACKAGE_VERSION', meson.project_version())
4cad4c
+conf.set_quoted('PACKAGE_STRING',  meson.project_name() + ' ' + dist_version)
4cad4c
+conf.set_quoted('PACKAGE_VERSION', dist_version)
4cad4c
 
4cad4c
 substs = configuration_data()
4cad4c
 substs.set('PACKAGE_URL',          'https://www.freedesktop.org/wiki/Software/systemd')
4cad4c
-substs.set('PACKAGE_VERSION',      meson.project_version())
4cad4c
+substs.set('PACKAGE_VERSION',      dist_version)
4cad4c
 
4cad4c
 #####################################################################
4cad4c
 
4cad4c
@@ -2871,7 +2878,7 @@ run_target(
4cad4c
 ############################################################
4cad4c
 
4cad4c
 status = [
4cad4c
-        '@0@ @1@'.format(meson.project_name(), meson.project_version()),
4cad4c
+        '@0@ @1@'.format(meson.project_name(), dist_version),
4cad4c
 
4cad4c
         'split /usr:                        @0@'.format(split_usr),
4cad4c
         'split bin-sbin:                    @0@'.format(split_bin),
4cad4c
diff --git a/meson_options.txt b/meson_options.txt
4cad4c
index 563b11f0a2..0996891177 100644
4cad4c
--- a/meson_options.txt
4cad4c
+++ b/meson_options.txt
4cad4c
@@ -1,6 +1,9 @@
4cad4c
 # -*- mode: meson -*-
4cad4c
 # SPDX-License-Identifier: LGPL-2.1+
4cad4c
 
4cad4c
+option('version-tag', type : 'string',
4cad4c
+       description : 'override the version string')
4cad4c
+
4cad4c
 option('split-usr', type : 'combo', choices : ['auto', 'true', 'false'],
4cad4c
        description : '''/bin, /sbin aren't symlinks into /usr''')
4cad4c
 option('split-bin', type : 'combo', choices : ['auto', 'true', 'false'],
4cad4c
diff --git a/src/udev/udev-ctrl.c b/src/udev/udev-ctrl.c
4cad4c
index efe7297f04..5382ce0d26 100644
4cad4c
--- a/src/udev/udev-ctrl.c
4cad4c
+++ b/src/udev/udev-ctrl.c
4cad4c
@@ -239,7 +239,10 @@ static int ctrl_send(struct udev_ctrl *uctrl, enum udev_ctrl_msg_type type, int
4cad4c
         int err = 0;
4cad4c
 
4cad4c
         memzero(&ctrl_msg_wire, sizeof(struct udev_ctrl_msg_wire));
4cad4c
-        strcpy(ctrl_msg_wire.version, "udev-" PACKAGE_VERSION);
4cad4c
+        /* jsynacek: As PACKAGE_VERSION is populated from the spec file with %{version}-%{release},
4cad4c
+         * it might not fit entirely into the version field. */
4cad4c
+        strncpy(ctrl_msg_wire.version, "udev-" PACKAGE_VERSION, 16-5);
4cad4c
+        ctrl_msg_wire.version[15] = '\0';
4cad4c
         ctrl_msg_wire.magic = UDEV_CTRL_MAGIC;
4cad4c
         ctrl_msg_wire.type = type;
4cad4c