233933
From bf5906cbc9bf986c7495db792d098001e28c47e3 Mon Sep 17 00:00:00 2001
233933
From: Niels de Vos <ndevos@redhat.com>
233933
Date: Wed, 22 Apr 2015 15:39:59 +0200
233933
Subject: [PATCH 10/52] spec: fix/add pre-transaction scripts for geo-rep and
233933
 cli packages
233933
233933
The cli subpackage never had a %pretrans script, this has been added
233933
now.
233933
233933
The %pretrans script for ge-repliaction was never included in the RPM
233933
package because it was disable by a undefined macro (_can_georeplicate).
233933
This macro is not used/set anywhere else and _without_georeplication
233933
should take care of it anyway.
233933
233933
Note: This is a Red Hat Gluster Storage specific patch. Upstream
233933
      packaging guidelines do not allow these kind of 'features'.
233933
233933
Label: DOWNSTREAM ONLY
233933
233933
Change-Id: I16aab5bba72f1ed178f3bcac47f9d8ef767cfcef
233933
Signed-off-by: Niels de Vos <ndevos@redhat.com>
233933
Signed-off-by: Bala.FA <barumuga@redhat.com>
233933
Reviewed-on: https://code.engineering.redhat.com/gerrit/50491
233933
Reviewed-on: https://code.engineering.redhat.com/gerrit/60138
233933
Tested-by: Milind Changire <mchangir@redhat.com>
233933
---
233933
 glusterfs.spec.in | 43 +++++++++++++++++++++++++++++++++++++++++--
233933
 1 file changed, 41 insertions(+), 2 deletions(-)
233933
233933
diff --git a/glusterfs.spec.in b/glusterfs.spec.in
233933
index 8a31a98..b70dbfc 100644
233933
--- a/glusterfs.spec.in
233933
+++ b/glusterfs.spec.in
233933
@@ -1626,6 +1626,47 @@ end
233933
 
233933
 
233933
 
233933
+%pretrans cli -p <lua>
233933
+if not posix.access("/bin/bash", "x") then
233933
+    -- initial installation, no shell, no running glusterfsd
233933
+    return 0
233933
+end
233933
+
233933
+-- TODO: move this completely to a lua script
233933
+-- For now, we write a temporary bash script and execute that.
233933
+
233933
+script = [[#!/bin/sh
233933
+pidof -c -o %PPID -x glusterfsd &>/dev/null
233933
+
233933
+if [ $? -eq 0 ]; then
233933
+   pushd . > /dev/null 2>&1
233933
+   for volume in /var/lib/glusterd/vols/*; do cd $volume;
233933
+       vol_type=`grep '^type=' info | awk -F'=' '{print $2}'`
233933
+       volume_started=`grep '^status=' info | awk -F'=' '{print $2}'`
233933
+       if [ $vol_type -eq 0 ] && [ $volume_started -eq 1 ] ; then
233933
+          exit 1;
233933
+       fi
233933
+   done
233933
+
233933
+   popd > /dev/null 2>&1
233933
+   exit 1;
233933
+fi
233933
+]]
233933
+
233933
+-- rpm in RHEL5 does not have os.tmpname()
233933
+-- io.tmpfile() can not be resolved to a filename to pass to bash :-/
233933
+tmpname = "/tmp/glusterfs-cli_pretrans_" .. os.date("%s")
233933
+tmpfile = io.open(tmpname, "w")
233933
+tmpfile:write(script)
233933
+tmpfile:close()
233933
+ok, how, val = os.execute("/bin/bash " .. tmpname)
233933
+os.remove(tmpname)
233933
+if not (ok == 0) then
233933
+   error("Detected running glusterfs processes", ok)
233933
+end
233933
+
233933
+
233933
+
233933
 %pretrans devel -p <lua>
233933
 if not posix.access("/bin/bash", "x") then
233933
     -- initial installation, no shell, no running glusterfsd
233933
@@ -1708,7 +1749,6 @@ end
233933
 
233933
 
233933
 
233933
-%if 0%{?_can_georeplicate}
233933
 %if ( 0%{!?_without_georeplication:1} )
233933
 %pretrans geo-replication -p <lua>
233933
 if not posix.access("/bin/bash", "x") then
233933
@@ -1749,7 +1789,6 @@ if not (ok == 0) then
233933
    error("Detected running glusterfs processes", ok)
233933
 end
233933
 %endif
233933
-%endif
233933
 
233933
 
233933
 
233933
-- 
233933
1.8.3.1
233933