xenserver: Clean up /usr/sbin/brctl dangling symlink.
[sliver-openvswitch.git] / xenserver / openvswitch-xen.spec
index 9a533a8..1b97a53 100644 (file)
@@ -73,8 +73,8 @@ install -m 644 xenserver/opt_xensource_libexec_InterfaceReconfigureVswitch.py \
              $RPM_BUILD_ROOT/usr/share/openvswitch/scripts/InterfaceReconfigureVswitch.py
 install -m 755 xenserver/etc_xensource_scripts_vif \
              $RPM_BUILD_ROOT/usr/share/openvswitch/scripts/vif
-install -m 755 xenserver/usr_share_openvswitch_scripts_ovs-external-ids \
-               $RPM_BUILD_ROOT/usr/share/openvswitch/scripts/ovs-external-ids
+install -m 755 xenserver/usr_share_openvswitch_scripts_ovs-xapi-sync \
+               $RPM_BUILD_ROOT/usr/share/openvswitch/scripts/ovs-xapi-sync
 install -m 755 xenserver/usr_sbin_xen-bugtool \
              $RPM_BUILD_ROOT/usr/share/openvswitch/scripts/xen-bugtool
 install -m 755 xenserver/usr_share_openvswitch_scripts_sysconfig.template \
@@ -109,23 +109,26 @@ install -d -m 755 $RPM_BUILD_ROOT/var/lib/openvswitch
 rm -rf $RPM_BUILD_ROOT
 
 %post
-if test ! -e /var/xapi/network.dbcache; then
-    if test "$1" = 1; then
-        printf "Creating xapi database cache...  "
-    else
-        printf "warning: Open vSwitch is being re-installed or upgraded,\n"
-        printf "         but the xapi database cache is missing.\n"
-        printf "Re-creating xapi database cache...  "
-    fi
+# Do not run the first block if we are in the XenServer installer
+if runlevel >/dev/null 2>&1; then
+    if test ! -e /var/xapi/network.dbcache; then
+        if test "$1" = 1; then
+            printf "Creating xapi database cache...  "
+        else
+            printf "warning: Open vSwitch is being re-installed or upgraded,\n"
+            printf "         but the xapi database cache is missing.\n"
+            printf "Re-creating xapi database cache...  "
+        fi
 
-    if /usr/share/openvswitch/scripts/interface-reconfigure rewrite; then
-        printf "done.\n"
-    else
-        printf "FAILED\n"
-        printf "Open vSwitch can only be installed on a XenServer that\n"
-        printf "has connectivity to xapi on the pool master.  Please\n"
-        printf "fix connectivity to the pool master, then try again.\n"
-        exit 1
+        if /usr/share/openvswitch/scripts/interface-reconfigure rewrite; then
+            printf "done.\n"
+        else
+            printf "FAILED\n"
+            printf "Open vSwitch can only be installed on a XenServer that\n"
+            printf "has connectivity to xapi on the pool master.  Please\n"
+            printf "fix connectivity to the pool master, then try again.\n"
+            exit 1
+        fi
     fi
 fi
 
@@ -196,6 +199,13 @@ do
     fi
 done
 
+# Bug #4667: one-time cleanup of brctl removal in commit 54f16a10
+# (xenserver: Remove brctl wrapper script).
+if [ -h /usr/sbin/brctl ] &&
+    [ "$(readlink /usr/sbin/brctl)" = /usr/share/openvswitch/scripts/brctl ]; then
+    mv -f /usr/lib/openvswitch/xs-original/brctl /usr/sbin/
+fi
+
 # Ensure all required services are set to run
 for s in openvswitch openvswitch-xapi-update; do
     if chkconfig --list $s >/dev/null 2>&1; then
@@ -228,37 +238,38 @@ fi
 
 
 %postun
-if [ "$1" = "0" ]; then     # $1 = 1 for upgrade
-    rm -f /usr/lib/xsconsole/plugins-base/XSFeatureVSwitch.pyc \
-        /usr/lib/xsconsole/plugins-base/XSFeatureVSwitch.pyo
-
-    rm -f /usr/share/openvswitch/scripts/InterfaceReconfigure.pyc \
-        /usr/share/openvswitch/scripts/InterfaceReconfigure.pyo \
-        /usr/share/openvswitch/scripts/InterfaceReconfigureBridge.pyc \
-        /usr/share/openvswitch/scripts/InterfaceReconfigureBridge.pyo \
-        /usr/share/openvswitch/scripts/InterfaceReconfigureVSwitch.pyc \
-        /usr/share/openvswitch/scripts/InterfaceReconfigureVSwitch.pyo 
-
-    # Restore original XenServer scripts
-    for f in \
-        /opt/xensource/libexec/interface-reconfigure \
-        /opt/xensource/libexec/InterfaceReconfigure.py \
-        /opt/xensource/libexec/InterfaceReconfigureBridge.py \
-        /opt/xensource/libexec/InterfaceReconfigureVswitch.py \
-        /etc/xensource/scripts/vif \
-        /usr/sbin/xen-bugtool
-    do
-        s=$(basename "$f")
-        if [ ! -f "/usr/lib/openvswitch/xs-original/$s" ]; then
-            printf "Original XenServer $s script not present in /usr/lib/openvswitch/xs-original\n"
-            printf "Could not restore original XenServer script.\n"
-        else
-            (rm -f "$f" \
-                && mv "/usr/lib/openvswitch/xs-original/$s" "$f") \
-                || printf "Could not restore original XenServer $s script.\n"
-        fi
-    done
+rm -f /usr/lib/xsconsole/plugins-base/XSFeatureVSwitch.pyc \
+    /usr/lib/xsconsole/plugins-base/XSFeatureVSwitch.pyo
+
+rm -f /usr/share/openvswitch/scripts/InterfaceReconfigure.pyc \
+    /usr/share/openvswitch/scripts/InterfaceReconfigure.pyo \
+    /usr/share/openvswitch/scripts/InterfaceReconfigureBridge.pyc \
+    /usr/share/openvswitch/scripts/InterfaceReconfigureBridge.pyo \
+    /usr/share/openvswitch/scripts/InterfaceReconfigureVSwitch.pyc \
+    /usr/share/openvswitch/scripts/InterfaceReconfigureVSwitch.pyo 
+
+# Restore original XenServer scripts. It's important to do this even on upgrade
+# since the version to be installed may be missing some of these scripts.
+for f in \
+    /opt/xensource/libexec/interface-reconfigure \
+    /opt/xensource/libexec/InterfaceReconfigure.py \
+    /opt/xensource/libexec/InterfaceReconfigureBridge.py \
+    /opt/xensource/libexec/InterfaceReconfigureVswitch.py \
+    /etc/xensource/scripts/vif \
+    /usr/sbin/xen-bugtool
+do
+    s=$(basename "$f")
+    if [ ! -f "/usr/lib/openvswitch/xs-original/$s" ]; then
+        printf "Original XenServer $s script not present in /usr/lib/openvswitch/xs-original\n"
+        printf "Could not restore original XenServer script.\n"
+    else
+        (rm -f "$f" \
+            && mv "/usr/lib/openvswitch/xs-original/$s" "$f") \
+            || printf "Could not restore original XenServer $s script.\n"
+    fi
+done
 
+if [ "$1" = "0" ]; then     # $1 = 1 for upgrade
     # Remove all configuration files
     rm -f /etc/openvswitch/conf.db
     rm -f /etc/sysconfig/openvswitch
@@ -274,7 +285,6 @@ if [ "$1" = "0" ]; then     # $1 = 1 for upgrade
     printf "could leave the server in a state requiring manual recovery.\n\n"
 fi
 
-
 %files
 %defattr(-,root,root)
 /etc/init.d/openvswitch
@@ -305,7 +315,7 @@ fi
 /usr/share/openvswitch/python/ovs/timeval.py
 /usr/share/openvswitch/python/ovs/util.py
 /usr/share/openvswitch/python/uuid.py
-/usr/share/openvswitch/scripts/ovs-external-ids
+/usr/share/openvswitch/scripts/ovs-xapi-sync
 /usr/share/openvswitch/scripts/interface-reconfigure
 /usr/share/openvswitch/scripts/InterfaceReconfigure.py
 /usr/share/openvswitch/scripts/InterfaceReconfigureBridge.py