forked from bottlerocket-os/bottlerocket
-
Notifications
You must be signed in to change notification settings - Fork 0
/
Copy pathkernel.spec
160 lines (136 loc) · 4.71 KB
/
kernel.spec
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
126
127
128
129
130
131
132
133
134
135
136
137
138
139
140
141
142
143
144
145
146
147
148
149
150
151
152
153
154
155
156
157
158
159
160
%global debug_package %{nil}
Name: %{_cross_os}kernel
Version: 5.4.16
Release: 1%{?dist}
Summary: The Linux kernel
License: GPL-2.0 WITH Linux-syscall-note
URL: https://www.kernel.org/
# Use latest-srpm-url.sh to get this.
Source0: https://cdn.amazonlinux.com/blobstore/8a2ede840234ebc72d835fab144162ba8184b8aa7df163a5d36aad2d3c85529b/kernel-5.4.16-8.72.amzn2.src.rpm
Source100: config-bottlerocket
Patch0001: 0001-lustrefsx-Disable-Werror-stringop-overflow.patch
BuildRequires: bc
BuildRequires: elfutils-devel
BuildRequires: hostname
BuildRequires: kmod
BuildRequires: openssl-devel
%global kernel_sourcedir %{_cross_usrsrc}/kernels
%global kernel_libdir %{_cross_libdir}/modules/%{version}
%description
%{summary}.
%package devel
Summary: Configured Linux kernel source for module building
Requires: %{_cross_os}filesystem
%description devel
%{summary}.
%package modules
Summary: Modules for the Linux kernel
%description modules
%{summary}.
%package headers
Summary: Header files for the Linux kernel for use by glibc
%description headers
%{summary}.
%prep
rpm2cpio %{SOURCE0} | cpio -iu linux-%{version}.tar config-%{_cross_arch} "*.patch"
tar -xof linux-%{version}.tar; rm linux-%{version}.tar
%setup -TDn linux-%{version}
# Patches from the Source0 SRPM
for patch in ../*.patch; do
patch -p1 <"$patch"
done
# Patches listed in this spec (Patch0001...)
%autopatch -p1
KCONFIG_CONFIG="arch/%{_cross_karch}/configs/%{_cross_vendor}_defconfig" \
ARCH="%{_cross_karch}" \
scripts/kconfig/merge_config.sh ../config-%{_cross_arch} %{SOURCE100}
rm -f ../config-%{_cross_arch} ../*.patch
%global kmake \
make -s\\\
ARCH="%{_cross_karch}"\\\
CROSS_COMPILE="%{_cross_target}-"\\\
INSTALL_HDR_PATH="%{buildroot}%{_cross_prefix}"\\\
INSTALL_MOD_PATH="%{buildroot}%{_cross_prefix}"\\\
INSTALL_MOD_STRIP=1\\\
%{nil}
%build
%kmake mrproper
%kmake %{_cross_vendor}_defconfig
%kmake %{?_smp_mflags} %{_cross_kimage}
%kmake %{?_smp_mflags} modules
%install
%kmake headers_install
%kmake modules_install
install -d %{buildroot}/boot
install -T -m 0755 arch/%{_cross_karch}/boot/%{_cross_kimage} %{buildroot}/boot/vmlinuz
install -m 0644 .config %{buildroot}/boot/config
install -m 0644 System.map %{buildroot}/boot/System.map
find %{buildroot}%{_cross_prefix} \
\( -name .install -o -name .check -o \
-name ..install.cmd -o -name ..check.cmd \) -delete
# files for external module compilation
(
find * -name Kbuild\* -type f -print \
-o -name Kconfig\* -type f -print \
-o -name Makefile\* -type f -print \
-o -name module.lds -type f -print \
-o -name Platform -type f -print
find arch/*/include/ include/ -type f -o -type l
find scripts/ -executable -type f
find scripts/ ! \( -name Makefile\* -o -name Kbuild\* \) -type f
echo .config
echo Module.symvers
echo System.map
) | sort -u > kernel_devel_files
# remove x86 intermediate files like generated/asm/.syscalls_32.h.cmd
sed -i '/asm\/.*\.cmd$/d' kernel_devel_files
## Create squashfs of kernel-devel files (ie. /usr/src/kernels/<version>)
mkdir src_squashfs
for file in $(cat kernel_devel_files); do
install -D ${file} src_squashfs/%{version}/${file}
done
mksquashfs src_squashfs kernel-devel.squashfs
install -D kernel-devel.squashfs %{buildroot}%{_cross_datadir}/bottlerocket/kernel-devel.squashfs
install -d %{buildroot}%{kernel_sourcedir}
# Replace the incorrect links from modules_install. These will be bound
# into a host container (and unused in the host) so they must not point
# to %{_cross_usrsrc} (eg. /x86_64-bottlerocket-linux-gnu/sys-root/...)
rm -f %{buildroot}%{kernel_libdir}/build %{buildroot}%{kernel_libdir}/source
ln -sf %{_usrsrc}/kernels/%{version} %{buildroot}%{kernel_libdir}/build
ln -sf %{_usrsrc}/kernels/%{version} %{buildroot}%{kernel_libdir}/source
%files
%license COPYING LICENSES/preferred/GPL-2.0 LICENSES/exceptions/Linux-syscall-note
%{_cross_attribution_file}
/boot/vmlinuz
/boot/config
/boot/System.map
%files modules
%dir %{_cross_libdir}/modules
%{_cross_libdir}/modules/*
%files headers
%dir %{_cross_includedir}/asm
%dir %{_cross_includedir}/asm-generic
%dir %{_cross_includedir}/drm
%dir %{_cross_includedir}/linux
%dir %{_cross_includedir}/misc
%dir %{_cross_includedir}/mtd
%dir %{_cross_includedir}/rdma
%dir %{_cross_includedir}/scsi
%dir %{_cross_includedir}/sound
%dir %{_cross_includedir}/video
%dir %{_cross_includedir}/xen
%{_cross_includedir}/asm/*
%{_cross_includedir}/asm-generic/*
%{_cross_includedir}/drm/*
%{_cross_includedir}/linux/*
%{_cross_includedir}/misc/*
%{_cross_includedir}/mtd/*
%{_cross_includedir}/rdma/*
%{_cross_includedir}/scsi/*
%{_cross_includedir}/sound/*
%{_cross_includedir}/video/*
%{_cross_includedir}/xen/*
%files devel
%dir %{kernel_sourcedir}
%{_cross_datadir}/bottlerocket/kernel-devel.squashfs
%changelog