diff mbox series

[meta-oe] netplan: upgrade 0.106 -> 1.0

Message ID 20240306125406.1381827-1-yi.zhao@windriver.com
State Accepted
Headers show
Series [meta-oe] netplan: upgrade 0.106 -> 1.0 | expand

Commit Message

Yi Zhao March 6, 2024, 12:54 p.m. UTC
Release Notes:
https://github.com/canonical/netplan/releases/tag/1.0

* Switch to meson build
* Add systemd to REQUIRED_DISTRO_FEATURES as systemd dependency can not
  be removed.
* Add a patch to fix build with clang.

Signed-off-by: Yi Zhao <yi.zhao@windriver.com>
---
 .../0001-Makefile-do-not-use-Werror.patch     | 26 -------
 ...-t-fail-if-GLOB_BRACE-is-not-defined.patch | 12 ++--
 ...-drop-unnecessary-build-dependencies.patch | 58 ++++++++++++++++
 ...ine-scope-specific-to-case-statement.patch | 47 +++++++++++++
 .../0002-meson.build-do-not-use-Werror.patch  | 29 ++++++++
 .../netplan/netplan_0.106.bb                  | 67 -------------------
 .../netplan/netplan_1.0.bb                    | 47 +++++++++++++
 7 files changed, 187 insertions(+), 99 deletions(-)
 delete mode 100644 meta-oe/dynamic-layers/meta-python/recipes-connectivity/netplan/netplan/0001-Makefile-do-not-use-Werror.patch
 create mode 100644 meta-oe/dynamic-layers/meta-python/recipes-connectivity/netplan/netplan/0001-meson.build-drop-unnecessary-build-dependencies.patch
 create mode 100644 meta-oe/dynamic-layers/meta-python/recipes-connectivity/netplan/netplan/0001-networkd.c-define-scope-specific-to-case-statement.patch
 create mode 100644 meta-oe/dynamic-layers/meta-python/recipes-connectivity/netplan/netplan/0002-meson.build-do-not-use-Werror.patch
 delete mode 100644 meta-oe/dynamic-layers/meta-python/recipes-connectivity/netplan/netplan_0.106.bb
 create mode 100644 meta-oe/dynamic-layers/meta-python/recipes-connectivity/netplan/netplan_1.0.bb
diff mbox series

Patch

diff --git a/meta-oe/dynamic-layers/meta-python/recipes-connectivity/netplan/netplan/0001-Makefile-do-not-use-Werror.patch b/meta-oe/dynamic-layers/meta-python/recipes-connectivity/netplan/netplan/0001-Makefile-do-not-use-Werror.patch
deleted file mode 100644
index b8c48d540..000000000
--- a/meta-oe/dynamic-layers/meta-python/recipes-connectivity/netplan/netplan/0001-Makefile-do-not-use-Werror.patch
+++ /dev/null
@@ -1,26 +0,0 @@ 
-From a06c77557ed951249d5b344441ad6ec57410e63f Mon Sep 17 00:00:00 2001
-From: Alexander Kanavin <alex@linutronix.de>
-Date: Sun, 3 Oct 2021 21:52:16 +0200
-Subject: [PATCH] Makefile: do not use -Werror
-
-Upstream-Status: Inappropriate [oe-core specific]
-Signed-off-by: Alexander Kanavin <alex@linutronix.de>
----
- Makefile | 1 -
- 1 file changed, 1 deletion(-)
-
-diff --git a/Makefile b/Makefile
-index 97973ce..78273ff 100644
---- a/Makefile
-+++ b/Makefile
-@@ -8,7 +8,6 @@ BUILDFLAGS = \
- 	-DSBINDIR=\"$(SBINDIR)\" \
- 	-I${CURDIR}/include \
- 	-Wall \
--	-Werror \
- 	$(NULL)
- 
- TESTFLAGS =	\
--- 
-2.34.1
-
diff --git a/meta-oe/dynamic-layers/meta-python/recipes-connectivity/netplan/netplan/0001-don-t-fail-if-GLOB_BRACE-is-not-defined.patch b/meta-oe/dynamic-layers/meta-python/recipes-connectivity/netplan/netplan/0001-don-t-fail-if-GLOB_BRACE-is-not-defined.patch
index 0bd7f80c2..cabceae84 100644
--- a/meta-oe/dynamic-layers/meta-python/recipes-connectivity/netplan/netplan/0001-don-t-fail-if-GLOB_BRACE-is-not-defined.patch
+++ b/meta-oe/dynamic-layers/meta-python/recipes-connectivity/netplan/netplan/0001-don-t-fail-if-GLOB_BRACE-is-not-defined.patch
@@ -1,20 +1,20 @@ 
-From e0df1f07d1707d5daf0358cc60b30f06121f7e60 Mon Sep 17 00:00:00 2001
+From 0ea11f520a8b4453e60eaf0679b9feb757024422 Mon Sep 17 00:00:00 2001
 From: Zang Ruochen <zangrc.fnst@cn.fujitsu.com>
 Date: Fri, 25 Dec 2020 11:41:43 +0900
 Subject: [PATCH] don't fail if GLOB_BRACE is not defined
 
-Signed-off-by: Zang Ruochen <zangrc.fnst@cn.fujitsu.com>
----
 Upstream-Status: Pending
 
+Signed-off-by: Zang Ruochen <zangrc.fnst@cn.fujitsu.com>
+---
  src/util.c | 6 ++++++
  1 file changed, 6 insertions(+)
 
 diff --git a/src/util.c b/src/util.c
-index 841ec12..59595da 100644
+index 36eb896a..ee13ec44 100644
 --- a/src/util.c
 +++ b/src/util.c
-@@ -32,6 +32,12 @@
+@@ -35,6 +35,12 @@
  #include "names.h"
  #include "yaml-helpers.h"
  
@@ -24,7 +24,7 @@  index 841ec12..59595da 100644
 +#define GLOB_BRACE 0
 +#endif
 +
- NETPLAN_ABI GHashTable*
+ GHashTable*
  wifi_frequency_24;
  
 -- 
diff --git a/meta-oe/dynamic-layers/meta-python/recipes-connectivity/netplan/netplan/0001-meson.build-drop-unnecessary-build-dependencies.patch b/meta-oe/dynamic-layers/meta-python/recipes-connectivity/netplan/netplan/0001-meson.build-drop-unnecessary-build-dependencies.patch
new file mode 100644
index 000000000..4f385e917
--- /dev/null
+++ b/meta-oe/dynamic-layers/meta-python/recipes-connectivity/netplan/netplan/0001-meson.build-drop-unnecessary-build-dependencies.patch
@@ -0,0 +1,58 @@ 
+From d3aa30f5cd7ba375e006a755752acbcfcd619452 Mon Sep 17 00:00:00 2001
+From: Yi Zhao <yi.zhao@windriver.com>
+Date: Wed, 6 Mar 2024 19:27:15 +0800
+Subject: [PATCH] meson.build: drop unnecessary build dependencies
+
+The pytest and pycoverage are required by meson test but not for
+building. Mark them as 'required: false' to get rid of unnecessary
+build dependencies.
+
+Upstream-Status: Inappropriate [oe specific]
+
+Signed-off-by: Yi Zhao <yi.zhao@windriver.com>
+---
+ meson.build | 8 ++++++--
+ 1 file changed, 6 insertions(+), 2 deletions(-)
+
+diff --git a/meson.build b/meson.build
+index 9556836a..30f33fe2 100644
+--- a/meson.build
++++ b/meson.build
+@@ -25,8 +25,8 @@ bash_completions_dir = completions.get_variable(pkgconfig: 'completionsdir', def
+ # Order: Fedora/Mageia/openSUSE || Debian/Ubuntu
+ pyflakes = find_program('pyflakes-3', 'pyflakes3', required: false)
+ pycodestyle = find_program('pycodestyle-3', 'pycodestyle', 'pep8', required: false)
+-pytest = find_program('pytest-3', 'pytest3')  # also requires the pytest-cov plugin
+-pycoverage = find_program('coverage-3', 'python3-coverage')
++pytest = find_program('pytest-3', 'pytest3', required: false)  # also requires the pytest-cov plugin
++pycoverage = find_program('coverage-3', 'python3-coverage', required: false)
+ pandoc = find_program('pandoc', required: false)
+ find = find_program('find')
+ 
+@@ -75,6 +75,7 @@ if get_option('unit_testing')
+ endif
+ 
+ #FIXME: exclude doc/env/
++if pyflakes.found() and pycodestyle.found()
+ test('linting',
+      pyflakes,
+      timeout: 100,
+@@ -91,7 +92,9 @@ test('legacy-tests',
+      find_program('tests/cli_legacy.py'),
+      timeout: 600,
+      env: test_env)
++endif
+ #TODO: split out dbus tests into own test() instance, to run in parallel
++if pycoverage.found()
+ test('unit-tests',
+      pycoverage,
+      args: ['run', '-a', '-m', 'pytest', '-s', '-v', '--cov-append', meson.current_source_dir()],
+@@ -143,4 +146,5 @@ if get_option('b_coverage')
+          priority: -99, # run last
+          is_parallel: false)
+ endif
++endif
+ 
+-- 
+2.25.1
+
diff --git a/meta-oe/dynamic-layers/meta-python/recipes-connectivity/netplan/netplan/0001-networkd.c-define-scope-specific-to-case-statement.patch b/meta-oe/dynamic-layers/meta-python/recipes-connectivity/netplan/netplan/0001-networkd.c-define-scope-specific-to-case-statement.patch
new file mode 100644
index 000000000..9f01108a2
--- /dev/null
+++ b/meta-oe/dynamic-layers/meta-python/recipes-connectivity/netplan/netplan/0001-networkd.c-define-scope-specific-to-case-statement.patch
@@ -0,0 +1,47 @@ 
+From 6e3dd61bf90a7ca8c36c5b95943cbff7c1ad3c2d Mon Sep 17 00:00:00 2001
+From: Yi Zhao <yi.zhao@windriver.com>
+Date: Wed, 6 Mar 2024 16:12:31 +0800
+Subject: [PATCH] networkd.c: define scope specific to case statement
+
+Per [1], define a scope specific to case statement to fix build with
+clang.
+
+Fixes:
+../git/src/networkd.c:544:13: error: expected expression
+  544 |             gchar* first = g_strcmp0(def->id, def->veth_peer_link->id) < 0 ? def->id : def->veth_peer_link->id;
+      |             ^
+../git/src/networkd.c:545:17: error: use of undeclared identifier 'first'
+  545 |             if (first != def->id) {
+      |                 ^
+
+[1] https://stackoverflow.com/questions/92396/why-cant-variables-be-declared-in-a-switch-statement
+
+Upstream-Status: Pending
+
+Signed-off-by: Yi Zhao <yi.zhao@windriver.com>
+---
+ src/networkd.c | 2 ++
+ 1 file changed, 2 insertions(+)
+
+diff --git a/src/networkd.c b/src/networkd.c
+index 25121c48..5eb9c0fe 100644
+--- a/src/networkd.c
++++ b/src/networkd.c
+@@ -541,12 +541,14 @@ write_netdev_file(const NetplanNetDefinition* def, const char* rootdir, const ch
+              * and, if the selected name is the name of the netdef being written, we generate
+              * the .netdev file. Otherwise we skip the netdef.
+              */
++        {
+             gchar* first = g_strcmp0(def->id, def->veth_peer_link->id) < 0 ? def->id : def->veth_peer_link->id;
+             if (first != def->id) {
+                 g_string_free(s, TRUE);
+                 return;
+             }
+             g_string_append_printf(s, "Kind=veth\n\n[Peer]\nName=%s\n", def->veth_peer_link->id);
++        }
+             break;
+ 
+         case NETPLAN_DEF_TYPE_TUNNEL:
+-- 
+2.25.1
+
diff --git a/meta-oe/dynamic-layers/meta-python/recipes-connectivity/netplan/netplan/0002-meson.build-do-not-use-Werror.patch b/meta-oe/dynamic-layers/meta-python/recipes-connectivity/netplan/netplan/0002-meson.build-do-not-use-Werror.patch
new file mode 100644
index 000000000..663a80ecd
--- /dev/null
+++ b/meta-oe/dynamic-layers/meta-python/recipes-connectivity/netplan/netplan/0002-meson.build-do-not-use-Werror.patch
@@ -0,0 +1,29 @@ 
+From 668ee79f39614ad758edd44c42b8b0eff57877cf Mon Sep 17 00:00:00 2001
+From: Alexander Kanavin <alex@linutronix.de>
+Date: Sun, 3 Oct 2021 21:52:16 +0200
+Subject: [PATCH] meson.build: do not use -Werror
+
+Upstream-Status: Inappropriate [oe specific]
+
+Signed-off-by: Alexander Kanavin <alex@linutronix.de>
+Signed-off-by: Yi Zhao <yi.zhao@windriver.com>
+---
+ meson.build | 2 +-
+ 1 file changed, 1 insertion(+), 1 deletion(-)
+
+diff --git a/meson.build b/meson.build
+index 30f33fe2..0b214795 100644
+--- a/meson.build
++++ b/meson.build
+@@ -4,7 +4,7 @@ project('netplan', 'c',
+         default_options: [
+             'c_std=c99',
+             'warning_level=2',
+-            'werror=true',
++            'werror=false',
+         ],
+         meson_version: '>= 0.61.0',
+ )
+-- 
+2.25.1
+
diff --git a/meta-oe/dynamic-layers/meta-python/recipes-connectivity/netplan/netplan_0.106.bb b/meta-oe/dynamic-layers/meta-python/recipes-connectivity/netplan/netplan_0.106.bb
deleted file mode 100644
index 8c1eaa550..000000000
--- a/meta-oe/dynamic-layers/meta-python/recipes-connectivity/netplan/netplan_0.106.bb
+++ /dev/null
@@ -1,67 +0,0 @@ 
-SUMMARY = "The network configuration abstraction renderer"
-DESCRIPTION = "Netplan is a utility for easily configuring networking on a \
-linux system. You simply create a YAML description of the required network \
-interfaces and what each should be configured to do. From this description \
-Netplan will generate all the necessary configuration for your chosen renderer \
-tool."
-HOMEPAGE = "https://netplan.io"
-SECTION = "net/misc"
-
-LICENSE = "GPL-3.0-only"
-LIC_FILES_CHKSUM = "file://COPYING;md5=d32239bcb673463ab874e80d47fae504"
-
-S = "${WORKDIR}/git"
-SRCREV = "15ce044d1df27b5057556d84d0d14beef8dd4e4d"
-PV = "0.106"
-
-SRC_URI = "git://github.com/CanonicalLtd/netplan.git;branch=main;protocol=https \
-           file://0001-Makefile-do-not-use-Werror.patch \
-           "
-
-SRC_URI:append:libc-musl = " file://0001-don-t-fail-if-GLOB_BRACE-is-not-defined.patch"
-
-DEPENDS = "glib-2.0 libyaml ${@bb.utils.filter('DISTRO_FEATURES', 'systemd', d)}"
-
-PACKAGECONFIG ?= ""
-
-PACKAGECONFIG[tests] = ",,,python3-nose python3-coverage python3-netifaces python3-pycodestyle python3-pyflakes python3-pyyaml"
-
-RDEPENDS:${PN} = "python3 python3-core python3-netifaces python3-pyyaml util-linux-libuuid libnetplan python3-dbus python3-rich"
-
-inherit pkgconfig systemd
-
-TARGET_CC_ARCH += "${LDFLAGS}"
-
-EXTRA_OEMAKE = "generate netplan/_features.py"
-EXTRA_OEMAKE =+ "${@bb.utils.contains('DISTRO_FEATURES','systemd','netplan-dbus dbus/io.netplan.Netplan.service','',d)}"
-
-do_install() {
-	install -d ${D}${sbindir} ${D}${libdir} ${D}${base_libdir}/netplan ${D}${datadir}/netplan/netplan/cli/commands ${D}${sysconfdir}/netplan
-	install -m 755 ${S}/generate ${D}${base_libdir}/netplan/
-	install -m 644 ${S}/netplan/*.py ${D}${datadir}/netplan/netplan
-	install -m 644 ${S}/netplan/cli/*.py ${D}${datadir}/netplan/netplan/cli
-	install -m 644 ${S}/netplan/cli/commands/*.py ${D}${datadir}/netplan/netplan/cli/commands
-	install -m 755 ${S}/src/netplan.script ${D}${datadir}/netplan/
-	ln -srf ${D}${datadir}/netplan/netplan.script ${D}${sbindir}/netplan
-	sed -i -e "s#/lib/netplan/generate#${base_libdir}/netplan/generate#" ${D}${datadir}/netplan/netplan/cli/utils.py
-
-	install -d ${D}/${systemd_unitdir}/system ${D}${systemd_unitdir}/system-generators
-	ln -srf ${D}/${base_libdir}/netplan/generate ${D}${systemd_unitdir}/system-generators
-
-	if ${@bb.utils.contains('DISTRO_FEATURES','systemd','true','false',d)}; then
-		install -d ${D}${datadir}/dbus-1/system.d ${D}${datadir}/dbus-1/system-services
-		install -m 755 ${S}/netplan-dbus ${D}${base_libdir}/netplan
-		install -m 644 ${S}/dbus/io.netplan.Netplan.conf ${D}${datadir}/dbus-1/system.d
-		install -m 644 ${S}/dbus/io.netplan.Netplan.service ${D}${datadir}/dbus-1/system-services
-		sed -i -e "s#^Exec=/lib/#Exec=${base_libdir}/#" ${D}${datadir}/dbus-1/system-services/io.netplan.Netplan.service
-	fi
-
-	install -m 755 ${S}/libnetplan.so.0.0 ${D}${libdir}
-        ln -rfs ${D}${libdir}/libnetplan.so.0.0 ${D}${libdir}/libnetplan.so
-}
-
-PACKAGES += "${PN}-dbus libnetplan"
-
-FILES:libnetplan = "${libdir}/libnetplan.so.0.0"
-FILES:${PN} = "${sbindir} ${base_libdir}/netplan/generate ${datadir}/netplan ${sysconfdir}/netplan ${systemd_unitdir}"
-FILES:${PN}-dbus = "${base_libdir}/netplan/netplan-dbus ${datadir}/dbus-1"
diff --git a/meta-oe/dynamic-layers/meta-python/recipes-connectivity/netplan/netplan_1.0.bb b/meta-oe/dynamic-layers/meta-python/recipes-connectivity/netplan/netplan_1.0.bb
new file mode 100644
index 000000000..71efd2cc3
--- /dev/null
+++ b/meta-oe/dynamic-layers/meta-python/recipes-connectivity/netplan/netplan_1.0.bb
@@ -0,0 +1,47 @@ 
+SUMMARY = "The network configuration abstraction renderer"
+DESCRIPTION = "Netplan is a utility for easily configuring networking on a \
+linux system. You simply create a YAML description of the required network \
+interfaces and what each should be configured to do. From this description \
+Netplan will generate all the necessary configuration for your chosen renderer \
+tool."
+HOMEPAGE = "https://netplan.io"
+SECTION = "net/misc"
+
+LICENSE = "GPL-3.0-only"
+LIC_FILES_CHKSUM = "file://COPYING;md5=d32239bcb673463ab874e80d47fae504"
+
+inherit meson pkgconfig systemd python3targetconfig features_check
+
+REQUIRED_DISTRO_FEATURES = "systemd"
+
+SRC_URI = "git://github.com/CanonicalLtd/netplan.git;branch=main;protocol=https \
+           file://0001-meson.build-drop-unnecessary-build-dependencies.patch \
+           file://0002-meson.build-do-not-use-Werror.patch \
+          "
+
+SRC_URI:append:libc-musl = " file://0001-don-t-fail-if-GLOB_BRACE-is-not-defined.patch"
+SRC_URI:append:toolchain-clang = " file://0001-networkd.c-define-scope-specific-to-case-statement.patch"
+
+SRCREV = "45f7cd1569896d9e316c130bf5c60b7ccfc8211d"
+
+S = "${WORKDIR}/git"
+
+DEPENDS = "glib-2.0 libyaml util-linux-libuuid \
+           systemd python3-cffi-native \
+          "
+
+EXTRA_OEMESON = "-Dunit_testing=false"
+
+RDEPENDS:${PN} = "python3-core python3-netifaces python3-pyyaml \
+                  python3-dbus python3-rich python3-cffi \
+                  util-linux-libuuid libnetplan \
+                 "
+
+PACKAGES += "${PN}-dbus libnetplan"
+
+FILES:libnetplan = "${libdir}/libnetplan.so.*"
+FILES:${PN} = "${sbindir} ${libexecdir}/netplan/generate \
+               ${datadir}/netplan ${datadir}/bash-completion \
+               ${systemd_unitdir} ${PYTHON_SITEPACKAGES_DIR} \
+              "
+FILES:${PN}-dbus = "${libexecdir}/netplan/netplan-dbus ${datadir}/dbus-1"