14f8ab
From f054086daf4549a6227196fe37a57a7e49aa5849 Mon Sep 17 00:00:00 2001
14f8ab
From: "Bala.FA" <barumuga@redhat.com>
14f8ab
Date: Fri, 7 Dec 2018 14:13:40 +0530
14f8ab
Subject: [PATCH 12/52] build: add pretrans check
14f8ab
14f8ab
This patch adds pretrans check for client-xlators
14f8ab
14f8ab
NOTE: ganesha and python-gluster sub-packages are now obsolete
14f8ab
14f8ab
Label: DOWNSTREAM ONLY
14f8ab
14f8ab
Change-Id: I454016319832c11902c0ca79a79fbbcf8ac0a121
14f8ab
Signed-off-by: Bala.FA <barumuga@redhat.com>
14f8ab
Reviewed-on: https://code.engineering.redhat.com/gerrit/50967
14f8ab
Reviewed-on: https://code.engineering.redhat.com/gerrit/60140
14f8ab
Tested-by: Milind Changire <mchangir@redhat.com>
14f8ab
---
14f8ab
 glusterfs.spec.in | 39 +++++++++++++++++++++++++++++++++++++++
14f8ab
 1 file changed, 39 insertions(+)
14f8ab
14f8ab
diff --git a/glusterfs.spec.in b/glusterfs.spec.in
14f8ab
index 1c631db..a1ff6e0 100644
14f8ab
--- a/glusterfs.spec.in
14f8ab
+++ b/glusterfs.spec.in
14f8ab
@@ -1704,6 +1704,45 @@ if not (ok == 0) then
14f8ab
 end
14f8ab
 
14f8ab
 
14f8ab
+%pretrans client-xlators -p <lua>
14f8ab
+if not posix.access("/bin/bash", "x") then
14f8ab
+    -- initial installation, no shell, no running glusterfsd
14f8ab
+    return 0
14f8ab
+end
14f8ab
+
14f8ab
+-- TODO: move this completely to a lua script
14f8ab
+-- For now, we write a temporary bash script and execute that.
14f8ab
+
14f8ab
+script = [[#!/bin/sh
14f8ab
+pidof -c -o %PPID -x glusterfsd &>/dev/null
14f8ab
+
14f8ab
+if [ $? -eq 0 ]; then
14f8ab
+   pushd . > /dev/null 2>&1
14f8ab
+   for volume in /var/lib/glusterd/vols/*; do cd $volume;
14f8ab
+       vol_type=`grep '^type=' info | awk -F'=' '{print $2}'`
14f8ab
+       volume_started=`grep '^status=' info | awk -F'=' '{print $2}'`
14f8ab
+       if [ $vol_type -eq 0 ] && [ $volume_started -eq 1 ] ; then
14f8ab
+          exit 1;
14f8ab
+       fi
14f8ab
+   done
14f8ab
+
14f8ab
+   popd > /dev/null 2>&1
14f8ab
+   exit 1;
14f8ab
+fi
14f8ab
+]]
14f8ab
+
14f8ab
+-- rpm in RHEL5 does not have os.tmpname()
14f8ab
+-- io.tmpfile() can not be resolved to a filename to pass to bash :-/
14f8ab
+tmpname = "/tmp/glusterfs-client-xlators_pretrans_" .. os.date("%s")
14f8ab
+tmpfile = io.open(tmpname, "w")
14f8ab
+tmpfile:write(script)
14f8ab
+tmpfile:close()
14f8ab
+ok, how, val = os.execute("/bin/bash " .. tmpname)
14f8ab
+os.remove(tmpname)
14f8ab
+if not (ok == 0) then
14f8ab
+   error("Detected running glusterfs processes", ok)
14f8ab
+end
14f8ab
+
14f8ab
 
14f8ab
 %pretrans devel -p <lua>
14f8ab
 if not posix.access("/bin/bash", "x") then
14f8ab
-- 
14f8ab
1.8.3.1
14f8ab