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