forked from TechNexion/linux
-
Notifications
You must be signed in to change notification settings - Fork 0
/
Copy pathkernel-image.spec
347 lines (277 loc) · 10.5 KB
/
kernel-image.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
275
276
277
278
279
280
281
282
283
284
285
286
287
288
289
290
291
292
293
294
295
296
297
298
299
300
301
302
303
304
305
306
307
308
309
310
311
312
313
314
315
316
317
318
319
320
321
322
323
324
325
326
327
328
329
330
331
332
333
334
335
336
337
338
339
340
341
342
343
344
345
346
347
%def_disable check
Name: kernel-image-pico-imx8mq
Release: alt3
%define kernel_need_version 5.4
# Used when kernel-source-x.y does not currently exist in repository.
%define kernel_base_version 5.4
%define kernel_sublevel .70
%define kernel_extra_version %nil
# kernel version is need version
Version: %kernel_need_version%kernel_sublevel%kernel_extra_version
# Numeric extra version scheme developed by Alexander Bokovoy:
# 0.0.X -- preX
# 0.X.0 -- rcX
# 1.0.0 -- release
%define kernel_extra_version_numeric 1.0.0
%define krelease %release
%define flavour %( s='%name'; printf %%s "${s#kernel-image-}" )
%define base_flavour %( s='%flavour'; printf %%s "${s%%%%-*}" )
%define sub_flavour %( s='%flavour'; printf %%s "${s#*-}" )
# Build options
# You can change compiler version by editing this line:
%define kgcc_version %__gcc_version_base
%def_disable docs
%def_disable domU
#Remove oss
%def_disable oss
## Don't edit below this line ##################################
%define kversion %kernel_need_version%kernel_sublevel%kernel_extra_version
%define modules_dir /lib/modules/%kversion-%flavour-%krelease
%define kheaders_dir %_prefix/include/linux-%kversion-%flavour
%define kbuild_dir %_prefix/src/linux-%kversion-%flavour-%krelease
%define old_kbuild_dir %_prefix/src/linux-%kversion-%flavour
%brp_strip_none /boot/*
Summary: The Linux kernel (the core of the Linux operating system)
License: GPL
Group: System/Kernel and hardware
Url: http://www.kernel.org/
Packager: Kernel Maintainers Team <kernel@packages.altlinux.org>
Patch0: %name-%version-%release.patch
ExclusiveArch: aarch64
%define make_target Image
%define image_path arch/%base_arch/boot/%make_target
%define arch_dir %base_arch
%define kvm_modules_dir arch/%arch_dir/kvm
%define qemu_pkg %_arch
ExclusiveOS: Linux
BuildRequires(pre): rpm-build-kernel
BuildRequires: flex
BuildRequires: libdb4-devel
BuildRequires: gcc%kgcc_version gcc%kgcc_version-c++
BuildRequires: gcc%kgcc_version-plugin-devel libgmp-devel libmpc-devel
BuildRequires: kernel-source-%kernel_base_version = %kernel_extra_version_numeric
BuildRequires: module-init-tools >= 3.16
BuildRequires: lzma-utils
BuildRequires: libelf-devel
BuildRequires: bc
BuildRequires: rsync
BuildRequires: openssl-devel
%if_enabled ccache
BuildRequires: ccache
%endif
%ifdef use_ccache
BuildRequires: ccache
%endif
Requires: bootloader-utils >= 0.4.24-alt1
Requires: module-init-tools >= 3.1
Requires: mkinitrd >= 1:2.9.9-alt1
Requires: startup >= 0.8.3-alt1
Provides: kernel = %kversion
Requires(pre): coreutils
Requires(pre): module-init-tools >= 3.1
Requires(pre): mkinitrd >= 1:2.9.9-alt1
%description
This package contains the Linux kernel that is used to boot and run
TechNexion PICO IMX8MQ board
%package -n kernel-headers-%flavour
Summary: Header files for the Linux kernel
Group: Development/Kernel
Requires: kernel-headers-common >= 1.1.5
Provides: kernel-headers = %version
%description -n kernel-headers-%flavour
This package makes Linux kernel headers corresponding to the Linux
kernel package %name-%version-%release available for building
userspace programs (if this version of headers is selected by
adjust_kernel_headers).
Since Linux 2.6.18 the kernel build system supports creation of
sanitized kernel headers for use in userspace (by deleting headers
which are not usable in userspace and removing #ifdef __KERNEL__
blocks from installed headers). This package contains sanitized
headers instead of raw kernel headers which were present in some
previous versions of similar packages.
If possible, try to use glibc-kernheaders instead of this package.
%package -n kernel-headers-modules-%flavour
Summary: Headers and other files needed for building kernel modules
Group: Development/Kernel
Requires: gcc%kgcc_version
%description -n kernel-headers-modules-%flavour
This package contains header files, Makefiles and other parts of the
Linux kernel build system which are needed to build kernel modules for
the Linux kernel package %name-%version-%release.
If you need to compile a third-party kernel module for the Linux
kernel package %name-%version-%release, install this package
and specify %kbuild_dir as the kernel source
directory.
%prep
%setup -cT -n kernel-image-%flavour-%kversion-%krelease
rm -rf kernel-source-%kernel_base_version
tar -xf %kernel_src/kernel-source-%kernel_base_version.tar
%setup -D -T -n kernel-image-%flavour-%kversion-%krelease/kernel-source-%kernel_base_version
%patch0 -p1
# this file should be usable both with make and sh (for broken modules
# which do not use the kernel makefile system)
echo 'export GCC_VERSION=%kgcc_version' > gcc_version.inc
subst 's/EXTRAVERSION[[:space:]]*=.*/EXTRAVERSION = %kernel_extra_version-%flavour-%krelease/g' Makefile
subst 's/CC.*$(CROSS_COMPILE)gcc/CC := $(shell echo $${GCC_USE_CCACHE:+ccache}) gcc-%kgcc_version/g' Makefile
# get rid of unwanted files resulting from patch fuzz
find . -name "*.orig" -delete -or -name "*~" -delete
chmod +x tools/objtool/sync-check.sh
%build
export ARCH=%base_arch
export NPROCS=%__nprocs
KernelVer=%kversion-%flavour-%krelease
echo "Building Kernel $KernelVer"
%make_build mrproper
cp -vf pico-imx8mq-config .config
%make_build %make_target
%make_build modules
%make_build dtbs
echo "Kernel built $KernelVer"
%install
export ARCH=%base_arch
KernelVer=%kversion-%flavour-%krelease
install -Dp -m644 System.map %buildroot/boot/System.map-$KernelVer
install -Dp -m644 %image_path \
%buildroot/boot/vmlinuz-$KernelVer
install -Dp -m644 .config %buildroot/boot/config-$KernelVer
make modules_install INSTALL_MOD_PATH=%buildroot
find %buildroot -name '*.ko' | xargs gzip
mkdir -p %buildroot/lib/devicetree/$KernelVer
find arch/%base_arch/boot/dts -type f -name \*.dtb |xargs -iz install -pm0644 z %buildroot/lib/devicetree/$KernelVer
mkdir -p %buildroot/lib/devicetree/$KernelVer/overlays
find -L arch/%arch_dir/boot/dts/overlays -type f -name \*.dtbo | xargs -iz install -pm0644 z %buildroot/lib/devicetree/$KernelVer/overlays
mkdir -p %buildroot%kbuild_dir/arch/%arch_dir
install -d %buildroot%kbuild_dir
cp -a include %buildroot%kbuild_dir/include
cp -a arch/%arch_dir/include %buildroot%kbuild_dir/arch/%arch_dir
# drivers-headers install
install -d %buildroot%kbuild_dir/drivers/scsi
install -d %buildroot%kbuild_dir/drivers/md
install -d %buildroot%kbuild_dir/drivers/usb/core
install -d %buildroot%kbuild_dir/drivers/net/wireless
install -d %buildroot%kbuild_dir/net/mac80211
install -d %buildroot%kbuild_dir/kernel
install -d %buildroot%kbuild_dir/lib
cp -a drivers/scsi/scsi.h \
%buildroot%kbuild_dir/drivers/scsi/
cp -a drivers/md/dm*.h \
%buildroot%kbuild_dir/drivers/md/
cp -a drivers/usb/core/*.h \
%buildroot%kbuild_dir/drivers/usb/core/
cp -a drivers/net/wireless/Kconfig \
%buildroot%kbuild_dir/drivers/net/wireless/
cp -a lib/hexdump.c %buildroot%kbuild_dir/lib/
cp -a kernel/workqueue.c %buildroot%kbuild_dir/kernel/
cp -a net/mac80211/ieee80211_i.h \
%buildroot%kbuild_dir/net/mac80211/
cp -a net/mac80211/sta_info.h \
%buildroot%kbuild_dir/net/mac80211/
# Install files required for building external modules (in addition to headers)
KbuildFiles="
Makefile
Module.symvers
arch/%arch_dir/Makefile
scripts/pnmtologo
scripts/mod/modpost
scripts/mkmakefile
scripts/mkversion
scripts/link-vmlinux.sh
scripts/mod/mk_elfconfig
scripts/kconfig/conf
scripts/mkcompile_h
scripts/makelst
scripts/Makefile.*
scripts/Makefile
scripts/Kbuild.include
scripts/kallsyms
scripts/genksyms/genksyms
scripts/basic/fixdep
scripts/basic/hash
scripts/extract-ikconfig
scripts/conmakehash
scripts/checkversion.pl
scripts/checkincludes.pl
scripts/checkconfig.pl
scripts/bin2c
scripts/gcc-version.sh
scripts/gcc-goto.sh
scripts/recordmcount.pl
scripts/recordmcount.h
scripts/recordmcount.c
scripts/recordmcount
scripts/gcc-x86_*-has-stack-protector.sh
scripts/module-common.lds
scripts/subarch.include
scripts/depmod.sh
scripts/gcc-plugins/*.so
scripts/ld-version.sh
tools/objtool/objtool
.config
.kernelrelease
gcc_version.inc
System.map
arch/%arch_dir/kernel/module.lds
"
for f in $KbuildFiles; do
[ -e "$f" ] || continue
[ -x "$f" ] && mode=755 || mode=644
install -Dp -m$mode "$f" %buildroot%kbuild_dir/"$f"
done
# Fix symlinks to kernel sources in /lib/modules
rm -f %buildroot%modules_dir/{build,source}
ln -s %kbuild_dir %buildroot%modules_dir/build
# Provide kbuild directory with old name (without %%krelease)
ln -s "$(relative %kbuild_dir %old_kbuild_dir)" %buildroot%old_kbuild_dir
# Provide kernel headers for userspace
make headers_install INSTALL_HDR_PATH=%buildroot%kheaders_dir
#provide symlink to autoconf.h for back compat
pushd %buildroot%old_kbuild_dir/include/linux
ln -s ../generated/autoconf.h
ln -s ../generated/utsrelease.h
ln -s ../generated/uapi/linux/version.h
popd
# remove *.bin files
rm -f %buildroot%modules_dir/modules.{alias,dep,symbols,builtin}.bin
touch %buildroot%modules_dir/modules.{alias,dep,symbols,builtin}.bin
touch %buildroot%modules_dir/modules.{alias,dep,devname,softdep,symbols}
%add_verify_elf_skiplist /boot/vmlinuz-*
%files
/boot/vmlinuz-%kversion-%flavour-%krelease
/boot/System.map-%kversion-%flavour-%krelease
/boot/config-%kversion-%flavour-%krelease
%dir %modules_dir/
%defattr(0600,root,root,0700)
%modules_dir/*
%exclude %modules_dir/build
%ghost %modules_dir/modules.alias.bin
%ghost %modules_dir/modules.dep.bin
%ghost %modules_dir/modules.symbols.bin
%ghost %modules_dir/modules.builtin.bin
/lib/devicetree/%kversion-%flavour-%krelease
# to avoid -drm- subpackage
%modules_dir/kernel/drivers/gpu/drm
%dir %modules_dir/kernel/drivers/media/rc
%modules_dir/kernel/drivers/media/rc/rc-core.*
# to avoid -staging- subpackage
%modules_dir/kernel/drivers/staging/
%files -n kernel-headers-%flavour
%kheaders_dir
%files -n kernel-headers-modules-%flavour
%kbuild_dir
%old_kbuild_dir
%dir %modules_dir/
%modules_dir/build
%changelog
* Wed Jun 02 2021 Pavel Nakonechnyi <zorg@altlinux.org> 5.4.70-alt3
- enable BPF-related options
* Mon May 31 2021 Pavel Nakonechnyi <zorg@altlinux.org> 5.4.70-alt2
- NFS and CIFS support enabled
* Fri May 28 2021 Pavel Nakonechnyi <zorg@altlinux.org> 5.4.70-alt1
- switched to tn-imx_5.4.70_2.3.0-stable branch
- config is now based on ./arch/arm64/configs/tn_imx8_defconfig
* Tue Oct 27 2020 Pavel Nakonechnyi <zorg@altlinux.org> 4.14.98-alt3
- switched to tn-imx_4.14.98_2.0.0_ga-stable branch
* Wed Dec 25 2019 Pavel Nakonechnyi <zorg@altlinux.org> 4.14.98-alt2
- updated to the current version of upstream tn-imx_4.14.98_2.0.0_ga-wip branch
* Sun Jul 07 2019 Pavel Nakonechnyi <zorg@altlinux.ru> 4.14.98-alt1
- 4.14.98 version of Linux kernel for TechNexion PICO IMX8MQ board