233933
From f054086daf4549a6227196fe37a57a7e49aa5849 Mon Sep 17 00:00:00 2001
233933
From: "Bala.FA" <barumuga@redhat.com>
233933
Date: Fri, 7 Dec 2018 14:13:40 +0530
233933
Subject: [PATCH 12/52] build: add pretrans check
233933
233933
This patch adds pretrans check for client-xlators
233933
233933
NOTE: ganesha and python-gluster sub-packages are now obsolete
233933
233933
Label: DOWNSTREAM ONLY
233933
233933
Change-Id: I454016319832c11902c0ca79a79fbbcf8ac0a121
233933
Signed-off-by: Bala.FA <barumuga@redhat.com>
233933
Reviewed-on: https://code.engineering.redhat.com/gerrit/50967
233933
Reviewed-on: https://code.engineering.redhat.com/gerrit/60140
233933
Tested-by: Milind Changire <mchangir@redhat.com>
233933
---
233933
 glusterfs.spec.in | 39 +++++++++++++++++++++++++++++++++++++++
233933
 1 file changed, 39 insertions(+)
233933
233933
diff --git a/glusterfs.spec.in b/glusterfs.spec.in
233933
index 1c631db..a1ff6e0 100644
233933
--- a/glusterfs.spec.in
233933
+++ b/glusterfs.spec.in
233933
@@ -1704,6 +1704,45 @@ if not (ok == 0) then
233933
 end
233933
 
233933
 
233933
+%pretrans client-xlators -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-client-xlators_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
 %pretrans devel -p <lua>
233933
 if not posix.access("/bin/bash", "x") then
233933
-- 
233933
1.8.3.1
233933