9f5ccc
From 562283ad34021bbf4fc540127ee7072d5152d34d Mon Sep 17 00:00:00 2001
9f5ccc
From: Yuval Turgeman <yturgema@redhat.com>
9f5ccc
Date: Wed, 24 Jul 2019 16:42:22 +0300
9f5ccc
Subject: [PATCH 336/336] spec: check and return exit code in rpm scripts
9f5ccc
9f5ccc
lua's error() call expects a value as its second argument, and this is
9f5ccc
taken from the `val` variable, while the `ok` is boolean.  This causes
9f5ccc
the rpm scripts to fail on:
9f5ccc
9f5ccc
bad argument #2 to 'error' (number expected, got boolean)
9f5ccc
9f5ccc
Label: DOWNSTREAM ONLY
9f5ccc
BUG: 1768786
9f5ccc
Change-Id: I9c6b1f62ebf15dbc93196d018bc1fd628b36fc33
9f5ccc
>Signed-off-by: Yuval Turgeman <yturgema@redhat.com>
9f5ccc
Reviewed-on: https://code.engineering.redhat.com/gerrit/186405
9f5ccc
Reviewed-by: Mohit Agrawal <moagrawa@redhat.com>
9f5ccc
Tested-by: RHGS Build Bot <nigelb@redhat.com>
9f5ccc
Reviewed-by: Sunil Kumar Heggodu Gopala Acharya <sheggodu@redhat.com>
9f5ccc
---
9f5ccc
 glusterfs.spec.in | 55 +++++++++++++++++++++++++++++++++----------------------
9f5ccc
 1 file changed, 33 insertions(+), 22 deletions(-)
9f5ccc
9f5ccc
diff --git a/glusterfs.spec.in b/glusterfs.spec.in
9f5ccc
index 91180db..1b975b2 100644
9f5ccc
--- a/glusterfs.spec.in
9f5ccc
+++ b/glusterfs.spec.in
9f5ccc
@@ -1572,8 +1572,9 @@ fi
9f5ccc
 ]]
9f5ccc
 
9f5ccc
 ok, how, val = os.execute(script)
9f5ccc
-if not (ok == 0) then
9f5ccc
-   error("Detected running glusterfs processes", ok)
9f5ccc
+rc = val or ok
9f5ccc
+if not (rc == 0) then
9f5ccc
+   error("Detected running glusterfs processes", rc)
9f5ccc
 end
9f5ccc
 
9f5ccc
 
9f5ccc
@@ -1606,8 +1607,9 @@ fi
9f5ccc
 ]]
9f5ccc
 
9f5ccc
 ok, how, val = os.execute(script)
9f5ccc
-if not (ok == 0) then
9f5ccc
-   error("Detected running glusterfs processes", ok)
9f5ccc
+rc = val or ok
9f5ccc
+if not (rc == 0) then
9f5ccc
+   error("Detected running glusterfs processes", rc)
9f5ccc
 end
9f5ccc
 
9f5ccc
 
9f5ccc
@@ -1640,8 +1642,9 @@ fi
9f5ccc
 ]]
9f5ccc
 
9f5ccc
 ok, how, val = os.execute(script)
9f5ccc
-if not (ok == 0) then
9f5ccc
-   error("Detected running glusterfs processes", ok)
9f5ccc
+rc = val or ok
9f5ccc
+if not (rc == 0) then
9f5ccc
+   error("Detected running glusterfs processes", rc)
9f5ccc
 end
9f5ccc
 
9f5ccc
 
9f5ccc
@@ -1674,8 +1677,9 @@ fi
9f5ccc
 ]]
9f5ccc
 
9f5ccc
 ok, how, val = os.execute(script)
9f5ccc
-if not (ok == 0) then
9f5ccc
-   error("Detected running glusterfs processes", ok)
9f5ccc
+rc = val or ok
9f5ccc
+if not (rc == 0) then
9f5ccc
+   error("Detected running glusterfs processes", rc)
9f5ccc
 end
9f5ccc
 
9f5ccc
 
9f5ccc
@@ -1707,8 +1711,9 @@ fi
9f5ccc
 ]]
9f5ccc
 
9f5ccc
 ok, how, val = os.execute(script)
9f5ccc
-if not (ok == 0) then
9f5ccc
-   error("Detected running glusterfs processes", ok)
9f5ccc
+rc = val or ok
9f5ccc
+if not (rc == 0) then
9f5ccc
+   error("Detected running glusterfs processes", rc)
9f5ccc
 end
9f5ccc
 
9f5ccc
 
9f5ccc
@@ -1740,8 +1745,9 @@ fi
9f5ccc
 ]]
9f5ccc
 
9f5ccc
 ok, how, val = os.execute(script)
9f5ccc
-if not (ok == 0) then
9f5ccc
-   error("Detected running glusterfs processes", ok)
9f5ccc
+rc = val or ok
9f5ccc
+if not (rc == 0) then
9f5ccc
+   error("Detected running glusterfs processes", rc)
9f5ccc
 end
9f5ccc
 
9f5ccc
 
9f5ccc
@@ -1775,8 +1781,9 @@ fi
9f5ccc
 ]]
9f5ccc
 
9f5ccc
 ok, how, val = os.execute(script)
9f5ccc
-if not (ok == 0) then
9f5ccc
-   error("Detected running glusterfs processes", ok)
9f5ccc
+rc = val or ok
9f5ccc
+if not (rc == 0) then
9f5ccc
+   error("Detected running glusterfs processes", rc)
9f5ccc
 end
9f5ccc
 %endif
9f5ccc
 
9f5ccc
@@ -1810,8 +1817,9 @@ fi
9f5ccc
 ]]
9f5ccc
 
9f5ccc
 ok, how, val = os.execute(script)
9f5ccc
-if not (ok == 0) then
9f5ccc
-   error("Detected running glusterfs processes", ok)
9f5ccc
+rc = val or ok
9f5ccc
+if not (rc == 0) then
9f5ccc
+   error("Detected running glusterfs processes", rc)
9f5ccc
 end
9f5ccc
 
9f5ccc
 
9f5ccc
@@ -1845,8 +1853,9 @@ fi
9f5ccc
 ]]
9f5ccc
 
9f5ccc
 ok, how, val = os.execute(script)
9f5ccc
-if not (ok == 0) then
9f5ccc
-   error("Detected running glusterfs processes", ok)
9f5ccc
+rc = val or ok
9f5ccc
+if not (rc == 0) then
9f5ccc
+   error("Detected running glusterfs processes", rc)
9f5ccc
 end
9f5ccc
 %endif
9f5ccc
 
9f5ccc
@@ -1881,8 +1890,9 @@ fi
9f5ccc
 ]]
9f5ccc
 
9f5ccc
 ok, how, val = os.execute(script)
9f5ccc
-if not (ok == 0) then
9f5ccc
-   error("Detected running glusterfs processes", ok)
9f5ccc
+rc = val or ok
9f5ccc
+if not (rc == 0) then
9f5ccc
+   error("Detected running glusterfs processes", rc)
9f5ccc
 end
9f5ccc
 %endif
9f5ccc
 
9f5ccc
@@ -1916,8 +1926,9 @@ fi
9f5ccc
 ]]
9f5ccc
 
9f5ccc
 ok, how, val = os.execute(script)
9f5ccc
-if not (ok == 0) then
9f5ccc
-   error("Detected running glusterfs processes", ok)
9f5ccc
+rc = val or ok
9f5ccc
+if not (rc == 0) then
9f5ccc
+   error("Detected running glusterfs processes", rc)
9f5ccc
 end
9f5ccc
 
9f5ccc
 %posttrans server
9f5ccc
-- 
9f5ccc
1.8.3.1
9f5ccc