From 125b16157ec53db61958be0b8255fcc3ba3ce7a6 Mon Sep 17 00:00:00 2001
From: Long Li <lilong-neu@neusoft.com>
Date: Thu, 26 Dec 2019 10:33:29 +0800
Subject: [PATCH] CentOS8: Redfishtool should use python3

change python to python3 explicitly to fix RPM build

Story: 2006729
Task: 37899

Change-Id: Iea9a056950d836541ce7ce316cbf817971d77c70
Signed-off-by: Long Li <lilong-neu@neusoft.com>
---
 bmc/Redfishtool/centos/redfishtool.spec       | 12 ++++---
 ...-Change-python-to-python3-explicitly.patch | 34 +++++++++++++++++++
 2 files changed, 41 insertions(+), 5 deletions(-)
 create mode 100644 bmc/Redfishtool/files/0002-Change-python-to-python3-explicitly.patch

diff --git a/bmc/Redfishtool/centos/redfishtool.spec b/bmc/Redfishtool/centos/redfishtool.spec
index baf27c59f..5f8c00225 100644
--- a/bmc/Redfishtool/centos/redfishtool.spec
+++ b/bmc/Redfishtool/centos/redfishtool.spec
@@ -19,29 +19,31 @@ Source0: %{name}-%{version}.tar.gz
 BuildArch: noarch
 
 Patch01: 0001-Adapt-redfishtool-to-python2.patch
+Patch02: 0002-Change-python-to-python3-explicitly.patch
 
-BuildRequires: python-setuptools
+BuildRequires: python3-setuptools
 
-Requires:      python-requests
+Requires:      python3-requests
 
 %description
 Redfish Tool Package
 
-%define pythonroot           /usr/lib64/python2.7/site-packages
+%define pythonroot           %python3_sitearch
 %define debug_package %{nil}
 
 %prep
 %setup
 %patch01 -p1
+%patch02 -p1
 
 # Remove bundled egg-info
 rm -rf *.egg-info
 
 %build
-%{__python} setup.py build
+%{__python3} setup.py build
 
 %install
-%{__python} setup.py install --root=%{buildroot} \
+%{__python3} setup.py install --root=%{buildroot} \
                              --install-lib=%{pythonroot} \
                              --prefix=/usr \
                              --install-data=/usr/share \
diff --git a/bmc/Redfishtool/files/0002-Change-python-to-python3-explicitly.patch b/bmc/Redfishtool/files/0002-Change-python-to-python3-explicitly.patch
new file mode 100644
index 000000000..4818450cb
--- /dev/null
+++ b/bmc/Redfishtool/files/0002-Change-python-to-python3-explicitly.patch
@@ -0,0 +1,34 @@
+From 820ad50e1d2e013ff7835ab3acb3809f5eee3d8e Mon Sep 17 00:00:00 2001
+From: Long Li <lilong-neu@neusoft.com>
+Date: Thu, 26 Dec 2019 09:53:28 +0800
+Subject: [PATCH] Change python to python3 explicitly
+
+Signed-off-by: Long Li <lilong-neu@neusoft.com>
+---
+ redfishtool.py      | 2 +-
+ scripts/redfishtool | 2 +-
+ 2 files changed, 2 insertions(+), 2 deletions(-)
+
+diff --git a/redfishtool.py b/redfishtool.py
+index b7b1b3c..7f585ab 100644
+--- a/redfishtool.py
++++ b/redfishtool.py
+@@ -1,4 +1,4 @@
+-#!/usr/bin/python
++#!/usr/bin/python3
+ # Copyright Notice:
+ # Copyright 2016 DMTF. All rights reserved.
+ # License: BSD 3-Clause License. For full text see link: https://github.com/DMTF/Redfishtool/blob/master/LICENSE.md
+diff --git a/scripts/redfishtool b/scripts/redfishtool
+index 3bc1eb0..7bed4fe 100644
+--- a/scripts/redfishtool
++++ b/scripts/redfishtool
+@@ -1,4 +1,4 @@
+-#!/usr/bin/python
++#!/usr/bin/python3
+ # Copyright Notice:
+ # Copyright 2016 DMTF. All rights reserved.
+ # License: BSD 3-Clause License. For full text see link: https://github.com/DMTF/Redfishtool/blob/master/LICENSE.md
+-- 
+1.8.3.1
+