3604df
From db766336fd658cde2beec09b68e309e8866b08aa Mon Sep 17 00:00:00 2001
cb8e9e
From: Bala.FA <barumuga@redhat.com>
cb8e9e
Date: Wed, 17 Jun 2015 21:34:52 +0530
3604df
Subject: [PATCH 14/86] build: add pretrans check
cb8e9e
cb8e9e
This patch adds pretrans check for client-xlators, ganesha and
cb8e9e
python-gluster sub-packages.
cb8e9e
cb8e9e
Label: DOWNSTREAM ONLY
cb8e9e
cb8e9e
Change-Id: I454016319832c11902c0ca79a79fbbcf8ac0a121
cb8e9e
Signed-off-by: Bala.FA <barumuga@redhat.com>
cb8e9e
Reviewed-on: https://code.engineering.redhat.com/gerrit/50967
12a457
Reviewed-on: https://code.engineering.redhat.com/gerrit/60140
12a457
Tested-by: Milind Changire <mchangir@redhat.com>
cb8e9e
---
cb8e9e
 glusterfs.spec.in |  127 +++++++++++++++++++++++++++++++++++++++++++++++++++++
cb8e9e
 1 files changed, 127 insertions(+), 0 deletions(-)
cb8e9e
cb8e9e
diff --git a/glusterfs.spec.in b/glusterfs.spec.in
3604df
index a10663f..d832235 100644
cb8e9e
--- a/glusterfs.spec.in
cb8e9e
+++ b/glusterfs.spec.in
3604df
@@ -1529,6 +1529,47 @@ end
cb8e9e
 
cb8e9e
 
cb8e9e
 
cb8e9e
+%pretrans client-xlators -p <lua>
cb8e9e
+if not posix.access("/bin/bash", "x") then
cb8e9e
+    -- initial installation, no shell, no running glusterfsd
cb8e9e
+    return 0
cb8e9e
+end
cb8e9e
+
cb8e9e
+-- TODO: move this completely to a lua script
cb8e9e
+-- For now, we write a temporary bash script and execute that.
cb8e9e
+
cb8e9e
+script = [[#!/bin/sh
cb8e9e
+pidof -c -o %PPID -x glusterfsd &>/dev/null
cb8e9e
+
cb8e9e
+if [ $? -eq 0 ]; then
cb8e9e
+   pushd . > /dev/null 2>&1
cb8e9e
+   for volume in /var/lib/glusterd/vols/*; do cd $volume;
cb8e9e
+       vol_type=`grep '^type=' info | awk -F'=' '{print $2}'`
cb8e9e
+       volume_started=`grep '^status=' info | awk -F'=' '{print $2}'`
cb8e9e
+       if [ $vol_type -eq 0 ] && [ $volume_started -eq 1 ] ; then
cb8e9e
+          exit 1;
cb8e9e
+       fi
cb8e9e
+   done
cb8e9e
+
cb8e9e
+   popd > /dev/null 2>&1
cb8e9e
+   exit 1;
cb8e9e
+fi
cb8e9e
+]]
cb8e9e
+
cb8e9e
+-- rpm in RHEL5 does not have os.tmpname()
cb8e9e
+-- io.tmpfile() can not be resolved to a filename to pass to bash :-/
cb8e9e
+tmpname = "/tmp/glusterfs-client-xlators_pretrans_" .. os.date("%s")
cb8e9e
+tmpfile = io.open(tmpname, "w")
cb8e9e
+tmpfile:write(script)
cb8e9e
+tmpfile:close()
cb8e9e
+ok, how, val = os.execute("/bin/bash " .. tmpname)
cb8e9e
+os.remove(tmpname)
cb8e9e
+if not (ok == 0) then
cb8e9e
+   error("Detected running glusterfs processes", ok)
cb8e9e
+end
cb8e9e
+
cb8e9e
+
cb8e9e
+
cb8e9e
 %pretrans devel -p <lua>
cb8e9e
 if not posix.access("/bin/bash", "x") then
cb8e9e
     -- initial installation, no shell, no running glusterfsd
3604df
@@ -1611,6 +1652,47 @@ end
cb8e9e
 
cb8e9e
 
cb8e9e
 
cb8e9e
+%pretrans ganesha -p <lua>
cb8e9e
+if not posix.access("/bin/bash", "x") then
cb8e9e
+    -- initial installation, no shell, no running glusterfsd
cb8e9e
+    return 0
cb8e9e
+end
cb8e9e
+
cb8e9e
+-- TODO: move this completely to a lua script
cb8e9e
+-- For now, we write a temporary bash script and execute that.
cb8e9e
+
cb8e9e
+script = [[#!/bin/sh
cb8e9e
+pidof -c -o %PPID -x glusterfsd &>/dev/null
cb8e9e
+
cb8e9e
+if [ $? -eq 0 ]; then
cb8e9e
+   pushd . > /dev/null 2>&1
cb8e9e
+   for volume in /var/lib/glusterd/vols/*; do cd $volume;
cb8e9e
+       vol_type=`grep '^type=' info | awk -F'=' '{print $2}'`
cb8e9e
+       volume_started=`grep '^status=' info | awk -F'=' '{print $2}'`
cb8e9e
+       if [ $vol_type -eq 0 ] && [ $volume_started -eq 1 ] ; then
cb8e9e
+          exit 1;
cb8e9e
+       fi
cb8e9e
+   done
cb8e9e
+
cb8e9e
+   popd > /dev/null 2>&1
cb8e9e
+   exit 1;
cb8e9e
+fi
cb8e9e
+]]
cb8e9e
+
cb8e9e
+-- rpm in RHEL5 does not have os.tmpname()
cb8e9e
+-- io.tmpfile() can not be resolved to a filename to pass to bash :-/
cb8e9e
+tmpname = "/tmp/glusterfs-ganesha_pretrans_" .. os.date("%s")
cb8e9e
+tmpfile = io.open(tmpname, "w")
cb8e9e
+tmpfile:write(script)
cb8e9e
+tmpfile:close()
cb8e9e
+ok, how, val = os.execute("/bin/bash " .. tmpname)
cb8e9e
+os.remove(tmpname)
cb8e9e
+if not (ok == 0) then
cb8e9e
+   error("Detected running glusterfs processes", ok)
cb8e9e
+end
cb8e9e
+
cb8e9e
+
cb8e9e
+
cb8e9e
 %if ( 0%{!?_without_georeplication:1} )
cb8e9e
 %pretrans geo-replication -p <lua>
cb8e9e
 if not posix.access("/bin/bash", "x") then
3604df
@@ -1695,6 +1777,47 @@ end
cb8e9e
 
cb8e9e
 
cb8e9e
 
cb8e9e
+%pretrans -n python-gluster -p <lua>
cb8e9e
+if not posix.access("/bin/bash", "x") then
cb8e9e
+    -- initial installation, no shell, no running glusterfsd
cb8e9e
+    return 0
cb8e9e
+end
cb8e9e
+
cb8e9e
+-- TODO: move this completely to a lua script
cb8e9e
+-- For now, we write a temporary bash script and execute that.
cb8e9e
+
cb8e9e
+script = [[#!/bin/sh
cb8e9e
+pidof -c -o %PPID -x glusterfsd &>/dev/null
cb8e9e
+
cb8e9e
+if [ $? -eq 0 ]; then
cb8e9e
+   pushd . > /dev/null 2>&1
cb8e9e
+   for volume in /var/lib/glusterd/vols/*; do cd $volume;
cb8e9e
+       vol_type=`grep '^type=' info | awk -F'=' '{print $2}'`
cb8e9e
+       volume_started=`grep '^status=' info | awk -F'=' '{print $2}'`
cb8e9e
+       if [ $vol_type -eq 0 ] && [ $volume_started -eq 1 ] ; then
cb8e9e
+          exit 1;
cb8e9e
+       fi
cb8e9e
+   done
cb8e9e
+
cb8e9e
+   popd > /dev/null 2>&1
cb8e9e
+   exit 1;
cb8e9e
+fi
cb8e9e
+]]
cb8e9e
+
cb8e9e
+-- rpm in RHEL5 does not have os.tmpname()
cb8e9e
+-- io.tmpfile() can not be resolved to a filename to pass to bash :-/
cb8e9e
+tmpname = "/tmp/python-gluster_pretrans_" .. os.date("%s")
cb8e9e
+tmpfile = io.open(tmpname, "w")
cb8e9e
+tmpfile:write(script)
cb8e9e
+tmpfile:close()
cb8e9e
+ok, how, val = os.execute("/bin/bash " .. tmpname)
cb8e9e
+os.remove(tmpname)
cb8e9e
+if not (ok == 0) then
cb8e9e
+   error("Detected running glusterfs processes", ok)
cb8e9e
+end
cb8e9e
+
cb8e9e
+
cb8e9e
+
cb8e9e
 %if ( 0%{!?_without_rdma:1} )
cb8e9e
 %pretrans rdma -p <lua>
cb8e9e
 if not posix.access("/bin/bash", "x") then
3604df
@@ -1865,6 +1988,10 @@ end
12a457
 * Tue Aug 18 2015 Niels de Vos <ndevos@redhat.com>
12a457
 - Include missing directories for glusterfind hooks scripts (#1225465)
cb8e9e
 
cb8e9e
+* Thu Jun 18 2015 Bala.FA <barumuga@redhat.com>
cb8e9e
+- add pretrans check for client-xlators, ganesha and python-gluster
cb8e9e
+  sub-packages (#1232641)
cb8e9e
+
cb8e9e
 * Thu Jun 18 2015 Niels de Vos <ndevos@redhat.com>
cb8e9e
 - glusterfs-devel for client-builds should not depend on -server (#1227029)
cb8e9e
 
cb8e9e
-- 
cb8e9e
1.7.1
cb8e9e