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