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