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