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