This repository has been archived by the owner on May 6, 2020. It is now read-only.
-
Notifications
You must be signed in to change notification settings - Fork 11
/
linux-container.spec-template
125 lines (92 loc) · 2.99 KB
/
linux-container.spec-template
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
33
34
35
36
37
38
39
40
41
42
43
44
45
46
47
48
49
50
51
52
53
54
55
56
57
58
59
60
61
62
63
64
65
66
67
68
69
70
71
72
73
74
75
76
77
78
79
80
81
82
83
84
85
86
87
88
89
90
91
92
93
94
95
96
97
98
99
100
101
102
103
104
105
106
107
108
109
110
111
112
113
114
115
116
117
118
119
120
121
122
123
124
125
#
# 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.
#
Name: linux-container
Version: @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
Patch0001: 0001-HACK-9P-always-use-cached-inode-to-fill-in-v9fs_vfs_.patch
%description
The Linux kernel.
%package debug
Summary: Debug components for the linux-container package.
Group: Default
%description debug
Debug components for the linux-container package.
This package includes the kernel config and the kernel map.
%prep
%setup -q -n linux-@VERSION@
# Patches
%patch0001 -p1
cp %{SOURCE1} .
%build
BuildKernel() {
Arch=x86_64
ExtraVer="-%{release}.container"
perl -p -i -e "s/^EXTRAVERSION.*/EXTRAVERSION = ${ExtraVer}/" Makefile
make -s mrproper
cp config .config
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=x86_64
KernelVer=%{kversion}
KernelDir=%{buildroot}/usr/share/clear-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/x86/boot/bzImage vmlinux
rm -rf %{buildroot}/usr/lib/firmware
%files
%dir /usr/share/clear-containers
/usr/share/clear-containers/vmlinux-%{kversion}
/usr/share/clear-containers/vmlinux.container
/usr/share/clear-containers/vmlinuz-%{kversion}
/usr/share/clear-containers/vmlinuz.container
%files debug
%defattr(-,root,root,-)
/usr/share/clear-containers/config-%{kversion}
/usr/share/clear-containers/System.map-%{kversion}