diff mbox series

[ovs-dev,v2] ovs-save: add bindir to PATH

Message ID 20220617150346.3041666-1-amorenoz@redhat.com
State Changes Requested
Headers show
Series [ovs-dev,v2] ovs-save: add bindir to PATH | expand

Checks

Context Check Description
ovsrobot/apply-robot success apply and check: success
ovsrobot/github-robot-_Build_and_Test success github build: passed
ovsrobot/intel-ovs-compilation success test: success

Commit Message

Adrian Moreno June 17, 2022, 3:03 p.m. UTC
If openvswitch is not installed in the default system's path ovs-save
script will fail to find the tools it requires.

Fix this by adding $bindir to the PATH.
Refactor common path calculation into ovs-lib.

Signed-off-by: Adrian Moreno <amorenoz@redhat.com>
---
 utilities/ovs-ctl.in      | 11 +----------
 utilities/ovs-kmod-ctl.in |  7 +------
 utilities/ovs-lib.in      | 21 +++++++++++++++++++++
 utilities/ovs-save        |  2 ++
 4 files changed, 25 insertions(+), 16 deletions(-)

Comments

Simon Horman June 12, 2023, 2:59 p.m. UTC | #1
On Fri, Jun 17, 2022 at 05:03:46PM +0200, Adrian Moreno wrote:
> If openvswitch is not installed in the default system's path ovs-save
> script will fail to find the tools it requires.
> 
> Fix this by adding $bindir to the PATH.
> Refactor common path calculation into ovs-lib.
> 
> Signed-off-by: Adrian Moreno <amorenoz@redhat.com>

Hi Adrian,

this patch seems to have gone stale.
Please consider reposting it if it is still relevant.
Adrian Moreno June 13, 2023, 6:44 a.m. UTC | #2
On 6/12/23 16:59, Simon Horman wrote:
> On Fri, Jun 17, 2022 at 05:03:46PM +0200, Adrian Moreno wrote:
>> If openvswitch is not installed in the default system's path ovs-save
>> script will fail to find the tools it requires.
>>
>> Fix this by adding $bindir to the PATH.
>> Refactor common path calculation into ovs-lib.
>>
>> Signed-off-by: Adrian Moreno <amorenoz@redhat.com>
> 
> Hi Adrian,
> 
> this patch seems to have gone stale.
> Please consider reposting it if it is still relevant.
> 

Thanks Simon for the archeology!

You are right. I completely forgot about it. I'll repost.

Cheers.
diff mbox series

Patch

diff --git a/utilities/ovs-ctl.in b/utilities/ovs-ctl.in
index e6e07f476..df4770ac2 100644
--- a/utilities/ovs-ctl.in
+++ b/utilities/ovs-ctl.in
@@ -19,16 +19,7 @@  case $0 in
 esac
 . "$dir0/ovs-lib" || exit 1
 
-for dir in "$sbindir" "$bindir" /sbin /bin /usr/sbin /usr/bin; do
-    case :$PATH: in
-        *:$dir:*) ;;
-        *)
-        case $dir in
-            $sbindir | $bindir) PATH=$dir:$PATH ;;
-            *) PATH=$PATH:$dir ;;
-        esac
-    esac
-done
+PATH=$OVS_SBIN_PATH
 
 ## ----- ##
 ## start ##
diff --git a/utilities/ovs-kmod-ctl.in b/utilities/ovs-kmod-ctl.in
index 19f100964..9804008cf 100644
--- a/utilities/ovs-kmod-ctl.in
+++ b/utilities/ovs-kmod-ctl.in
@@ -20,12 +20,7 @@  case $0 in
 esac
 . "$dir0/ovs-lib" || exit 1
 
-for dir in "$sbindir" "$bindir" /sbin /bin /usr/sbin /usr/bin; do
-    case :$PATH: in
-        *:$dir:*) ;;
-        *) PATH=$PATH:$dir ;;
-    esac
-done
+PATH=$OVS_SBIN_PATH
 
 insert_mods () {
     # Try loading openvswitch kernel module.
diff --git a/utilities/ovs-lib.in b/utilities/ovs-lib.in
index 13477a6a9..a00c484f6 100644
--- a/utilities/ovs-lib.in
+++ b/utilities/ovs-lib.in
@@ -39,6 +39,27 @@  else
     dbdir='@DBDIR@'
 fi
 
+OVS_SBIN_PATH=$PATH
+OVS_BIN_PATH=$PATH
+for dir in "$sbindir" "$bindir" /sbin /bin /usr/sbin /usr/bin; do
+    case :$PATH: in
+        *:$dir:*) ;;
+        *)
+        case $dir in
+            $bindir)
+                OVS_BIN_PATH=$dir:$OVS_BIN_PATH
+                OVS_SBIN_PATH=$dir:$OVS_SBIN_PATH
+                ;;
+            $sbindir)
+                OVS_SBIN_PATH=$dir:$OVS_SBIN_PATH
+                ;;
+            *)
+                OVS_BIN_PATH=$OVS_BIN_PATH:$dir
+                OVS_SBIN_PATH=$OVS_SBIN_PATH:$dir
+        esac
+    esac
+done
+
 ovs_ctl_log () {
     echo "$@" >> "${logdir}/ovs-ctl.log"
 }
diff --git a/utilities/ovs-save b/utilities/ovs-save
index a190902f4..1c4810648 100755
--- a/utilities/ovs-save
+++ b/utilities/ovs-save
@@ -20,6 +20,8 @@  case $0 in
 esac
 . "$dir0/ovs-lib" || exit 1
 
+PATH=$OVS_BIN_PATH
+
 usage() {
     UTIL=$(basename $0)
     cat <<EOF