rpm: ignore CMakeCache.txt in dist and relax BuildRequires on cross build

CPack takes the source dir as is, so if it was used to build something
it will incorrectly grab the temporary CMakeCache file and cmake will
complain during rpmbuild later on.

The BuildRequires should be a separate patch but logic behind the change
is that the dependencies need to be installed in the sysroot, and
rpmbuild cannot test this, so just move them all to only enforce
BuildRequires for native build.

And while we are here, also add a new kernel_dir specfile option.

Change-Id: Ie67932798f632e6d307f8ead93bdbe043e6e8898
This commit is contained in:
Dominique Martinet
2019-02-27 17:05:02 +09:00
committed by Dominique Martinet
parent 69846345de
commit fb3f1c58a8
3 changed files with 20 additions and 14 deletions

5
.gitignore vendored
View File

@@ -33,3 +33,8 @@ executer/user/libmcexec.a
executer/user/libldump2mcdump.so executer/user/libldump2mcdump.so
executer/user/eclair executer/user/eclair
tools/mcstat/mcstat tools/mcstat/mcstat
/_CPack_Packages
/CPackSourceConfig.cmake
CPackConfig.cmake
/build
mckernel-*.tar.gz

View File

@@ -187,7 +187,7 @@ install(FILES "${CMAKE_CURRENT_BINARY_DIR}/mcreboot.1"
configure_file(scripts/mckernel.spec.in scripts/mckernel.spec @ONLY) configure_file(scripts/mckernel.spec.in scripts/mckernel.spec @ONLY)
set(CPACK_SOURCE_PACKAGE_FILE_NAME "${CMAKE_PROJECT_NAME}-${MCKERNEL_VERSION}") set(CPACK_SOURCE_PACKAGE_FILE_NAME "${CMAKE_PROJECT_NAME}-${MCKERNEL_VERSION}")
set(CPACK_SOURCE_IGNORE_FILES "/.git$") set(CPACK_SOURCE_IGNORE_FILES "/.git/;/build;/CMakeCache.txt$;/CMakeFiles$;/Makefile$")
set(CPACK_SOURCE_INSTALLED_DIRECTORIES "${CMAKE_SOURCE_DIR};/;${IHK_FULL_SOURCE_DIR};/ihk;${CMAKE_BINARY_DIR}/scripts;/scripts") set(CPACK_SOURCE_INSTALLED_DIRECTORIES "${CMAKE_SOURCE_DIR};/;${IHK_FULL_SOURCE_DIR};/ihk;${CMAKE_BINARY_DIR}/scripts;/scripts")
set(CPACK_SOURCE_GENERATOR "TGZ") set(CPACK_SOURCE_GENERATOR "TGZ")
include(CPack) include(CPack)

View File

@@ -2,13 +2,14 @@
# cmake /path/to/mckernel && make dist # cmake /path/to/mckernel && make dist
# rpmbuild -ta mckernel-@MCKERNEL_VERSION@.tar.gz # rpmbuild -ta mckernel-@MCKERNEL_VERSION@.tar.gz
# #
# for cross compilation also pass the following to rpmbuild: # for cross compilation also pass at least the following to rpmbuild:
# --target aarch64 -D 'kernel_version <target kernel>' # --target aarch64 -D 'kernel_version <target kernel>'
# you will need to install the target's kernel-devel package (rpm -i --ignorearch) # you will need to setup your your environment as per
# and have your environment setup as per cmake/README.cross_compilation # cmake/README.cross_compilation
%{!?kernel_version: %define kernel_version @UNAME_R@} %{!?kernel_version: %global kernel_version @UNAME_R@}
%{!?kernel_dir: %global kernel_dir /usr/src/kernels/%{kernel_version}}
%define krequires %(echo %{kernel_version} | sed "s/.%{_target_cpu}$//") %define krequires %(echo %{kernel_version} | sed "s/.%{_target_cpu}$//")
%define ktag %(echo %{krequires} | tr '-' '_' | sed -e 's/\.el[0-9]*$//' | sed -e 's/\.\([a-zA-Z]\)/_\1/') %define ktag %(echo %{krequires} | tr '-' '_' | sed -e 's/\.el[0-9]*$//' | sed -e 's/\.\([a-zA-Z]\)/_\1/')
@@ -19,9 +20,6 @@ Summary: IHK/McKernel
License: GPLv2 License: GPLv2
Source0: mckernel-%{version}.tar.gz Source0: mckernel-%{version}.tar.gz
BuildRequires: systemd-devel numactl-devel binutils-devel kernel-devel
BuildRequires: %kernel_module_package_buildreqs = %{krequires}
# kernel_module_package macro does not handle cross build... # kernel_module_package macro does not handle cross build...
%if "%{?_host_cpu}" == "x86_64" && "%{?_target_cpu}" == "aarch64" %if "%{?_host_cpu}" == "x86_64" && "%{?_target_cpu}" == "aarch64"
%define cross_compile 1 %define cross_compile 1
@@ -29,6 +27,9 @@ Requires: kernel = %{krequires}
Requires(post): /usr/sbin/depmod Requires(post): /usr/sbin/depmod
Requires(postun): /usr/sbin/depmod Requires(postun): /usr/sbin/depmod
%else %else
BuildRequires: systemd-devel numactl-devel binutils-devel kernel-devel
BuildRequires: %kernel_module_package_buildreqs = %{krequires}
%kernel_module_package %{?kmod_flavors} %kernel_module_package %{?kmod_flavors}
%endif %endif
@@ -40,9 +41,9 @@ Interface for Heterogeneous Kernels and McKernel.
%build %build
%if 0%{?cross_compile} %if 0%{?cross_compile}
%{!?toolchain_file: %define toolchain_file cmake/cross-aarch64.cmake} %{!?toolchain_file: %global toolchain_file cmake/cross-aarch64.cmake}
%{!?build_target: %define build_target smp-arm64} %{!?build_target: %global build_target smp-arm64}
%{!?cmake_libdir: %define cmake_libdir /usr/lib64} %{!?cmake_libdir: %global cmake_libdir /usr/lib64}
%endif %endif
# We need to remove ld flags like relro for the final mckernel.img link, as well as remove cflags for mckernel # We need to remove ld flags like relro for the final mckernel.img link, as well as remove cflags for mckernel
@@ -51,10 +52,10 @@ Interface for Heterogeneous Kernels and McKernel.
%define optflags -O2 -g -pipe -Wall -Wp,-D_FORTIFY_SOURCE=2 -fexceptions --param=ssp-buffer-size=4 -grecord-gcc-switches -mtune=generic %define optflags -O2 -g -pipe -Wall -Wp,-D_FORTIFY_SOURCE=2 -fexceptions --param=ssp-buffer-size=4 -grecord-gcc-switches -mtune=generic
%cmake -DCMAKE_BUILD_TYPE=Release \ %cmake -DCMAKE_BUILD_TYPE=Release \
%{?kernel_version:-DUNAME_R=%{kernel_version}} \ -DUNAME_R=%{kernel_version} \
%{?kernel_version:-DKERNEL_DIR=/usr/src/kernels/%{kernel_version}} \ -DKERNEL_DIR=%{kernel_dir} \
%{?cmake_libdir:-DCMAKE_INSTALL_LIBDIR=%{cmake_libdir}} \ %{?cmake_libdir:-DCMAKE_INSTALL_LIBDIR=%{cmake_libdir}} \
%{?build_target:-DBUILD_TARGET=%{build_target}} \ %{?build_target:-DBUILD_TARGET=%{build_target}} \
%{?toolchain_file:-DCMAKE_TOOLCHAIN_FILE=%{toolchain_file}} \ %{?toolchain_file:-DCMAKE_TOOLCHAIN_FILE=%{toolchain_file}} \
. .
%make_build %make_build