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