diff mbox series

[1/1] eudev: allow for predictable network interface names

Message ID 20240131185342.3602428-1-joe.slater@windriver.com
State Accepted, archived
Commit dc7cd56df85f28f2a3a3dd97730d475522b7b0f7
Headers show
Series [1/1] eudev: allow for predictable network interface names | expand

Commit Message

Slater, Joseph Jan. 31, 2024, 6:53 p.m. UTC
From: Joe Slater <joe.slater@windriver.com>

Do not suppress renaming by eudev if 'pni-names' is
a distro feature.  The previous behavior was to always
suppress renaming.

eudev is used when sysvinit is the init manager.

Signed-off-by: Joe Slater <joe.slater@windriver.com>
---
 meta/recipes-core/udev/eudev_3.2.14.bb | 7 ++++---
 1 file changed, 4 insertions(+), 3 deletions(-)

Comments

Peter Kjellerstedt Feb. 2, 2024, 6:42 p.m. UTC | #1
> -----Original Message-----
> From: openembedded-core@lists.openembedded.org <openembedded-core@lists.openembedded.org> On Behalf Of Joe Slater via lists.openembedded.org
> Sent: den 31 januari 2024 19:54
> To: openembedded-core@lists.openembedded.org
> Cc: joe.slater@windriver.com; randy.macleod@windriver.com
> Subject: [oe-core][PATCH 1/1] eudev: allow for predictable network interface names
> 
> From: Joe Slater <joe.slater@windriver.com>
> 
> Do not suppress renaming by eudev if 'pni-names' is
> a distro feature.  The previous behavior was to always
> suppress renaming.
> 
> eudev is used when sysvinit is the init manager.
> 
> Signed-off-by: Joe Slater <joe.slater@windriver.com>
> ---
>  meta/recipes-core/udev/eudev_3.2.14.bb | 7 ++++---
>  1 file changed, 4 insertions(+), 3 deletions(-)
> 
> diff --git a/meta/recipes-core/udev/eudev_3.2.14.bb b/meta/recipes-core/udev/eudev_3.2.14.bb
> index ddb3c3340f..18696679c8 100644
> --- a/meta/recipes-core/udev/eudev_3.2.14.bb
> +++ b/meta/recipes-core/udev/eudev_3.2.14.bb
> @@ -49,9 +49,10 @@ do_install:append() {
>  	install -d ${D}${sysconfdir}/udev/rules.d
>  	install -m 0644 ${WORKDIR}/local.rules ${D}${sysconfdir}/udev/rules.d/local.rules
> 
> -	# Use classic network interface naming scheme
> -	touch ${D}${sysconfdir}/udev/rules.d/80-net-name-slot.rules
> -
> +	# Use classic network interface naming scheme if no 'pni-names' distro feature
> +	if ${@bb.utils.contains('DISTRO_FEATURES', 'pni-names', 'false', 'true', d)}; then

May I suggest to write that as:

	if ! ${@bb.utils.contains('DISTRO_FEATURES', 'pni-names', 'true', 'false', d)}; then

At least I find it much easier to read code like this that mixes shell 
code with Python code where bb.utils.contains() is only used to determine 
whether a feature is set if it actually returns 'true' when the feature is set.
An alternative is to write it as:

	if [ ! "${@bb.utils.filter('DISTRO_FEATURES', 'pni-names', d)}" ]; then

> +		touch ${D}${sysconfdir}/udev/rules.d/80-net-name-slot.rules
> +	fi
>  }
> 
>  do_install:prepend:class-target () {
> --
> 2.25.1

//Peter
diff mbox series

Patch

diff --git a/meta/recipes-core/udev/eudev_3.2.14.bb b/meta/recipes-core/udev/eudev_3.2.14.bb
index ddb3c3340f..18696679c8 100644
--- a/meta/recipes-core/udev/eudev_3.2.14.bb
+++ b/meta/recipes-core/udev/eudev_3.2.14.bb
@@ -49,9 +49,10 @@  do_install:append() {
 	install -d ${D}${sysconfdir}/udev/rules.d
 	install -m 0644 ${WORKDIR}/local.rules ${D}${sysconfdir}/udev/rules.d/local.rules
 
-	# Use classic network interface naming scheme
-	touch ${D}${sysconfdir}/udev/rules.d/80-net-name-slot.rules
-
+	# Use classic network interface naming scheme if no 'pni-names' distro feature
+	if ${@bb.utils.contains('DISTRO_FEATURES', 'pni-names', 'false', 'true', d)}; then
+		touch ${D}${sysconfdir}/udev/rules.d/80-net-name-slot.rules
+	fi
 }
 
 do_install:prepend:class-target () {