From 841d94b830e459fac13d9ad9bb165723014e59af Mon Sep 17 00:00:00 2001 From: Johnny Hughes Date: Dec 09 2019 20:21:56 +0000 Subject: Modify to build on el7 for aarch64 and power 9 --- diff --git a/SPECS/kernel.spec b/SPECS/kernel.spec index d4d080e..fb347a7 100644 --- a/SPECS/kernel.spec +++ b/SPECS/kernel.spec @@ -168,6 +168,10 @@ %define with_bpftool 0 %endif +%if %{?rhel}<=7 +%define with_kabichk 0 +%endif + # turn off kABI DUP check and DWARF-based check if kABI check is disabled %if !%{with_kabichk} %define with_kabidupchk 0 @@ -199,6 +203,10 @@ %define all_arch_configs kernel-%{version}-*.config %endif +%if 0%{?rhel} == 7 +%define with_bootwrapper 0 +%endif + # sparse blows up on ppc %ifnarch ppc64le %define with_sparse 0 @@ -228,6 +236,9 @@ %define make_target vmlinux %define kernel_image vmlinux %define kernel_image_elf 1 +%if 0%{?rhel} == 7 +%define with_bootwrapper 1 +%endif %define all_arch_configs kernel-%{version}-ppc64le*.config %define kcflags -O3 %endif @@ -275,7 +286,11 @@ # Packages that need to be installed before the kernel is, because the %%post # scripts use them. # +%if 0%{?rhel} == 7 +%define kernel_prereq fileutils, module-init-tools >= 3.16-2, initscripts >= 8.11.1-1, grubby >= 8.28-2 +%else %define kernel_prereq coreutils, systemd >= 203-2, /usr/bin/kernel-install +%endif %define initrd_prereq dracut >= 027 @@ -300,8 +315,19 @@ Requires: kernel-modules-uname-r = %{KVERREL}%{?variant} # List the packages used during the kernel build # BuildRequires: kmod, patch, bash, sh-utils, tar, git +%if 0%{?rhel} == 7 +BuildRequires: bzip2, xz, findutils, gzip, m4, perl-interpreter, perl-Carp, perl-devel, perl, make, diffutils, gawk, python-devel, python2-rpm-macros +%else BuildRequires: bzip2, xz, findutils, gzip, m4, perl-interpreter, perl-Carp, perl-devel, perl-generators, make, diffutils, gawk +%endif BuildRequires: gcc, binutils, redhat-rpm-config, hmaccalc, python3-devel +%if 0%{?rhel} == 7 +BuildRequires: devtoolset-8-build +BuildRequires: devtoolset-8-binutils +BuildRequires: devtoolset-8-gcc +BuildRequires: devtoolset-8-make +BuildRequires: python3-rpm-macros +%endif BuildRequires: net-tools, hostname, bc, bison, flex, elfutils-devel %if %{with_doc} BuildRequires: xmlto, asciidoc, python3-sphinx @@ -324,12 +350,20 @@ BuildRequires: pciutils-devel %endif %endif %if %{with_bpftool} +%if %{?rhel}>7 BuildRequires: python3-docutils +%else +BuildRequires: python-docutils +%endif BuildRequires: zlib-devel binutils-devel %endif %if %{with_selftests} +%if 0%{?rhel} == 7 +BuildRequires: libcap-devel libcap-ng-devel llvm-toolset-7.0 numactl-devel rsync +%else BuildRequires: libcap-devel libcap-ng-devel llvm-toolset numactl-devel rsync %endif +%endif BuildConflicts: rhbuildsys(DiskFree) < 500Mb %if %{with_debuginfo} BuildRequires: rpm-build, elfutils @@ -580,24 +614,57 @@ 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} +%if 0%{?rhel} == 7 +%package -n python-perf +%else %package -n python3-perf +%endif Summary: Python bindings for apps which will manipulate perf events Group: Development/Libraries +%if 0%{?rhel} == 7 +%description -n python-perf +The python-perf package contains a module that permits applications +%else %description -n python3-perf The python3-perf package contains a module that permits applications +%endif written in the Python programming language to use the interface to manipulate perf events. +%if 0%{?rhel} == 7 +%package -n python-perf-debuginfo +%else %package -n python3-perf-debuginfo +%endif Summary: Debug information for package perf python bindings Group: Development/Debug Requires: %{name}-debuginfo-common-%{_target_cpu} = %{version}-%{release} AutoReqProv: no +%if 0%{?rhel} == 7 +%description -n python-perf-debuginfo +%else %description -n python3-perf-debuginfo +%endif This package provides debug information for the perf python bindings. +%if 0%{?rhel} == 7 +%if %{with_bootwrapper} +%package bootwrapper +Summary: Boot wrapper files for generating combined kernel + initrd images +Group: Development/System +Requires: gzip binutils +%description bootwrapper +kernel-bootwrapper contains the wrapper code which makes bootable "zImage" +files combining both kernel and initial ramdisk. +%endif +%endif + # the python_sitearch macro should already be defined from above +%if 0%{?rhel} == 7 +%{expand:%%global _find_debuginfo_opts %{?_find_debuginfo_opts} -p '.*%%{python_sitearch}/perf.*so(\.debug)?|XXX' -o python-perf-debuginfo.list} +%else %{expand:%%global _find_debuginfo_opts %{?_find_debuginfo_opts} -p '.*%%{python3_sitearch}/perf.*so(\.debug)?|XXX' -o python3-perf-debuginfo.list} +%endif %endif # with_perf @@ -913,6 +980,11 @@ input and output, etc. %endif %prep +%if 0%{?rhel} == 7 +source scl_source enable devtoolset-8 || : +source scl_source enable llvm-toolset-7.0 || : +%endif + # do a few sanity-checks for --with *only builds %if %{with_baseonly} %if !%{with_up} @@ -979,6 +1051,9 @@ ApplyOptionalPatch debrand-single-cpu.patch ApplyOptionalPatch debrand-rh_taint.patch #ApplyOptionalPatch debrand-rh-i686-cpu.patch +%if 0%{?rhel} == 7 +sed -i 's/strip_size=.*/strip_size=$(stat -c %s $vmz.$$)/g' arch/powerpc/boot/wrapper +%endif # END OF PATCH APPLICATIONS @@ -990,6 +1065,7 @@ mv COPYING COPYING-%{version} # This Prevents scripts/setlocalversion from mucking with our version numbers. touch .scmversion +%if 0%{?rhel}>7 # Do not use "ambiguous" python shebangs. RHEL 8 now has a new script # (/usr/lib/rpm/redhat/brp-mangle-shebangs), which forces us to specify a # "non-ambiguous" python shebang for scripts we ship in buildroot. This @@ -1004,6 +1080,7 @@ pathfix.py -i %{__python3} -p -n \ tools/perf/scripts/python/stat-cpi.py \ tools/perf/scripts/python/sched-migration.py \ Documentation +%endif %define make make %{?cross_opts} HOSTCFLAGS="%{?build_hostcflags}" HOSTLDFLAGS="%{?build_hostldflags}" @@ -1058,6 +1135,10 @@ cd .. ### build ### %build +%if 0%{?rhel} == 7 +source scl_source enable devtoolset-8 || : +source scl_source enable llvm-toolset-7.0 || : +%endif %if %{with_sparse} %define sparse_mflags C=1 @@ -1600,8 +1681,13 @@ BuildKernel %make_target %kernel_image %{with_vdso_install} zfcpdump BuildKernel %make_target %kernel_image %{with_vdso_install} %endif +%if 0%{?rhel} == 7 +%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=%{__python} +%else %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} +%endif %if %{with_perf} # perf # make sure check-headers.sh is executable @@ -1744,6 +1830,10 @@ find Documentation -type d | xargs chmod u+w ### %install +%if 0%{?rhel} == 7 +source scl_source enable devtoolset-8 || : +source scl_source enable llvm-toolset-7.0 || : +%endif cd linux-%{KVERREL} @@ -1866,6 +1956,7 @@ popd pushd tools/iio %{tools_make} DESTDIR=%{buildroot} install popd +%if 0%{?rhel} > 7 pushd tools/gpio %{tools_make} DESTDIR=%{buildroot} install popd @@ -1874,6 +1965,7 @@ make INSTALL_ROOT=%{buildroot} install-tools make INSTALL_ROOT=%{buildroot} install-man popd %endif +%endif %if %{with_bpftool} pushd tools/bpf/bpftool @@ -1933,6 +2025,11 @@ HEADERS_CHKSUM=$(export LC_ALL=C; find $RPM_BUILD_ROOT/usr/include -type f -name # find-provides can grab the hash to update it accordingly echo "#define KERNEL_HEADERS_CHECKSUM \"$HEADERS_CHKSUM\"" >> $RPM_BUILD_ROOT/usr/include/linux/version.h %endif +%if 0%{?rhel} == 7 +%if %{with_bootwrapper} +make %{?cross_opts} ARCH=%{hdrarch} DESTDIR=$RPM_BUILD_ROOT bootwrapper_install WRAPPER_OBJDIR=%{_libdir}/kernel-wrapper WRAPPER_DTSDIR=%{_libdir}/kernel-wrapper/dts +%endif +%endif ### ### clean @@ -2015,6 +2112,17 @@ fi\ # %%kernel_variant_posttrans [] # More text can follow to go at the end of this variant's %%post. # +%if 0%{?rhel} == 7 +%define kernel_variant_posttrans() \ +%{expand:%%posttrans %{?1:%{1}-}core}\ +if [ -x %{_sbindir}/weak-modules ]\ +then\ + %{_sbindir}/weak-modules --add-kernel %{KVERREL}%{?1:.%{1}} || exit $?\ +fi\ +%{_sbindir}/new-kernel-pkg --package kernel%{?-v:-%{-v*}} --mkinitrd --dracut --depmod --update %{KVERREL}%{?-v:.%{-v*}} || exit $?\ +%{_sbindir}/new-kernel-pkg --package kernel%{?1:-%{1}} --rpmposttrans %{KVERREL}%{?1:.%{1}} || exit $?\ +%{nil} +%else %define kernel_variant_posttrans() \ %{expand:%%posttrans %{?1:%{1}-}core}\ if [ -x %{_sbindir}/weak-modules ]\ @@ -2023,6 +2131,7 @@ then\ fi\ /bin/kernel-install add %{KVERREL}%{?1:+%{1}} /lib/modules/%{KVERREL}%{?1:+%{1}}/vmlinuz || exit $?\ %{nil} +%endif # # This macro defines a %%post script for a kernel package and its devel package. @@ -2041,12 +2150,27 @@ if [ `uname -i` == "x86_64" -o `uname -i` == "i386" ] &&\ [ -f /etc/sysconfig/kernel ]; then\ /bin/sed -r -i -e 's/^DEFAULTKERNEL=%{-r*}$/DEFAULTKERNEL=kernel%{?-v:-%{-v*}}/' /etc/sysconfig/kernel || exit $?\ fi}\ +%if 0%{?rhel} == 7 \ +%{expand:\ +%{_sbindir}/new-kernel-pkg --package kernel%{?-v:-%{-v*}} --install %{KVERREL}%{?-v:.%{-v*}} || exit $?\ +}\ +%endif \ %{nil} # # This macro defines a %%preun script for a kernel package. # %%kernel_variant_preun # +%if 0%{?rhel} == 7 +%define kernel_variant_preun() \ +%{expand:%%preun %{?1:%{1}-}core}\ +%{_sbindir}/new-kernel-pkg --rminitrd --rmmoddep --remove %{KVERREL}%{?1:.%{1}} || exit $?\ +if [ -x %{_sbindir}/weak-modules ]\ +then\ + %{_sbindir}/weak-modules --remove-kernel %{KVERREL}%{?1:.%{1}} || exit $?\ +fi\ +%{nil} +%else %define kernel_variant_preun() \ %{expand:%%preun %{?1:%{1}-}core}\ /bin/kernel-install remove %{KVERREL}%{?1:+%{1}} /lib/modules/%{KVERREL}%{?1:+%{1}}/vmlinuz || exit $?\ @@ -2055,6 +2179,7 @@ then\ %{_sbindir}/weak-modules --remove-kernel %{KVERREL}%{?1:+%{1}} || exit $?\ fi\ %{nil} +%endif %kernel_variant_preun %kernel_variant_post -r kernel-smp @@ -2126,15 +2251,25 @@ fi %doc linux-%{KVERREL}/tools/perf/Documentation/examples.txt %{_docdir}/perf-tip/tips.txt +%if 0%{?rhel} == 7 +%files -n python-perf +%defattr(-,root,root) +%{python_sitearch}/* +%else %files -n python3-perf %defattr(-,root,root) %{python3_sitearch}/* +%endif %if %{with_debuginfo} %files -f perf-debuginfo.list -n perf-debuginfo %defattr(-,root,root) +%if 0%{?rhel} == 7 +%files -f python-perf-debuginfo.list -n python-perf-debuginfo +%else %files -f python3-perf-debuginfo.list -n python3-perf-debuginfo +%endif %defattr(-,root,root) %endif %endif # with_perf @@ -2165,11 +2300,13 @@ fi %{_bindir}/iio_event_monitor %{_bindir}/iio_generic_buffer %{_bindir}/lsiio +%if 0%{?rhel} > 7 %{_bindir}/lsgpio %{_bindir}/gpio-hammer %{_bindir}/gpio-event-mon %{_mandir}/man1/kvm_stat* %{_bindir}/kvm_stat +%endif %if %{with_debuginfo} %files -f kernel-tools-debuginfo.list -n kernel-tools-debuginfo @@ -2212,6 +2349,16 @@ fi %{_libexecdir}/kselftests %endif +%if 0%{?rhel} == 7 +%if %{with_bootwrapper} +%files bootwrapper +%defattr(-,root,root) +/usr/sbin/* +%exclude /usr/sbin/bpftool +%{_libdir}/kernel-wrapper +%endif +%endif + # empty meta-package %ifnarch %nobuildarches noarch %files @@ -2242,20 +2389,35 @@ fi %{!?_licensedir:%global license %%doc}\ %license linux-%{KVERREL}/COPYING-%{version}\ /lib/modules/%{KVERREL}%{?3:+%{3}}/%{?-k:%{-k*}}%{!?-k:vmlinuz}\ +%if 0%{?rhel} == 7\ +/%{image_install_path}/%{?-k:%{-k*}}%{!?-k:vmlinuz}-%{KVERREL}%{?3:+%{3}}\ +/lib/modules/%{KVERREL}%{?3:+%{3}}/.vmlinuz.hmac \ +/%{image_install_path}/.vmlinuz-%{KVERREL}%{?3:+%{3}}.hmac \ +%else\ %ghost /%{image_install_path}/%{?-k:%{-k*}}%{!?-k:vmlinuz}-%{KVERREL}%{?3:+%{3}}\ /lib/modules/%{KVERREL}%{?3:+%{3}}/.vmlinuz.hmac \ %ghost /%{image_install_path}/.vmlinuz-%{KVERREL}%{?3:+%{3}}.hmac \ +%endif\ %ifarch aarch64\ /lib/modules/%{KVERREL}%{?3:+%{3}}/dtb \ %ghost /%{image_install_path}/dtb-%{KVERREL}%{?3:+%{3}} \ %endif\ %attr(0600, root, root) /lib/modules/%{KVERREL}%{?3:+%{3}}/System.map\ +%if 0%{?rhel} == 7\ +/boot/System.map-%{KVERREL}%{?3:+%{3}}\ +%else\ %ghost %attr(0600, root, root) /boot/System.map-%{KVERREL}%{?3:+%{3}}\ +%endif\ /lib/modules/%{KVERREL}%{?3:+%{3}}/symvers.gz\ /lib/modules/%{KVERREL}%{?3:+%{3}}/config\ +%if 0%{?rhel} == 7\ +/boot/symvers-%{KVERREL}%{?3:+%{3}}.gz\ +/boot/config-%{KVERREL}%{?3:+%{3}}\ +%else\ %ghost %attr(0600, root, root) /boot/symvers-%{KVERREL}%{?3:+%{3}}.gz\ -%ghost %attr(0600, root, root) /boot/initramfs-%{KVERREL}%{?3:+%{3}}.img\ %ghost %attr(0644, root, root) /boot/config-%{KVERREL}%{?3:+%{3}}\ +%endif\ +%ghost %attr(0600, root, root) /boot/initramfs-%{KVERREL}%{?3:+%{3}}.img\ %dir /lib/modules\ %dir /lib/modules/%{KVERREL}%{?3:+%{3}}\ %dir /lib/modules/%{KVERREL}%{?3:+%{3}}/kernel\