richardphibel / rpms / systemd

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