forked from clearlinux-pkgs/linux
-
Notifications
You must be signed in to change notification settings - Fork 0
/
Copy pathlinux.spec
274 lines (224 loc) · 8.54 KB
/
linux.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
161
162
163
164
165
166
167
168
169
170
171
172
173
174
175
176
177
178
179
180
181
182
183
184
185
186
187
188
189
190
191
192
193
194
195
196
197
198
199
200
201
202
203
204
205
206
207
208
209
210
211
212
213
214
215
216
217
218
219
220
221
222
223
224
225
226
227
228
229
230
231
232
233
234
235
236
237
238
239
240
241
242
243
244
245
246
247
248
249
250
251
252
253
254
255
256
257
258
259
260
261
262
263
264
265
266
267
268
269
270
271
272
273
274
#
# note to self: Linus releases need to be named 5.x.0 not 5.x or various
# things break
#
#
Name: linux
Version: 5.12.13
Release: 1050
License: GPL-2.0
Summary: The Linux kernel
Url: http://www.kernel.org/
Group: kernel
Source0: https://cdn.kernel.org/pub/linux/kernel/v5.x/linux-5.12.13.tar.xz
Source1: config
Source2: cmdline
%define ktarget native
%define kversion %{version}-%{release}.%{ktarget}
BuildRequires: buildreq-kernel
Requires: systemd-bin
Requires: init-rdahead-extras
Requires: linux-license = %{version}-%{release}
# don't strip .ko files!
%global __os_install_post %{nil}
%define debug_package %{nil}
%define __strip /bin/true
#cve.start cve patches from 0001 to 050
#cve.end
#mainline: Mainline patches, upstream backport and fixes from 0051 to 0099
#mainline.end
#Serie.clr 01XX: Clear Linux patches
Patch0101: 0101-i8042-decrease-debug-message-level-to-info.patch
Patch0102: 0102-increase-the-ext4-default-commit-age.patch
Patch0103: 0103-silence-rapl.patch
Patch0104: 0104-pci-pme-wakeups.patch
Patch0105: 0105-ksm-wakeups.patch
Patch0106: 0106-intel_idle-tweak-cpuidle-cstates.patch
Patch0107: 0107-bootstats-add-printk-s-to-measure-boot-time-in-more-.patch
Patch0108: 0108-smpboot-reuse-timer-calibration.patch
Patch0109: 0109-initialize-ata-before-graphics.patch
Patch0110: 0110-give-rdrand-some-credit.patch
Patch0111: 0111-ipv4-tcp-allow-the-memory-tuning-for-tcp-to-go-a-lit.patch
Patch0112: 0112-init-wait-for-partition-and-retry-scan.patch
Patch0113: 0113-print-fsync-count-for-bootchart.patch
Patch0114: 0114-add-boot-option-to-allow-unsigned-modules.patch
Patch0115: 0115-enable-stateless-firmware-loading.patch
Patch0116: 0116-migrate-some-systemd-defaults-to-the-kernel-defaults.patch
Patch0117: 0117-xattr-allow-setting-user.-attributes-on-symlinks-by-.patch
Patch0118: 0118-add-scheduler-turbo3-patch.patch
Patch0119: 0119-use-lfence-instead-of-rep-and-nop.patch
Patch0120: 0120-do-accept-in-LIFO-order-for-cache-efficiency.patch
Patch0121: 0121-locking-rwsem-spin-faster.patch
Patch0122: 0122-ata-libahci-ignore-staggered-spin-up.patch
Patch0123: 0123-print-CPU-that-faults.patch
Patch0124: 0124-x86-microcode-Force-update-a-uCode-even-if-the-rev-i.patch
Patch0125: 0125-x86-microcode-echo-2-reload-to-force-load-ucode.patch
Patch0126: 0126-fix-bug-in-ucode-force-reload-revision-check.patch
Patch0127: 0127-nvme-workaround.patch
Patch0128: 0128-don-t-report-an-error-if-PowerClamp-run-on-other-CPU.patch
#Serie.end
%description
The Linux kernel.
%package extra
License: GPL-2.0
Summary: The Linux kernel extra files
Group: kernel
Requires: linux-license = %{version}-%{release}
%description extra
Linux kernel extra files
%package license
Summary: license components for the linux package.
Group: Default
%description license
license components for the linux package.
%package cpio
License: GPL-2.0
Summary: cpio file with kenrel modules
Group: kernel
%description cpio
Creates a cpio file with some modules
%package dev
License: GPL-2.0
Summary: The Linux kernel
Group: kernel
Requires: linux = %{version}-%{release}
Requires: linux-extra = %{version}-%{release}
Requires: linux-license = %{version}-%{release}
%description dev
Linux kernel build files
%prep
%setup -q -n linux-5.12.13
#cve.patch.start cve patches
#cve.patch.end
#mainline.patch.start Mainline patches, upstream backport and fixes
#mainline.patch.end
#Serie.patch.start Clear Linux patches
%patch0101 -p1
%patch0102 -p1
%patch0103 -p1
%patch0104 -p1
%patch0105 -p1
%patch0106 -p1
%patch0107 -p1
%patch0108 -p1
%patch0109 -p1
%patch0110 -p1
%patch0111 -p1
%patch0112 -p1
%patch0113 -p1
%patch0114 -p1
%patch0115 -p1
%patch0116 -p1
%patch0117 -p1
%patch0118 -p1
%patch0119 -p1
%patch0120 -p1
%patch0121 -p1
%patch0122 -p1
%patch0123 -p1
%patch0124 -p1
%patch0125 -p1
%patch0126 -p1
%patch0127 -p1
%patch0128 -p1
#Serie.patch.end
cp %{SOURCE1} .
%build
BuildKernel() {
Target=$1
Arch=x86_64
ExtraVer="-%{release}.${Target}"
perl -p -i -e "s/^EXTRAVERSION.*/EXTRAVERSION = ${ExtraVer}/" Makefile
make O=${Target} -s mrproper
cp config ${Target}/.config
make O=${Target} -s ARCH=${Arch} olddefconfig
make O=${Target} -s ARCH=${Arch} CONFIG_DEBUG_SECTION_MISMATCH=y %{?_smp_mflags} %{?sparse_mflags}
}
BuildKernel %{ktarget}
%install
InstallKernel() {
Target=$1
Kversion=$2
Arch=x86_64
KernelDir=%{buildroot}/usr/lib/kernel
DevDir=%{buildroot}/usr/lib/modules/${Kversion}/build
mkdir -p ${KernelDir}
install -m 644 ${Target}/.config ${KernelDir}/config-${Kversion}
install -m 644 ${Target}/System.map ${KernelDir}/System.map-${Kversion}
install -m 644 ${Target}/vmlinux ${KernelDir}/vmlinux-${Kversion}
install -m 644 %{SOURCE2} ${KernelDir}/cmdline-${Kversion}
cp ${Target}/arch/x86/boot/bzImage ${KernelDir}/org.clearlinux.${Target}.%{version}-%{release}
chmod 755 ${KernelDir}/org.clearlinux.${Target}.%{version}-%{release}
mkdir -p %{buildroot}/usr/lib/modules
make O=${Target} -s ARCH=${Arch} INSTALL_MOD_PATH=%{buildroot}/usr modules_install
rm -f %{buildroot}/usr/lib/modules/${Kversion}/build
rm -f %{buildroot}/usr/lib/modules/${Kversion}/source
mkdir -p ${DevDir}
find . -type f -a '(' -name 'Makefile*' -o -name 'Kbuild*' -o -name 'Kconfig*' ')' -exec cp -t ${DevDir} --parents -pr {} +
find . -type f -a '(' -name '*.sh' -o -name '*.pl' ')' -exec cp -t ${DevDir} --parents -pr {} +
cp -t ${DevDir} -pr ${Target}/{Module.symvers,tools}
ln -s ../../../kernel/config-${Kversion} ${DevDir}/.config
ln -s ../../../kernel/System.map-${Kversion} ${DevDir}/System.map
cp -t ${DevDir} --parents -pr arch/x86/include
cp -t ${DevDir}/arch/x86/include -pr ${Target}/arch/x86/include/*
cp -t ${DevDir}/include -pr include/*
cp -t ${DevDir}/include -pr ${Target}/include/*
cp -t ${DevDir} --parents -pr scripts/*
cp -t ${DevDir}/scripts -pr ${Target}/scripts/*
find ${DevDir}/scripts -type f -name '*.[cho]' -exec rm -v {} +
find ${DevDir} -type f -name '*.cmd' -exec rm -v {} +
# Cleanup any dangling links
find ${DevDir} -type l -follow -exec rm -v {} +
# Kernel default target link
ln -s org.clearlinux.${Target}.%{version}-%{release} %{buildroot}/usr/lib/kernel/default-${Target}
}
# cpio file for keyboard drivers
createCPIO() {
Target=$1
Kversion=$2
KernelDir=%{buildroot}/usr/lib/kernel
ModDir=/usr/lib/modules/${Kversion}
mkdir -p cpiofile${ModDir}/kernel/drivers/input/{serio,keyboard}
mkdir -p cpiofile${ModDir}/kernel/drivers/hid
cp %{buildroot}${ModDir}/kernel/drivers/input/serio/i8042.ko cpiofile${ModDir}/kernel/drivers/input/serio
cp %{buildroot}${ModDir}/kernel/drivers/input/serio/libps2.ko cpiofile${ModDir}/kernel/drivers/input/serio
cp %{buildroot}${ModDir}/kernel/drivers/input/keyboard/atkbd.ko cpiofile${ModDir}/kernel/drivers/input/keyboard
cp %{buildroot}${ModDir}/kernel/drivers/hid/hid-logitech-dj.ko cpiofile${ModDir}/kernel/drivers/hid
cp %{buildroot}${ModDir}/kernel/drivers/hid/hid-logitech-hidpp.ko cpiofile${ModDir}/kernel/drivers/hid
cp %{buildroot}${ModDir}/kernel/drivers/hid/hid-apple.ko cpiofile${ModDir}/kernel/drivers/hid
cp %{buildroot}${ModDir}/modules.order cpiofile${ModDir}
cp %{buildroot}${ModDir}/modules.builtin cpiofile${ModDir}
depmod -b cpiofile/usr ${Kversion}
(
cd cpiofile
find . | cpio --create --format=newc \
| xz --check=crc32 --lzma2=dict=512KiB > ${KernelDir}/initrd-org.clearlinux.${Target}.%{version}-%{release}
)
}
InstallKernel %{ktarget} %{kversion}
createCPIO %{ktarget} %{kversion}
rm -rf %{buildroot}/usr/lib/firmware
mkdir -p %{buildroot}/usr/share/package-licenses/linux
cp COPYING %{buildroot}/usr/share/package-licenses/linux/COPYING
cp -a LICENSES/* %{buildroot}/usr/share/package-licenses/linux
%files
%dir /usr/lib/kernel
%dir /usr/lib/modules/%{kversion}
/usr/lib/kernel/config-%{kversion}
/usr/lib/kernel/cmdline-%{kversion}
/usr/lib/kernel/org.clearlinux.%{ktarget}.%{version}-%{release}
/usr/lib/kernel/default-%{ktarget}
/usr/lib/modules/%{kversion}/kernel
/usr/lib/modules/%{kversion}/modules.*
%files extra
%dir /usr/lib/kernel
/usr/lib/kernel/System.map-%{kversion}
/usr/lib/kernel/vmlinux-%{kversion}
%files license
%defattr(0644,root,root,0755)
/usr/share/package-licenses/linux
%files cpio
/usr/lib/kernel/initrd-org.clearlinux.%{ktarget}.%{version}-%{release}
%files dev
%defattr(-,root,root)
/usr/lib/modules/%{kversion}/build