net-misc/netplan: add 0001-buildsystem-meson-fixes.patch

This commit is contained in:
Alexander Miroshnichenko 2022-09-28 15:03:48 +03:00
parent 2f9dd2a49a
commit c442887cb7
Signed by: alex
GPG Key ID: E93720C6C73A77F4
1 changed files with 139 additions and 0 deletions

View File

@ -0,0 +1,139 @@
From 89948ed72b80c2671981ce6bb995dccbb5e389b6 Mon Sep 17 00:00:00 2001
From: =?UTF-8?q?Lukas=20M=C3=A4rdian?= <slyon@ubuntu.com>
Date: Wed, 24 Aug 2022 12:34:51 +0200
Subject: [PATCH] buildsystem: meson fixes
Content-Type: text/plain; charset="utf-8"
Content-Transfer-Encoding: 8bit
- install all files
- POSIX shell compatibility in generators
- use custom_targets for generators
- fix dbus install directory
Signed-off-by: Alexander Miroshnichenko <alex@millerson.name>
---
dbus/meson.build | 12 +++++++++++-
features_h_generator.sh | 6 ++++--
features_py_generator.sh | 6 ++++--
meson.build | 5 -----
netplan/meson.build | 15 +++++++++++++--
5 files changed, 32 insertions(+), 12 deletions(-)
diff --git a/dbus/meson.build b/dbus/meson.build
index 68a6ce39208d..fc34e2c2cbf7 100644
--- a/dbus/meson.build
+++ b/dbus/meson.build
@@ -1,6 +1,16 @@
+features_h = custom_target(
+ build_always_stale: true,
+ output: '_features.h',
+ input: join_paths(meson.project_source_root(), 'features_h_generator.sh'),
+ command: ['sh', '-c', '@INPUT@'],
+ install: false,
+ capture: true,
+)
+
executable(
'netplan-dbus',
'../src/dbus.c',
+ features_h,
include_directories: inc,
link_with: libnetplan,
dependencies: [libsystemd, glib, gio, yaml, uuid],
@@ -9,7 +19,7 @@ executable(
install_data(
'io.netplan.Netplan.conf',
- install_dir: join_paths(get_option('datadir'), 'dbus-1', 'systemd.d'))
+ install_dir: join_paths(get_option('datadir'), 'dbus-1', 'system.d'))
conf_data = configuration_data()
conf_data.set('ROOTLIBEXECDIR', join_paths(get_option('prefix'), get_option('libexecdir')))
diff --git a/features_h_generator.sh b/features_h_generator.sh
index ed9c3cc78cab..d38771515a2d 100755
--- a/features_h_generator.sh
+++ b/features_h_generator.sh
@@ -1,6 +1,8 @@
#!/bin/sh
-OUTPUT=src/_features.h
-INPUT=src/[^_]*.[hc]
+BASE=$(dirname $0)
+OUTPUT=$BASE/src/_features.h
+INPUT=$BASE/src/[!_]*.[hc]
printf "#include <stddef.h>\nstatic const char *feature_flags[] __attribute__((__unused__)) = {\n" > $OUTPUT
awk 'match ($0, /netplan-feature:.*/ ) { $0=substr($0, RSTART, RLENGTH); print "\""$2"\"," }' $INPUT >> $OUTPUT
echo "NULL, };" >> $OUTPUT
+cat $OUTPUT
diff --git a/features_py_generator.sh b/features_py_generator.sh
index ecb42af47e75..bbbe3a4e3e30 100755
--- a/features_py_generator.sh
+++ b/features_py_generator.sh
@@ -1,7 +1,9 @@
#!/bin/sh
-OUTPUT=netplan/_features.py
-INPUT=src/[^_]*.[hc]
+BASE=$(dirname $0)
+OUTPUT=$BASE/netplan/_features.py
+INPUT=$BASE/src/[!_]*.[hc]
echo "# Generated file" > $OUTPUT
echo "NETPLAN_FEATURE_FLAGS = [" >> $OUTPUT
awk 'match ($0, /netplan-feature:.*/ ) { $0=substr($0, RSTART, RLENGTH); print " \""$2"\"," }' $INPUT >> $OUTPUT
echo "]" >> $OUTPUT
+cat $OUTPUT
diff --git a/meson.build b/meson.build
index 3ab07765b38e..7f48cb4f244a 100644
--- a/meson.build
+++ b/meson.build
@@ -32,11 +32,6 @@ add_project_arguments(
'-D_XOPEN_SOURCE=700',
language: 'c')
-message('Generating the _features.[py|h] code')
-#XXX: this is ugly as it produces artifacts in the source directory
-run_command('features_h_generator.sh', check: true)
-run_command('features_py_generator.sh', check: true)
-
inc = include_directories('include')
subdir('include')
subdir('src')
diff --git a/netplan/meson.build b/netplan/meson.build
index 1313cb40ebad..07a13e2cc484 100644
--- a/netplan/meson.build
+++ b/netplan/meson.build
@@ -4,10 +4,21 @@ install_symlink(
pointing_to: '../share/netplan/netplan.script',
install_dir: get_option('sbindir'))
+netplan_module = join_paths(get_option('datadir'), meson.project_name(), 'netplan')
+features_py = custom_target(
+ build_always_stale: true,
+ output: '_features.py',
+ input: join_paths(meson.project_source_root(), 'features_py_generator.sh'),
+ command: ['sh', '-c', '@INPUT@'],
+ install: true,
+ install_dir: netplan_module,
+ capture: true,
+)
+
netplan_sources = files(
'__init__.py',
- '_features.py',
'configmanager.py',
+ 'libnetplan.py',
'terminal.py')
cli_sources = files(
@@ -26,9 +37,9 @@ commands_sources = files(
'cli/commands/ip.py',
'cli/commands/migrate.py',
'cli/commands/set.py',
+ 'cli/commands/sriov_rebind.py',
'cli/commands/try_command.py')
-netplan_module = join_paths(get_option('datadir'), meson.project_name(), 'netplan')
install_data(netplan_sources, install_dir: netplan_module)
install_data(cli_sources, install_dir: join_paths(netplan_module, 'cli'))
install_data(commands_sources, install_dir: join_paths(netplan_module, 'cli', 'commands'))
--
2.26.2