From 8d9e40056220f73261c0410be14393c62d0298b1 Mon Sep 17 00:00:00 2001
From: Shuicheng Lin <shuicheng.lin@intel.com>
Date: Tue, 18 Feb 2020 15:41:52 +0800
Subject: [PATCH 3/4] customize 4.18 kernel with centos 7 build environment

1. change python3 to python2
2. fix compile issue with gcc-4.8.5
3. disable failure exit when do kernel install

Signed-off-by: Shuicheng Lin <shuicheng.lin@intel.com>
---
 SPECS/kernel.spec | 50 +++++++++++++++++++++++++++-----------------------
 1 file changed, 27 insertions(+), 23 deletions(-)

diff --git a/SPECS/kernel.spec b/SPECS/kernel.spec
index 8f3ee0f..7c773fc 100644
--- a/SPECS/kernel.spec
+++ b/SPECS/kernel.spec
@@ -113,6 +113,8 @@ Summary: The Linux kernel
 
 %define with_gcov %{?_with_gcov: 1} %{?!_with_gcov: 0}
 
+# STX
+
 # turn off debug kernel and kabichk for gcov builds
 %if %{with_gcov}
 %define with_debug 0
@@ -287,10 +289,10 @@ Requires: kernel-modules-uname-r = %{KVERREL}%{?variant}
 #
 BuildRequires: kmod, patch, bash, sh-utils, tar, git
 BuildRequires: bzip2, xz, findutils, gzip, m4, perl-interpreter, perl-Carp, perl-devel, perl-generators, make, diffutils, gawk
-BuildRequires: gcc, binutils, redhat-rpm-config, hmaccalc, python3-devel
+BuildRequires: gcc, binutils, redhat-rpm-config, hmaccalc, python2-devel
 BuildRequires: net-tools, hostname, bc, bison, flex, elfutils-devel
 %if %{with_doc}
-BuildRequires: xmlto, asciidoc, python3-sphinx
+BuildRequires: xmlto, asciidoc, python2-sphinx
 %endif
 %if %{with_sparse}
 BuildRequires: sparse
@@ -310,7 +312,7 @@ BuildRequires: pciutils-devel
 %endif
 %endif
 %if %{with_bpftool}
-BuildRequires: python3-docutils
+BuildRequires: python2-docutils
 BuildRequires: zlib-devel binutils-devel
 %endif
 %if %{with_bpf_samples}
@@ -443,6 +445,7 @@ Patch40008: intel-iommu-allow-ignoring-Ethernet-device-RMRR-with.patch
 Patch40022: US101216-IMA-support-in-Titanium-kernel.patch
 Patch40023: US103091-IMA-System-Configuration.patch
 Patch40026: turn-off-write-same-in-smartqpi-driver.patch
+Patch40027: Fix-compile-error-with-gcc-4.8.5.patch
 
 # END OF PATCH DEFINITIONS
 
@@ -549,24 +552,24 @@ This package provides debug information for the perf package.
 # of matching the pattern against the symlinks file.
 %{expand:%%global _find_debuginfo_opts %{?_find_debuginfo_opts} -p '.*%%{_bindir}/perf(\.debug)?|.*%%{_libexecdir}/perf-core/.*|.*%%{_libdir}/traceevent/plugins/.*|.*%%{_libdir}/libperf-jvmti.so(\.debug)?|XXX' -o perf-debuginfo.list}
 
-%package -n python3-perf
+%package -n python-perf
 Summary: Python bindings for apps which will manipulate perf events
 Group: Development/Libraries
-%description -n python3-perf
-The python3-perf package contains a module that permits applications
+%description -n python-perf
+The python-perf package contains a module that permits applications
 written in the Python programming language to use the interface
 to manipulate perf events.
 
-%package -n python3-perf-debuginfo
+%package -n python-perf-debuginfo
 Summary: Debug information for package perf python bindings
 Group: Development/Debug
 Requires: %{name}-debuginfo-common-%{_target_cpu} = %{version}-%{release}
 AutoReqProv: no
-%description -n python3-perf-debuginfo
+%description -n python-perf-debuginfo
 This package provides debug information for the perf python bindings.
 
 # the python_sitearch macro should already be defined from above
-%{expand:%%global _find_debuginfo_opts %{?_find_debuginfo_opts} -p '.*%%{python3_sitearch}/perf.*so(\.debug)?|XXX' -o python3-perf-debuginfo.list}
+%{expand:%%global _find_debuginfo_opts %{?_find_debuginfo_opts} -p '.*%%{python_sitearch}/perf.*so(\.debug)?|XXX' -o python-perf-debuginfo.list}
 
 
 %endif # with_perf
@@ -921,6 +924,7 @@ ApplyOptionalPatch intel-iommu-allow-ignoring-Ethernet-device-RMRR-with.patch
 ApplyOptionalPatch US101216-IMA-support-in-Titanium-kernel.patch
 ApplyOptionalPatch US103091-IMA-System-Configuration.patch
 ApplyOptionalPatch turn-off-write-same-in-smartqpi-driver.patch
+ApplyOptionalPatch Fix-compile-error-with-gcc-4.8.5.patch
 
 # END OF PATCH APPLICATIONS
 
@@ -938,15 +942,15 @@ touch .scmversion
 # script throws an error like below:
 # *** ERROR: ambiguous python shebang in /usr/bin/kvm_stat: #!/usr/bin/python. Change it to python3 (or python2) explicitly.
 # We patch all sources below for which we got a report/error.
-pathfix.py -i %{__python3} -p -n \
-	tools/kvm/kvm_stat/kvm_stat \
-	scripts/show_delta \
-	scripts/diffconfig \
-	scripts/bloat-o-meter \
-	tools/perf/tests/attr.py \
-	tools/perf/scripts/python/stat-cpi.py \
-	tools/perf/scripts/python/sched-migration.py \
-	Documentation
+#pathfix.py -i %{__python3} -p -n \
+#	tools/kvm/kvm_stat/kvm_stat \
+#	scripts/show_delta \
+#	scripts/diffconfig \
+#	scripts/bloat-o-meter \
+#	tools/perf/tests/attr.py \
+#	tools/perf/scripts/python/stat-cpi.py \
+#	tools/perf/scripts/python/sched-migration.py \
+#	Documentation
 
 # only deal with configs if we are going to build for the arch
 %ifnarch %nobuildarches
@@ -1521,7 +1525,7 @@ BuildKernel %make_target %kernel_image %{with_vdso_install}
 %endif
 
 %global perf_make \
-  make EXTRA_CFLAGS="${RPM_OPT_FLAGS}" LDFLAGS="%{__global_ldflags}" %{?cross_opts} -C tools/perf V=1 NO_PERF_READ_VDSO32=1 NO_PERF_READ_VDSOX32=1 WERROR=0 NO_LIBUNWIND=1 HAVE_CPLUS_DEMANGLE=1 NO_GTK2=1 NO_STRLCPY=1 NO_BIONIC=1 prefix=%{_prefix} PYTHON=%{__python3}
+  make EXTRA_CFLAGS="${RPM_OPT_FLAGS}" LDFLAGS="%{__global_ldflags}" %{?cross_opts} -C tools/perf V=1 NO_PERF_READ_VDSO32=1 NO_PERF_READ_VDSOX32=1 WERROR=0 NO_LIBUNWIND=1 HAVE_CPLUS_DEMANGLE=1 NO_GTK2=1 NO_STRLCPY=1 NO_BIONIC=1 prefix=%{_prefix} PYTHON=%{__python}
 %if %{with_perf}
 # perf
 # make sure check-headers.sh is executable
@@ -1888,7 +1892,7 @@ if [ $1 -gt 1 ] ; then\
 fi\
 if [ -x %{_sbindir}/weak-modules ]\
 then\
-    %{_sbindir}/weak-modules --add-kernel %{KVERREL}%{?1:+%{1}} || exit $?\
+    %{_sbindir}/weak-modules --add-kernel %{KVERREL}%{?1:+%{1}} \
 fi\
 /bin/kernel-install add %{KVERREL}%{?1:+%{1}} /lib/modules/%{KVERREL}%{?1:+%{1}}/vmlinuz || exit $?\
 %{nil}
@@ -1993,15 +1997,15 @@ fi
 %{_sysconfdir}/bash_completion.d/perf
 %doc linux-%{KVERREL}/tools/perf/Documentation/examples.txt
 
-%files -n python3-perf
+%files -n python-perf
 %defattr(-,root,root)
-%{python3_sitearch}/*
+%{python_sitearch}/*
 
 %if %{with_debuginfo}
 %files -f perf-debuginfo.list -n perf-debuginfo
 %defattr(-,root,root)
 
-%files -f python3-perf-debuginfo.list -n python3-perf-debuginfo
+%files -f python-perf-debuginfo.list -n python-perf-debuginfo
 %defattr(-,root,root)
 %endif
 %endif # with_perf
-- 
2.7.4

