Blob Blame History Raw
From a701c96f94fb1c868566f7b3ad54b9e67b9ed211 Mon Sep 17 00:00:00 2001
From: Bala.FA <barumuga@redhat.com>
Date: Wed, 17 Jun 2015 21:34:52 +0530
Subject: [PATCH 098/101] build: add pretrans check

This patch adds pretrans check for client-xlators, ganesha and
python-gluster sub-packages.

Label: DOWNSTREAM ONLY

Bug: 1232641
Change-Id: I454016319832c11902c0ca79a79fbbcf8ac0a121
Signed-off-by: Bala.FA <barumuga@redhat.com>
Reviewed-on: https://code.engineering.redhat.com/gerrit/50967
---
 glusterfs.spec.in |  127 +++++++++++++++++++++++++++++++++++++++++++++++++++++
 1 files changed, 127 insertions(+), 0 deletions(-)

diff --git a/glusterfs.spec.in b/glusterfs.spec.in
index 388c28c..e4d9d5f 100644
--- a/glusterfs.spec.in
+++ b/glusterfs.spec.in
@@ -1512,6 +1512,47 @@ end
 
 
 
+%pretrans client-xlators -p <lua>
+if not posix.access("/bin/bash", "x") then
+    -- initial installation, no shell, no running glusterfsd
+    return 0
+end
+
+-- TODO: move this completely to a lua script
+-- For now, we write a temporary bash script and execute that.
+
+script = [[#!/bin/sh
+pidof -c -o %PPID -x glusterfsd &>/dev/null
+
+if [ $? -eq 0 ]; then
+   pushd . > /dev/null 2>&1
+   for volume in /var/lib/glusterd/vols/*; do cd $volume;
+       vol_type=`grep '^type=' info | awk -F'=' '{print $2}'`
+       volume_started=`grep '^status=' info | awk -F'=' '{print $2}'`
+       if [ $vol_type -eq 0 ] && [ $volume_started -eq 1 ] ; then
+          exit 1;
+       fi
+   done
+
+   popd > /dev/null 2>&1
+   exit 1;
+fi
+]]
+
+-- rpm in RHEL5 does not have os.tmpname()
+-- io.tmpfile() can not be resolved to a filename to pass to bash :-/
+tmpname = "/tmp/glusterfs-client-xlators_pretrans_" .. os.date("%s")
+tmpfile = io.open(tmpname, "w")
+tmpfile:write(script)
+tmpfile:close()
+ok, how, val = os.execute("/bin/bash " .. tmpname)
+os.remove(tmpname)
+if not (ok == 0) then
+   error("Detected running glusterfs processes", ok)
+end
+
+
+
 %pretrans devel -p <lua>
 if not posix.access("/bin/bash", "x") then
     -- initial installation, no shell, no running glusterfsd
@@ -1594,6 +1635,47 @@ end
 
 
 
+%pretrans ganesha -p <lua>
+if not posix.access("/bin/bash", "x") then
+    -- initial installation, no shell, no running glusterfsd
+    return 0
+end
+
+-- TODO: move this completely to a lua script
+-- For now, we write a temporary bash script and execute that.
+
+script = [[#!/bin/sh
+pidof -c -o %PPID -x glusterfsd &>/dev/null
+
+if [ $? -eq 0 ]; then
+   pushd . > /dev/null 2>&1
+   for volume in /var/lib/glusterd/vols/*; do cd $volume;
+       vol_type=`grep '^type=' info | awk -F'=' '{print $2}'`
+       volume_started=`grep '^status=' info | awk -F'=' '{print $2}'`
+       if [ $vol_type -eq 0 ] && [ $volume_started -eq 1 ] ; then
+          exit 1;
+       fi
+   done
+
+   popd > /dev/null 2>&1
+   exit 1;
+fi
+]]
+
+-- rpm in RHEL5 does not have os.tmpname()
+-- io.tmpfile() can not be resolved to a filename to pass to bash :-/
+tmpname = "/tmp/glusterfs-ganesha_pretrans_" .. os.date("%s")
+tmpfile = io.open(tmpname, "w")
+tmpfile:write(script)
+tmpfile:close()
+ok, how, val = os.execute("/bin/bash " .. tmpname)
+os.remove(tmpname)
+if not (ok == 0) then
+   error("Detected running glusterfs processes", ok)
+end
+
+
+
 %if ( 0%{!?_without_georeplication:1} )
 %pretrans geo-replication -p <lua>
 if not posix.access("/bin/bash", "x") then
@@ -1678,6 +1760,47 @@ end
 
 
 
+%pretrans -n python-gluster -p <lua>
+if not posix.access("/bin/bash", "x") then
+    -- initial installation, no shell, no running glusterfsd
+    return 0
+end
+
+-- TODO: move this completely to a lua script
+-- For now, we write a temporary bash script and execute that.
+
+script = [[#!/bin/sh
+pidof -c -o %PPID -x glusterfsd &>/dev/null
+
+if [ $? -eq 0 ]; then
+   pushd . > /dev/null 2>&1
+   for volume in /var/lib/glusterd/vols/*; do cd $volume;
+       vol_type=`grep '^type=' info | awk -F'=' '{print $2}'`
+       volume_started=`grep '^status=' info | awk -F'=' '{print $2}'`
+       if [ $vol_type -eq 0 ] && [ $volume_started -eq 1 ] ; then
+          exit 1;
+       fi
+   done
+
+   popd > /dev/null 2>&1
+   exit 1;
+fi
+]]
+
+-- rpm in RHEL5 does not have os.tmpname()
+-- io.tmpfile() can not be resolved to a filename to pass to bash :-/
+tmpname = "/tmp/python-gluster_pretrans_" .. os.date("%s")
+tmpfile = io.open(tmpname, "w")
+tmpfile:write(script)
+tmpfile:close()
+ok, how, val = os.execute("/bin/bash " .. tmpname)
+os.remove(tmpname)
+if not (ok == 0) then
+   error("Detected running glusterfs processes", ok)
+end
+
+
+
 %if ( 0%{!?_without_rdma:1} )
 %pretrans rdma -p <lua>
 if not posix.access("/bin/bash", "x") then
@@ -1805,6 +1928,10 @@ end
 %endif
 
 %changelog
+* Thu Jun 18 2015 Bala.FA <barumuga@redhat.com>
+- add pretrans check for client-xlators, ganesha and python-gluster
+  sub-packages (#1232641)
+
 * Thu Jun 18 2015 Niels de Vos <ndevos@redhat.com>
 - glusterfs-devel for client-builds should not depend on -server (#1227029)
 
-- 
1.7.1