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