233933
From 4f471c25dad4d7d51443005108ec53c2d390daf5 Mon Sep 17 00:00:00 2001
233933
From: Sunil Kumar Acharya <sheggodu@redhat.com>
233933
Date: Fri, 14 Jun 2019 20:20:26 +0530
233933
Subject: [PATCH 191/192] Build: Update python shebangs based on version
233933
233933
RHEL 7 uses python2 where as RHEL 8 uses python 3.
233933
Updating the spec file to use appropriate shebangs
233933
to avoid script failures.
233933
233933
Label : DOWNSTREAM ONLY
233933
233933
BUG: 1719640
233933
Change-Id: I075764b6a00ba53a305451e3fc58584facd75a78
233933
Signed-off-by: Sunil Kumar Acharya <sheggodu@redhat.com>
233933
Reviewed-on: https://code.engineering.redhat.com/gerrit/173518
233933
Tested-by: RHGS Build Bot <nigelb@redhat.com>
233933
Reviewed-by: Hari Gowtham Gopal <hgowtham@redhat.com>
233933
Reviewed-by: Atin Mukherjee <amukherj@redhat.com>
233933
---
233933
 glusterfs.spec.in | 12 ++++++++----
233933
 1 file changed, 8 insertions(+), 4 deletions(-)
233933
233933
diff --git a/glusterfs.spec.in b/glusterfs.spec.in
233933
index 0127e8e..29e4a37 100644
233933
--- a/glusterfs.spec.in
233933
+++ b/glusterfs.spec.in
233933
@@ -722,11 +722,15 @@ GlusterFS Events
233933
 
233933
 %prep
233933
 %setup -q -n %{name}-%{version}%{?prereltag}
233933
-%if ( ! %{_usepython3} )
233933
 echo "fixing python shebangs..."
233933
-for f in api events extras geo-replication libglusterfs tools xlators; do
233933
-find $f -type f -exec sed -i 's|/usr/bin/python3|/usr/bin/python2|' {} \;
233933
-done
233933
+%if ( %{_usepython3} )
233933
+    for i in `find . -type f -exec bash -c "if file {} | grep 'Python script, ASCII text executable' >/dev/null; then echo {}; fi" ';'`; do
233933
+        sed -i -e 's|^#!/usr/bin/python.*|#!%{__python3}|' -e 's|^#!/usr/bin/env python.*|#!%{__python3}|' $i
233933
+    done
233933
+%else
233933
+    for f in api events extras geo-replication libglusterfs tools xlators; do
233933
+        find $f -type f -exec sed -i 's|/usr/bin/python3|/usr/bin/python2|' {} \;
233933
+    done
233933
 %endif
233933
 
233933
 %build
233933
-- 
233933
1.8.3.1
233933