Files
kata-containers/obs-packaging/linux-container/kata-linux-container.spec-template
Peng Tao 4338886211 obs-package: rename kernel to linux-container
We are using linux-container repo in the subproject.

Signed-off-by: Peng Tao <bergwolf@gmail.com>
2018-09-29 11:35:10 +08:00

134 lines
3.2 KiB
Plaintext

#
# This is a special configuration of the Linux kernel, aimed exclusively
# for running inside a container
# This specialization allows us to optimize memory footprint and boot time.
#
%define bzimage_arch x86
Name: kata-linux-container
Version: @VERSION@.@CONFIG_VERSION@
Release: @RELEASE@.<B_CNT>
License: GPL-2.0
Summary: The Linux kernel optimized for running inside a container
Url: http://www.kernel.org/
Group: kernel
Source0: https://cdn.kernel.org/pub/linux/kernel/v4.x/linux-@VERSION@.tar.xz
Source1: config
%define kversion %{version}-%{release}.container
BuildRequires: bash >= 2.03
BuildRequires: bc
BuildRequires: binutils-devel
%if 0%{?rhel_version}
BuildRequires: elfutils-devel
%endif
%if 0%{?suse_version}
BuildRequires: libelf-devel
%endif
%if 0%{?fedora} || 0%{?centos_version}
BuildRequires: pkgconfig(libelf)
%endif
BuildRequires: make >= 3.78
BuildRequires: openssl-devel
BuildRequires: flex
BuildRequires: bison
# don't strip .ko files!
%global __os_install_post %{nil}
%define debug_package %{nil}
%define __strip /bin/true
# Patches
@RPM_PATCH_LIST@
%description
The Linux kernel.
%package debug
Summary: Debug components for the kata-linux-container package.
Group: Default
%description debug
Debug components for the kata-linux-container package.
This package includes the kernel config and the kernel map.
%prep
%setup -q -n linux-@VERSION@
# Patches
@RPM_APPLY_PATCHES@
cp %{SOURCE1} .
%build
BuildKernel() {
Arch=%{_arch}
ExtraVer="-%{release}.container"
perl -p -i -e "s/^EXTRAVERSION.*/EXTRAVERSION = ${ExtraVer}/" Makefile
make -s mrproper
cp config .config
%if 0%{?fedora}
#Fedora uses gcc 8, build is failing due to warnings.
export CFLAGS="-Wno-error=restrict"
export EXTRA_CFLAGS="-Wno-format-truncation -Wno-cast-function-type -Wno-error=restrict -Wno-error"
%endif
make -s ARCH=$Arch oldconfig > /dev/null
make -s CONFIG_DEBUG_SECTION_MISMATCH=y %{?_smp_mflags} ARCH=$Arch %{?sparse_mflags} || exit 1
}
BuildKernel
%install
InstallKernel() {
KernelImage=$1
KernelImageRaw=$2
Arch=%{_arch}
KernelVer=%{kversion}
KernelDir=%{buildroot}/usr/share/kata-containers
mkdir -p ${KernelDir}
cp $KernelImage ${KernelDir}/vmlinuz-$KernelVer
chmod 755 ${KernelDir}/vmlinuz-$KernelVer
ln -sf vmlinuz-$KernelVer ${KernelDir}/vmlinuz.container
cp $KernelImageRaw ${KernelDir}/vmlinux-$KernelVer
chmod 755 ${KernelDir}/vmlinux-$KernelVer
ln -sf vmlinux-$KernelVer ${KernelDir}/vmlinux.container
cp .config "${KernelDir}/config-${KernelVer}"
cp System.map "${KernelDir}/System.map-${KernelVer}"
rm -f %{buildroot}/usr/lib/modules/$KernelVer/build
rm -f %{buildroot}/usr/lib/modules/$KernelVer/source
}
InstallKernel arch/%{bzimage_arch}/boot/bzImage vmlinux
rm -rf %{buildroot}/usr/lib/firmware
%files
%dir /usr/share/kata-containers
/usr/share/kata-containers/vmlinux-%{kversion}
/usr/share/kata-containers/vmlinux.container
/usr/share/kata-containers/vmlinuz-%{kversion}
/usr/share/kata-containers/vmlinuz.container
%files debug
%defattr(-,root,root,-)
/usr/share/kata-containers/config-%{kversion}
/usr/share/kata-containers/System.map-%{kversion}