Subject: [alpine-aports] [PATCH 1/2] main/openvswitch: fix ifupdown script

From: Stuart Cardall <[email-masked]>
Date: Tue, 25 Aug 2015 22:49:35 +0000

---
Changes v1 -> v2:
 - ifupdown script redone with better handling of the ovs-vswitchd depends
 - NB: after applying this first patch please move openvswitch-2.3.2-r2 into stable

 main/openvswitch/APKBUILD              | 14 ++++++-------
 main/openvswitch/ifupdown-alpine.patch | 38 +++++++++++++++++++++++-----------
 main/openvswitch/ifupdown.sh           | 22 ++++++++++++++------
 main/openvswitch/ovs-vswitchd.initd    |  2 +-
 4 files changed, 50 insertions(+), 26 deletions(-)

diff --git a/main/openvswitch/APKBUILD b/main/openvswitch/APKBUILD
index 940304c..d030bba 100644
--- a/main/openvswitch/APKBUILD
+++ b/main/openvswitch/APKBUILD
@@ -2,7 +2,7 @@
 # Maintainer: Stuart Cardall <[email-masked]>
 pkgname=openvswitch
 pkgver=2.3.2
-pkgrel=1
+pkgrel=2
 pkgdesc="A production quality, multilayer virtual switch"
 url="http://openvswitch.org/"
 arch="all"
@@ -87,30 +87,30 @@ package() {
 md5sums="5a5739ed82f1accac1c2d8d7553dc88f  openvswitch-2.3.2.tar.gz
 a2b05882127059f79a02d1c49b58e526  ovsdb-server.initd
 f10a8ac784654bec359bda52779f16fe  ovsdb-server.confd
-384ad5bbe9dd788de78012864233a756  ovs-vswitchd.initd
+401141939f2390b231ed758abda09eca  ovs-vswitchd.initd
 2d1e0111ea62779f49e14d62678294b2  ovs-vswitchd.confd
 45b381d434ccbc634a3224c5963edc66  ovs-modules.initd
 6e17032bd6e7caf6e6e844b5a84d7080  musl-if_packet.patch
 59fa9a6d293a25571562a5190ae559f2  0001-ovs-thread-Set-stacksize-to-1M.patch
-b8c688a31385dc4e19f12799546a8a8e  ifupdown-alpine.patch
+3a289fcaca5dbdb2d6b550151defca00  ifupdown-alpine.patch
 7280528282e3c9ec235e013fede2f973  readme.debian.patch"
 sha256sums="386b11df94d06c68d391ee4091832360095bd3a14c72d454325fab284dad9887  openvswitch-2.3.2.tar.gz
 737be74a4ce951cd49b9cd85696ff5cbdb54fa7ad52c831494fcf336487fc420  ovsdb-server.initd
 d0d8a6a7256f4cc47ab1b9f9f7657202388133bcfff3668e7c1d4adbcc572261  ovsdb-server.confd
-d2db312103d740fb9246ea218560995b969cb8356e3524d4c0ce79a06ccc65b8  ovs-vswitchd.initd
+e0343795bf565c2060f284eff1ea009a166e54dc230396d6ae6b000e0036d499  ovs-vswitchd.initd
 cc189d5ca24708ff775a4de312df3f611c65714724b8901ec6527c9e3f22e14a  ovs-vswitchd.confd
 06079771a94dd363218f2b3561efd0178a47d85bfd73c8b6cf24eef4ec82b0de  ovs-modules.initd
 d0e9e3e30b2943b10e7efa59c41c3bf8d5b599d55fc99198146bf4761df4d8ae  musl-if_packet.patch
 faf997814e89b0b5948c06050ef38051f0bc6b108958f76313263f77a724906c  0001-ovs-thread-Set-stacksize-to-1M.patch
-8554e7272818471fb12d633132e2e51ea31199a5d4559e2c098af48ab089b0de  ifupdown-alpine.patch
+4068e737a06e3e76ac16f95213130b959980d659fc3aecbc7213b851ac473ebc  ifupdown-alpine.patch
 57a2becc7210faff2fb57ef51f8e6c33978925b48e013ba5fb78d031f2f55748  readme.debian.patch"
 sha512sums="dfbd9d5b16aeecdc880efb910e0ec2e474dcc02515f0033b1e9466735387b39f2855bec49936a261aea66badb35e09598dbb9fc4b506e9a9e0c18d3441fea691  openvswitch-2.3.2.tar.gz
 097d4721a78fff749c534910d98543778474406bd61b469b88a0d981a2a380556444437ec44278cead6d8688c45a38b2acbf1551acb9ab38d048f413728e3b88  ovsdb-server.initd
 b1588d076bbfc7ef2dd46fce8e46186f40cbbc4667697f7ac13ddc68e34568fdab315fde47838de7f6d32916853190336cfe3735f672ad7cb624ae14dbff55a5  ovsdb-server.confd
-4bff37f8bed32d5327b4b0433984ab8ffdce77f618034aa6ffd1ad4a7caa00703ea2bef312876dce5aafa4c17fe06dddd75e5c05c10e13bf8f5c3805a0654a96  ovs-vswitchd.initd
+5d0892a44760765994b4ef57ae15b1b7266f387b59fb3c0730d9240c4da0f7d9cf7cc56bc3f79393160d3f5159dc0877c54f412325a441c7636687f02b8d5eff  ovs-vswitchd.initd
 346aea099f51707d2b4fc9fdc8c1502582723fb4e00c4d5d1624b0378c94dfb76674fa95e2af894f36169df52109dbe441ee6a45aa744584d9e4c74d15a46c1d  ovs-vswitchd.confd
 614c86eab826bb8f934cf4a98508fde9952a0b7211414e074510473af3455077a333729aa0e59f3634b9bf30d64847d0f7597246506c36a8f09d57573a2522fc  ovs-modules.initd
 1ebfb2629081cc0b34383e6c2f163f3c1d43da3a399b8ba8745871b77029d3b8fc21a287ff859a6a9cca2cb4885715458d4e4086cb6c17765ff7c898d4004850  musl-if_packet.patch
 5fed04e68b58ab322154fa1cc4c4b63b08c22ed41f0b7713dbe8437f7cb4e9fd93c8aba524c2e5a46bba956da9439f5bfe5ba6fcdff2b98fa9bbcc748c5b64db  0001-ovs-thread-Set-stacksize-to-1M.patch
-45c793e1fd303a2a234abdb99c07a5dac14261a216e3f250f50488dba7114771372225c18f9f1469344e040e1b51dec513d423323dce6af4077757c22f3330d9  ifupdown-alpine.patch
+c90b5ab0062e000f62e6eafa5ac3fd37e795131de4295c1d7e9a74e514e095af581dbe6fbe554aa2a691e296af503bf6372f6a9524c7c3c8e434114994e00101  ifupdown-alpine.patch
 27bf10138b0be024c0a9039aea9cfa42825d365de5d414872b25d7cd642f2d0d41d5c604d5282362f3d2b1782513fc792a619fe0b6de19d14c04178e11a3ccb0  readme.debian.patch"
diff --git a/main/openvswitch/ifupdown-alpine.patch b/main/openvswitch/ifupdown-alpine.patch
index a417f72..48b9c58 100644
--- a/main/openvswitch/ifupdown-alpine.patch
+++ b/main/openvswitch/ifupdown-alpine.patch
@@ -1,27 +1,41 @@
---- ./debian/ifupdown.sh.orig
-+++ ./debian/ifupdown.sh
-@@ -29,8 +29,8 @@ if (ovs_vsctl --version) > /dev/null 2>&
+--- openvswitch-2.3.2/debian/ifupdown.sh
++++ openvswitch-2.3.2/debian/ifupdown.sh.new
+@@ -25,12 +25,22 @@
+     ovs-vsctl --timeout=5 "$@"
+ }
+ 
++sv_status() {
++   /etc/init.d/$1 status &>/dev/null
++   return $?
++}
++
+ if (ovs_vsctl --version) > /dev/null 2>&1; then :; else
      exit 0
  fi
  
 -if /etc/init.d/openvswitch-switch status > /dev/null 2>&1; then :; else
 -    /etc/init.d/openvswitch-switch start
-+if ! /etc/init.d/ovs-vswitchd status &>/dev/null; then
-+    /etc/init.d/ovs-vswitchd start
++if ! sv_status ovs-vswitchd ; then # see src/librc/librc-depend.c
++    DEPENDS=$(/lib/rc/bin/rc-depend -t ineed -qq ovs-vswitchd)
++    for sv in $DEPENDS; do
++        if ! sv_status $sv; then
++                /sbin/rc-service $sv start
++        fi
++    done
  fi
  
  if [ "${MODE}" = "start" ]; then
-@@ -38,7 +38,8 @@
+@@ -42,7 +52,8 @@
                           ${OVS_EXTRA+-- $OVS_EXTRA}
  
                  if [ ! -z "${IF_OVS_PORTS}" ]; then
 -                    ifup --allow="${IFACE}" ${IF_OVS_PORTS}
-+#                    ifup --allow="${IFACE}" ${IF_OVS_PORTS}
-+                    ifup  ${IF_OVS_PORTS}
++#                   ifup --allow="${IFACE}" ${IF_OVS_PORTS}
++                    ifup ${IF_OVS_PORTS}
                  fi
                  ;;
          OVSPort)
-@@ -46,24 +47,24 @@
+@@ -50,24 +61,24 @@
                      "${IFACE}" ${IF_OVS_OPTIONS} \
                      ${OVS_EXTRA+-- $OVS_EXTRA}
  
@@ -34,7 +48,7 @@
                      type=internal ${OVS_EXTRA+-- $OVS_EXTRA}
  
 -                ifconfig "${IFACE}" up
-+		ip link set dev "${IFACE}" up
++                ip link set dev "${IFACE}" up
                  ;;
          OVSBond)
                  ovs_vsctl -- --fake-iface add-bond "${IF_OVS_BRIDGE}"\
@@ -50,12 +64,12 @@
                  done
                  ;;
          OVSTunnel)
-@@ -80,7 +81,8 @@
+@@ -84,7 +95,8 @@
      case "${IF_OVS_TYPE}" in
          OVSBridge)
                  if [ ! -z "${IF_OVS_PORTS}" ]; then
 -                    ifdown --allow="${IFACE}" ${IF_OVS_PORTS}
-+#                    ifdown --allow="${IFACE}" ${IF_OVS_PORTS}
++#                   ifdown --allow="${IFACE}" ${IF_OVS_PORTS}
 +                    ifdown ${IF_OVS_PORTS}
                  fi
  
diff --git a/main/openvswitch/ifupdown.sh b/main/openvswitch/ifupdown.sh
index a2bd048..1dfe7c3 100755
--- a/main/openvswitch/ifupdown.sh
+++ b/main/openvswitch/ifupdown.sh
@@ -25,12 +25,22 @@ ovs_vsctl() {
     ovs-vsctl --timeout=5 "$@"
 }
 
+sv_status() {
+   /etc/init.d/$1 status &>/dev/null
+   return $?
+}
+
 if (ovs_vsctl --version) > /dev/null 2>&1; then :; else
     exit 0
 fi
 
-if /etc/init.d/ovs-vswitchd status > /dev/null 2>&1; then :; else
-    /etc/init.d/ovs-vswitchd start
+if ! sv_status ovs-vswitchd ; then # see src/librc/librc-depend.c
+    DEPENDS=$(/lib/rc/bin/rc-depend -t ineed -qq ovs-vswitchd)
+    for sv in $DEPENDS; do
+        if ! sv_status $sv; then
+                /sbin/rc-service $sv start
+        fi
+    done
 fi
 
 if [ "${MODE}" = "start" ]; then
@@ -42,8 +52,8 @@ if [ "${MODE}" = "start" ]; then
                          ${OVS_EXTRA+-- $OVS_EXTRA}
 
                 if [ ! -z "${IF_OVS_PORTS}" ]; then
-#                    ifup --allow="${IFACE}" ${IF_OVS_PORTS}
-                    ifup  ${IF_OVS_PORTS}
+#                   ifup --allow="${IFACE}" ${IF_OVS_PORTS}
+                    ifup ${IF_OVS_PORTS}
                 fi
                 ;;
         OVSPort)
@@ -58,7 +68,7 @@ if [ "${MODE}" = "start" ]; then
                     "${IFACE}" ${IF_OVS_OPTIONS} -- set Interface "${IFACE}"\
                     type=internal ${OVS_EXTRA+-- $OVS_EXTRA}
 
-		ip link set dev "${IFACE}" up
+                ip link set dev "${IFACE}" up
                 ;;
         OVSBond)
                 ovs_vsctl -- --fake-iface add-bond "${IF_OVS_BRIDGE}"\
@@ -85,7 +95,7 @@ elif [ "${MODE}" = "stop" ]; then
     case "${IF_OVS_TYPE}" in
         OVSBridge)
                 if [ ! -z "${IF_OVS_PORTS}" ]; then
-#                    ifdown --allow="${IFACE}" ${IF_OVS_PORTS}
+#                   ifdown --allow="${IFACE}" ${IF_OVS_PORTS}
                     ifdown ${IF_OVS_PORTS}
                 fi
 
diff --git a/main/openvswitch/ovs-vswitchd.initd b/main/openvswitch/ovs-vswitchd.initd
index fe35a96..d7a2be4 100644
--- a/main/openvswitch/ovs-vswitchd.initd
+++ b/main/openvswitch/ovs-vswitchd.initd
@@ -14,7 +14,7 @@ command_args="
     ${OPTIONS} ${DATABASE}"
 
 depend() {
-	need localmount ovsdb-server
+	need localmount ovs-modules ovsdb-server
 	after bootmisc hwdrivers modules
 	before net
 	use logger
-- 
2.4.6

---
Unsubscribe:  [email-masked]
Help:         [email-masked]
---