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