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