All of lore.kernel.org
 help / color / mirror / Atom feed
From: Peter Kjellerstedt <pkj@axis.com>
To: <openembedded-devel@lists.openembedded.org>
Subject: [meta-networking][PATCH] ebtables: Remove the dependecy on bash
Date: Thu, 7 Nov 2024 10:01:00 +0100	[thread overview]
Message-ID: <20241107090100.2029544-1-pkj@axis.com> (raw)

Rewrite ebtables-legacy-save to avoid using bashisms.

Signed-off-by: Peter Kjellerstedt <peter.kjellerstedt@axis.com>
---
 .../ebtables-2.0.11/ebtables-legacy-save      | 19 +++++++++----------
 .../ebtables/ebtables_2.0.11.bb               |  2 --
 2 files changed, 9 insertions(+), 12 deletions(-)

diff --git a/meta-networking/recipes-filter/ebtables/ebtables-2.0.11/ebtables-legacy-save b/meta-networking/recipes-filter/ebtables/ebtables-2.0.11/ebtables-legacy-save
index 2133600f77..0b39c23deb 100644
--- a/meta-networking/recipes-filter/ebtables/ebtables-2.0.11/ebtables-legacy-save
+++ b/meta-networking/recipes-filter/ebtables/ebtables-2.0.11/ebtables-legacy-save
@@ -1,4 +1,4 @@
-#!/bin/bash
+#!/bin/sh
 
 EBTABLES="/usr/sbin/ebtables-legacy"
 
@@ -11,7 +11,7 @@ cnt=""
 
 for table_name in $(grep -E '^ebtable_' /proc/modules | cut -f1 -d' ' | sed s/ebtable_//); do
     table=$($EBTABLES -t $table_name -L $cnt)
-    [ $? -eq 0 ] || { echo "$table"; exit -1; }
+    [ $? -eq 0 ] || { echo "$table"; exit 1; }
 
     chain=""
     rules=""
@@ -20,24 +20,23 @@ for table_name in $(grep -E '^ebtable_' /proc/modules | cut -f1 -d' ' | sed s/eb
 
 	case "$line" in 
 	    Bridge\ table:\ *)
-		echo "*${line:14}"
+		echo "*${line#Bridge table: }"
 		;;
 	    Bridge\ chain:\ *)
-		chain="${line:14}"
+		chain="${line#Bridge chain: }"
 		chain="${chain%%,*}"
 		policy="${line##*policy: }"
 		echo ":$chain $policy"
 		;;
 	    *)
-		if [ "$cnt" = "--Lc" ]; then
-		    line=${line/, pcnt \=/ -c}
-		    line=${line/-- bcnt \=/}
-		fi
-		rules="$rules-A $chain $line\n"
+		[ "$cnt" != "--Lc" ] ||
+                    line=$(echo "$line" | sed -e 's/, pcnt =/-c/' -e 's/ -- bcnt =//')
+		rules="$rules-A $chain $line
+"
 		;;
 	esac
     done <<EOF
 $table
 EOF
-    echo -e $rules
+    echo "$rules"
 done
diff --git a/meta-networking/recipes-filter/ebtables/ebtables_2.0.11.bb b/meta-networking/recipes-filter/ebtables/ebtables_2.0.11.bb
index 8918936e14..be8c49854e 100644
--- a/meta-networking/recipes-filter/ebtables/ebtables_2.0.11.bb
+++ b/meta-networking/recipes-filter/ebtables/ebtables_2.0.11.bb
@@ -6,8 +6,6 @@ LICENSE = "GPL-2.0-only"
 LIC_FILES_CHKSUM = "file://COPYING;md5=53b4a999993871a28ab1488fdbd2e73e"
 SECTION = "net"
 
-RDEPENDS:${PN} += "bash"
-
 RRECOMMENDS:${PN} += "kernel-module-ebtables \
     "
 


             reply	other threads:[~2024-11-12 16:28 UTC|newest]

Thread overview: 2+ messages / expand[flat|nested]  mbox.gz  Atom feed  top
2024-11-07  9:01 Peter Kjellerstedt [this message]
  -- strict thread matches above, loose matches on Subject: below --
2024-11-12 16:12 [meta-networking][PATCH] ebtables: Remove the dependecy on bash Peter Kjellerstedt

Reply instructions:

You may reply publicly to this message via plain-text email
using any one of the following methods:

* Save the following mbox file, import it into your mail client,
  and reply-to-all from there: mbox

  Avoid top-posting and favor interleaved quoting:
  https://en.wikipedia.org/wiki/Posting_style#Interleaved_style

* Reply using the --to, --cc, and --in-reply-to
  switches of git-send-email(1):

  git send-email \
    --in-reply-to=20241107090100.2029544-1-pkj@axis.com \
    --to=pkj@axis.com \
    --cc=openembedded-devel@lists.openembedded.org \
    /path/to/YOUR_REPLY

  https://kernel.org/pub/software/scm/git/docs/git-send-email.html

* If your mail client supports setting the In-Reply-To header
  via mailto: links, try the mailto: link
Be sure your reply has a Subject: header at the top and a blank line before the message body.
This is an external index of several public inboxes,
see mirroring instructions on how to clone and mirror
all data and code used by this external index.