linux-cachyos-deckify-headers
LOW
maintainer ptr1337
0 votes
base
linux-cachyos-deckify
scanned 2026-10-23 15:37:50.087015
Why flagged
Uploaded within the last 14 days with 2 or fewer community votes — little peer review so far.
Triggered rules
Low
Few votes, recently uploaded
zero_votes_recent
Uploaded within the last 14 days with 2 or fewer community votes — little peer review so far.
PKGBUILD
1
# Maintainer: Peter Jung ptr1337 <admin@ptr1337.dev>
2
# Maintainer: Piotr Gorski <piotrgorski@cachyos.org>
3
# Maintainer: Vasiliy Stelmachenok <ventureo@cachyos.org>
4
# Contributor: Jan Alexander Steffens (heftig) <jan.steffens@gmail.com>
5
# Contributor: Tobias Powalowski <tpowa@archlinux.org>
6
# Contributor: Thomas Baechler <thomas@archlinux.org>
7
8
### BUILD OPTIONS
9
# Set these variables to ANYTHING that is not null or choose proper variable to enable them
10
11
### Selecting CachyOS config
12
: "${_cachy_config:=yes}"
13
14
### Selecting the CPU scheduler
15
# ATTENTION - only one of the following values can be selected:
16
# 'bore' - select 'Burst-Oriented Response Enhancer'
17
# 'bmq' - select 'BMQ Scheduler'
18
# 'hardened' - select 'BORE Scheduler hardened' ## kernel with hardened config and hardening patches with the bore scheduler
19
# 'cachyos' - select 'CachyOS Default Scheduler (EEVDF)'
20
# 'eevdf' - select 'EEVDF Scheduler'
21
# 'rt' - select EEVDF, but includes a series of realtime patches
22
# 'rt-bore' - select Burst-Oriented Response Enhancer, but includes a series of realtime patches
23
: "${_cpusched:=cachyos}"
24
25
### Tweak kernel options prior to a build via nconfig
26
: "${_makenconfig:=no}"
27
28
### Tweak kernel options prior to a build via xconfig
29
: "${_makexconfig:=no}"
30
31
# Compile ONLY used modules to VASTLYreduce the number of modules built
32
# and the build time.
33
#
34
# To keep track of which modules are needed for your specific system/hardware,
35
# give module_db script a try: https://aur.archlinux.org/packages/modprobed-db
36
# This PKGBUILD read the database kept if it exists
37
#
38
# More at this wiki page ---> https://wiki.archlinux.org/index.php/Modprobed-db
39
: "${_localmodcfg:=no}"
40
41
# Path to the list of used modules
42
: "${_localmodcfg_path:="$XDG_DATA_HOME/modprobed-db/modprobed.db"}"
43
44
45
# Use the current kernel's .config file
46
# Enabling this option will use the .config of the RUNNING kernel rather than
47
# the ARCH defaults. Useful when the package gets updated and you already went
48
# through the trouble of customizing your config options. NOT recommended when
49
# a new kernel is released, but again, convenient for package bumps.
50
: "${_use_current:=no}"
51
52
### Enable KBUILD_CFLAGS -O3
53
: "${_cc_harder:=yes}"
54
55
### Set performance governor as default
56
: "${_per_gov:=no}"
57
58
### Enable TCP_CONG_BBR3
59
: "${_tcp_bbr3:=no}"
60
61
### Running with a 1000HZ, 750Hz, 600 Hz, 500Hz, 300Hz, 250Hz and 100Hz tick rate
62
: "${_HZ_ticks:=1000}"
63
64
## Choose between periodic, idle or full
65
### Full tickless can give higher performances in various cases but, depending on hardware, lower consistency.
66
: "${_tickrate:=full}"
67
68
## Choose between full or lazy
69
# Full: Makes all non-critical kernel code preemptible to reduce latency
70
# Lazy: Same as full but instead of preempting immediately it waits for signals from the scheduler
71
# in an attempt to boost throughput.
72
# In practice, this doesn't seem to perform well as both throughput and latency suffer
73
# compared to full.
74
: "${_preempt:=full}"
75
76
### Transparent Hugepages
77
# ATTENTION - one of two predefined values should be selected!
78
# 'always' - always enable THP
79
# 'madvise' - madvise, prevent applications from allocating more memory resources than necessary
80
# More infos here:
81
# https://access.redhat.com/documentation/en-us/red_hat_enterprise_linux/7/html/performance_tuning_guide/sect-red_hat_enterprise_linux-performance_tuning_guide-configuring_transparent_huge_pages
82
: "${_hugepage:=always}"
83
84
# CPU compiler optimizations - Defaults to native if left empty
85
# - "native" (use compiler autodetection)
86
# - "zen4" (Use znver4 compiler optimizations)
87
# - "generic" (kernel's default - to share the package between machines with different CPU µarch as long as they are x86-64)
88
: "${_processor_opt:=}"
89
90
# Clang LTO mode, only available with the "llvm" compiler - options are "none", "full" or "thin".
91
# ATTENTION - one of three predefined values should be selected!
92
# "full: uses 1 thread for Linking, slow and uses more memory, theoretically with the highest performance gains."
93
# "thin: uses multiple threads, faster and uses less memory, may have a lower runtime performance than Full."
94
# "thin-dist: Similar to thin, but uses a distributed model rather than in-process: https://discourse.llvm.org/t/rfc-distributed-thinlto-build-for-kernel/85934"
95
# "none: disable LTO
96
: "${_use_llvm_lto:=none}"
97
98
# Use suffix -lto only when requested by the user
99
# yes - enable -lto suffix
100
# no - disable -lto suffix
101
# https://github.com/CachyOS/linux-cachyos/issues/36
102
: "${_use_lto_suffix:=yes}"
103
104
# Use suffix -gcc when requested by the user
105
# This was added to facilitate https://github.com/CachyOS/linux-cachyos/issues/286
106
: "${_use_gcc_suffix:=no}"
107
108
# KCFI is a proposed forward-edge control-flow integrity scheme for
109
# Clang, which is more suitable for kernel use than the existing CFI
110
# scheme used by CONFIG_CFI_CLANG. kCFI doesn't require LTO, doesn't
111
# alter function references to point to a jump table, and won't break
112
# function address equality.
113
: "${_use_kcfi:=no}"
114
115
# Build the zfs module in to the kernel
116
# WARNING: The ZFS module doesn't build with selected RT sched due to licensing issues.
117
# If you use ZFS, refrain from building the RT kernel
118
: "${_build_zfs:=no}"
119
120
# Builds the open nvidia module and package it into a own base
121
# This does replace the requirement of nvidia-open-dkms
122
# Use this only if you have Turing+ GPU
123
: "${_build_nvidia_open:=no}"
124
125
# Builds the r8125 module and package it into its own package
126
# Replaces requirement for r8125-dkms
127
: "${_build_r8125:=no}"
128
129
# Build a debug package with non-stripped vmlinux
130
: "${_build_debug:=no}"
131
132
# ATTENTION: Do not modify after this line
133
_is_lto_kernel() {
134
[[ "$_use_llvm_lto" = "thin" || "$_use_llvm_lto" = "full" || "$_use_llvm_lto" = "thin-dist" ]]
135
return $?
136
}
137
138
_is_ci_build() {
139
[[ -n "$CI" || -n "$GITHUB_RUN_ID" ]]
140
return $?
141
}
142
143
if _is_lto_kernel && [ "$_use_lto_suffix" = "yes" ]; then
144
_pkgsuffix="cachyos-deckify-lto"
145
elif ! _is_lto_kernel && [ "$_use_gcc_suffix" = "yes" ]; then
146
_pkgsuffix="cachyos-deckify-gcc"
147
else
148
_pkgsuffix="cachyos-deckify"
149
fi
150
151
pkgbase="linux-$_pkgsuffix"
152
_major=7.3
153
_minor=0
154
#_minorc=$((_minor+1))
155
#_rcver=rc8
156
pkgver=${_major}.${_minor}
157
_tagrel=4
158
pkgrel=3
159
_srcname=cachyos-${_major}.${_minor}-${_tagrel}
160
pkgdesc='Linux BORE + Cachy Sauce + Handheld Kernel by CachyOS with other patches and improvements.'
161
_kernver="$pkgver-$pkgrel"
162
_kernuname="${pkgver}-${_pkgsuffix}"
163
arch=('x86_64')
164
url="https://github.com/CachyOS/linux-cachyos"
165
license=('GPL-2.0-only')
166
options=('!strip' '!debug' '!lto')
167
makedepends=(
168
bc
169
binutils
170
cpio
171
gettext
172
glibc
173
libelf
174
libgcc
175
openssl
176
pahole
177
perl
178
python
179
rust
180
rust-bindgen
181
rust-src
182
tar
183
xxhash
184
xz
185
zlib
186
zstd
187
)
188
189
_patchsource="https://raw.githubusercontent.com/cachyos/kernel-patches/master/${_major}"
190
_nv_ver=615.78.08
191
_nv_pkg="NVIDIA-Linux-x86_64-${_nv_ver}"
192
_nv_open_pkg="NVIDIA-kernel-module-source-${_nv_ver}"
193
source=(
194
"https://github.com/CachyOS/linux/releases/download/${_srcname}/${_srcname}.tar.gz"{,.asc}
195
"config"
196
"${_patchsource}/misc/0001-acpi-call.patch"
197
"${_patchsource}/misc/0001-handheld.patch")
198
validpgpkeys=(
199
E18447AC260021D31F3FF6C4C8A2A4774B8B63C4 # Eric Naim <dnaim@cachyos.org>
200
E8B9AA39F054E30E8290D492C3C4820857F654FE # Peter Jung <admin@ptr1337.dev>
201
)
202
203
# LLVM makedepends
204
if _is_lto_kernel; then
205
makedepends+=(clang llvm lld)
206
source+=("${_patchsource}/misc/dkms-clang.patch")
207
BUILD_FLAGS=(
208
CC=clang
209
LD=ld.lld
210
LLVM=1
211
LLVM_IAS=1
212
)
213
fi
214
215
# WARNING The ZFS module doesn't build with selected RT sched due to licensing issues.
216
if [[ "$_cpusched" = "rt" || "$_cpusched" = "rt-bore" ]]; then
217
unset _build_zfs
218
fi
219
220
# ZFS support
221
if [ "$_build_zfs" = "yes" ]; then
222
makedepends+=(git)
223
source+=("git+https://github.com/cachyos/zfs.git#commit=fb48c76e17d3e0092fbba430a9eec1960e1b9961")
224
fi
225
226
227
if [ "$_build_nvidia_open" = "yes" ]; then
228
source+=("https://download.nvidia.com/XFree86/${_nv_open_pkg%"-$_nv_ver"}/${_nv_open_pkg}.tar.xz"
229
"${_patchsource}/misc/nvidia/0001-fix-dsc-correct-RC-parameter-tables-to-match-VESA-DS.patch"
230
"${_patchsource}/misc/nvidia/0002-fix-dp-add-Bigscreen-Beyond-VR-headset-to-WAR-databa.patch")
231
fi
232
233
if [ "$_build_r8125" = "yes" ]; then
234
source+=("git+https://github.com/aravance/r8125.git")
235
fi
236
237
## List of CachyOS schedulers
238
case "$_cpusched" in
239
cachyos|bore|rt-bore|hardened) # CachyOS Scheduler (BORE)
240
source+=("${_patchsource}/sched/0001-bore-cachy.patch");;&
241
bmq) ## Project C Scheduler
242
source+=("${_patchsource}/sched/0001-prjc-cachy.patch");;
243
hardened) ## Hardened Patches
244
source+=("${_patchsource}/misc/0001-hardened.patch");;
245
rt|rt-bore) ## RT patches
246
source+=("${_patchsource}/misc/0001-rt-i915.patch");;
247
esac
248
249
export KBUILD_BUILD_HOST=cachyos
250
export KBUILD_BUILD_USER="$pkgbase"
251
export KBUILD_BUILD_TIMESTAMP="$(date -Ru${SOURCE_DATE_EPOCH:+d @$SOURCE_DATE_EPOCH})"
252
253
_die() { error "$@" ; exit 1; }
254
255
prepare() {
256
cd "$_srcname"
257
258
echo "Setting version..."
259
echo "-$pkgrel" > localversion.10-pkgrel
260
echo "${pkgbase#linux}" > localversion.20-pkgname
261
262
local src
263
for patch in "${source[@]}"; do
264
patch="${patch%%::*}"
265
src="${patch##*/}"
266
src="${src%.zst}"
267
[[ $src = *.patch ]] || continue
268
echo "Applying patch $src..."
269
if [[ "$patch" == "${_patchsource}"/misc/nvidia/* ]]; then
270
patch -Np1 < "../$src" -d "${srcdir}/${_nv_open_pkg}"
271
else
272
patch -Np1 < "../$src"
273
fi
274
done
275
276
echo "Setting config..."
277
cp ../config .config
278
279
### Select CPU optimization
280
if [ -n "$_processor_opt" ]; then
281
MARCH="${_processor_opt^^}"
282
283
case "$MARCH" in
284
GENERIC_V[1-4]) scripts/config -e GENERIC_CPU -d MZEN4 -d X86_NATIVE_CPU \
285
--set-val X86_64_VERSION "${MARCH//GENERIC_V}";;
286
ZEN4) scripts/config -d GENERIC_CPU -e MZEN4 -d X86_NATIVE_CPU;;
287
NATIVE) scripts/config -d GENERIC_CPU -d MZEN4 -e X86_NATIVE_CPU;;
288
esac
289
else
290
scripts/config -d GENERIC_CPU -d MZEN4 -e X86_NATIVE_CPU
291
fi
292
293
### Selecting CachyOS config
294
if [ "$_cachy_config" = "yes" ]; then
295
echo "Enabling CachyOS config..."
296
scripts/config -e CACHY
297
fi
298
299
### Selecting the CPU scheduler
300
case "$_cpusched" in
301
cachyos|bore|hardened) scripts/config -e SCHED_BORE;;
302
bmq) scripts/config -e SCHED_ALT -e SCHED_BMQ;;
303
eevdf) ;;
304
rt) scripts/config -e PREEMPT_RT;;
305
rt-bore) scripts/config -e SCHED_BORE -e PREEMPT_RT;;
306
*) _die "The value $_cpusched is invalid. Choose the correct one again.";;
307
esac
308
309
echo "Selecting ${_cpusched^^} CPU scheduler..."
310
311
### Enable KCFI
312
if [ "$_use_kcfi" = "yes" ]; then
313
echo "Enabling kCFI"
314
scripts/config -e ARCH_SUPPORTS_CFI_CLANG -e CFI_CLANG -e CFI_AUTO_DEFAULT
315
fi
316
317
### Select LLVM level
318
case "$_use_llvm_lto" in
319
thin) scripts/config -e LTO_CLANG_THIN;;
320
thin-dist) scripts/config -e LTO_CLANG_THIN_DIST;;
321
full) scripts/config -e LTO_CLANG_FULL;;
322
none) scripts/config -e LTO_NONE;;
323
*) _die "The value '$_use_llvm_lto' is invalid. Choose the correct one again.";;
324
esac
325
326
echo "Selecting '$_use_llvm_lto' LLVM level..."
327
328
if ! _is_lto_kernel; then
329
echo "Enabling QR Code Panic for GCC Kernels"
330
scripts/config --set-str DRM_PANIC_SCREEN qr_code -e DRM_PANIC_SCREEN_QR_CODE \
331
--set-str DRM_PANIC_SCREEN_QR_CODE_URL https://panic.archlinux.org/panic_report# \
332
--set-val CONFIG_DRM_PANIC_SCREEN_QR_VERSION 40
333
fi
334
335
### Select tick rate
336
case "$_HZ_ticks" in
337
100|250|500|600|750|1000)
338
scripts/config -d HZ_300 -e "HZ_${_HZ_ticks}" --set-val HZ "${_HZ_ticks}";;
339
300)
340
scripts/config -e HZ_300 --set-val HZ 300;;
341
*)
342
_die "The value $_HZ_ticks is invalid. Choose the correct one again."
343
esac
344
345
echo "Setting tick rate to ${_HZ_ticks}Hz..."
346
347
### Select performance governor
348
if [ "$_per_gov" = "yes" ]; then
349
echo "Setting performance governor..."
350
scripts/config -d CPU_FREQ_DEFAULT_GOV_SCHEDUTIL \
351
-e CPU_FREQ_DEFAULT_GOV_PERFORMANCE
352
fi
353
354
### Select tick type
355
case "$_tickrate" in
356
periodic) scripts/config -d NO_HZ_IDLE -d NO_HZ_FULL -d NO_HZ -d NO_HZ_COMMON -e HZ_PERIODIC;;
357
idle) scripts/config -d HZ_PERIODIC -d NO_HZ_FULL -e NO_HZ_IDLE -e NO_HZ -e NO_HZ_COMMON;;
358
full) scripts/config -d HZ_PERIODIC -d NO_HZ_IDLE -d CONTEXT_TRACKING_FORCE -e NO_HZ_FULL_NODEF -e NO_HZ_FULL -e NO_HZ -e NO_HZ_COMMON -e CONTEXT_TRACKING;;
359
*) _die "The value '$_tickrate' is invalid. Choose the correct one again.";;
360
esac
361
362
echo "Selecting '$_tickrate' tick type..."
363
364
### Select preempt type
365
366
# We should not set up the PREEMPT for RT kernels
367
if [[ "$_cpusched" != "rt" && "$_cpusched" != "rt-bore" ]]; then
368
case "$_preempt" in
369
full) scripts/config -e PREEMPT -d PREEMPT_LAZY;;
370
lazy) scripts/config -d PREEMPT -e PREEMPT_LAZY;;
371
*) _die "The value '$_preempt' is invalid. Choose the correct one again.";;
372
esac
373
374
echo "Selecting '$_preempt' preempt type..."
375
fi
376
377
### Enable O3
378
if [ "$_cc_harder" = "yes" ]; then
379
echo "Enabling KBUILD_CFLAGS -O3..."
380
scripts/config -d CC_OPTIMIZE_FOR_PERFORMANCE \
381
-e CC_OPTIMIZE_FOR_PERFORMANCE_O3
382
fi
383
384
### CI-only stuff
385
if _is_ci_build; then
386
echo "Detected build inside CI"
387
388
scripts/config \
389
-d CC_OPTIMIZE_FOR_PERFORMANCE_O3 \
390
-e CC_OPTIMIZE_FOR_SIZE \
391
-d DEBUG_KERNEL \
392
-e DEBUG_INFO_REDUCED
393
fi
394
395
### Enable bbr3
396
if [ "$_tcp_bbr3" = "yes" ]; then
397
echo "Disabling TCP_CONG_CUBIC..."
398
scripts/config -m TCP_CONG_CUBIC \
399
-d DEFAULT_CUBIC \
400
-e TCP_CONG_BBR \
401
-e DEFAULT_BBR \
402
--set-str DEFAULT_TCP_CONG bbr \
403
-m NET_SCH_FQ_CODEL \
404
-e NET_SCH_FQ \
405
-d CONFIG_DEFAULT_FQ_CODEL \
406
-e CONFIG_DEFAULT_FQ
407
fi
408
409
### Select THP
410
case "$_hugepage" in
411
always) scripts/config -d TRANSPARENT_HUGEPAGE_MADVISE -e TRANSPARENT_HUGEPAGE_ALWAYS;;
412
madvise) scripts/config -d TRANSPARENT_HUGEPAGE_ALWAYS -e TRANSPARENT_HUGEPAGE_MADVISE;;
413
*) _die "The value '$_hugepage' is invalid. Choose the correct one again.";;
414
esac
415
416
echo "Selecting '$_hugepage' TRANSPARENT_HUGEPAGE config..."
417
418
echo "Enabling handheld configs"
419
scripts/config \
420
-d RCU_LAZY_DEFAULT_OFF \
421
-e AMD_PRIVATE_COLOR \
422
-m SENSORS_STEAMDECK \
423
-m MFD_STEAMDECK \
424
-m SND_SOC_AW87XXX \
425
-m HID_ASUS_ALLY \
426
-m HID_LENOVO_GO \
427
-m HID_LENOVO_GO_S \
428
-m HID_MSI_CLAW \
429
-m ZOTAC_ZONE_HID \
430
-m LEDS_STEAMDECK \
431
-m LEDS_VALVE \
432
-e ACPI_CALL \
433
-m ZOTAC_ZONE_PLATFORM \
434
-m EXTCON_STEAMDECK \
435
-m HID_MSI
436
437
### Optionally use running kernel's config
438
# code originally by nous; http://aur.archlinux.org/packages.php?ID=40191
439
if [ "$_use_current" = "yes" ]; then
440
if [[ -s /proc/config.gz ]]; then
441
echo "Extracting config from /proc/config.gz..."
442
# modprobe configs
443
zcat /proc/config.gz > ./.config
444
else
445
warning "Your kernel was not compiled with IKPROC!"
446
warning "You cannot read the current config!"
447
warning "Aborting!"
448
exit
449
fi
450
fi
451
452
### Optionally load needed modules for the make localmodconfig
453
# See https://aur.archlinux.org/packages/modprobed-db
454
if [ "$_localmodcfg" = "yes" ]; then
455
if [ -e "$_localmodcfg_path" ]; then
456
echo "Running Steven Rostedt's make localmodconfig now"
457
make "${BUILD_FLAGS[@]}" LSMOD="${_localmodcfg_path}" localmodconfig
458
else
459
_die "No modprobed.db data found"
460
fi
461
fi
462
463
### Rewrite configuration
464
echo "Rewrite configuration..."
465
make "${BUILD_FLAGS[@]}" prepare
466
yes "" | make "${BUILD_FLAGS[@]}" config >/dev/null
467
diff -u ../config .config || :
468
469
### Prepared version
470
make -s kernelrelease > version
471
echo "Prepared $pkgbase version $(<version)"
472
473
### Running make nconfig
474
[ "$_makenconfig" = "yes" ] && make "${BUILD_FLAGS[@]}" nconfig
475
476
### Running make xconfig
477
[ "$_makexconfig" = "yes" ] && make "${BUILD_FLAGS[@]}" xconfig
478
479
### Save configuration for later reuse
480
echo "Save configuration for later reuse..."
481
local basedir="$(dirname "$(readlink "${srcdir}/config")")"
482
cat .config > "${basedir}/config-${pkgver}-${pkgrel}${pkgbase#linux}"
483
}
484
485
_sign_modules() {
486
msg2 "Signing modules in $1"
487
local sign_script="${srcdir}/${_srcname}/scripts/sign-file"
488
local sign_key="$(grep -Po 'CONFIG_MODULE_SIG_KEY="\K[^"]*' "${srcdir}/${_srcname}/.config")"
489
if [[ ! "$sign_key" =~ ^/ ]]; then
490
sign_key="${srcdir}/${_srcname}/${sign_key}"
491
fi
492
local sign_cert="${srcdir}/${_srcname}/certs/signing_key.x509"
493
local hash_algo="$(grep -Po 'CONFIG_MODULE_SIG_HASH="\K[^"]*' "${srcdir}/${_srcname}/.config")"
494
495
if [ "$_use_llvm_lto" != "none" ]; then
496
local strip_bin="llvm-strip"
497
else
498
local strip_bin="strip"
499
fi
500
501
find "$1" -type f -name '*.ko' -print \
502
-exec "${strip_bin}" --strip-debug '{}' \; \
503
-exec "${sign_script}" "${hash_algo}" "${sign_key}" "${sign_cert}" '{}' \;
504
}
505
506
build() {
507
cd "$_srcname"
508
make "${BUILD_FLAGS[@]}" -j"$(nproc)" all
509
510
if ! _is_ci_build; then
511
make -C tools/bpf/bpftool vmlinux.h feature-clang-bpf-co-re=1
512
fi
513
514
local MODULE_FLAGS=(
515
KERNEL_UNAME="${_kernuname}"
516
IGNORE_PREEMPT_RT_PRESENCE=1
517
SYSSRC="${srcdir}/${_srcname}"
518
SYSOUT="${srcdir}/${_srcname}"
519
)
520
521
if [ "$_build_nvidia_open" = "yes" ]; then
522
cd "${srcdir}/${_nv_open_pkg}"
523
MODULE_FLAGS+=(IGNORE_CC_MISMATCH=yes)
524
CFLAGS= CXXFLAGS= LDFLAGS= make "${BUILD_FLAGS[@]}" "${MODULE_FLAGS[@]}" -j"$(nproc)" modules
525
fi
526
527
if [ "$_build_zfs" = "yes" ]; then
528
cd ${srcdir}/"zfs"
529
530
local CONFIGURE_FLAGS=()
531
[ "$_use_llvm_lto" != "none" ] && CONFIGURE_FLAGS+=("KERNEL_LLVM=1")
532
533
./autogen.sh
534
sed -i "s|\$(uname -r)|${_kernuname}|g" configure
535
./configure "${CONFIGURE_FLAGS[@]}" --prefix=/usr --sysconfdir=/etc --sbindir=/usr/bin \
536
--libdir=/usr/lib --datadir=/usr/share --includedir=/usr/include \
537
--with-udevdir=/lib/udev --libexecdir=/usr/lib/zfs --with-config=kernel \
538
--with-linux="${srcdir}/$_srcname"
539
make "${BUILD_FLAGS[@]}"
540
fi
541
542
if [ "$_build_r8125" = "yes" ]; then
543
cd "${srcdir}/r8125"
544
make "${BUILD_FLAGS[@]}" KERNELDIR="$srcdir/$_srcname" modules
545
fi
546
547
}
548
549
_package() {
550
pkgdesc="The $pkgdesc kernel and modules"
551
depends=('coreutils' 'kmod' 'initramfs')
552
optdepends=('wireless-regdb: to set the correct wireless channels of your country'
553
'linux-firmware: firmware images needed for some devices'
554
'modprobed-db: Keeps track of EVERY kernel module that has ever been probed - useful for those of us who make localmodconfig'
555
'scx-scheds: to use sched-ext schedulers')
556
provides=(VIRTUALBOX-GUEST-MODULES WIREGUARD-MODULE KSMBD-MODULE V4L2LOOPBACK-MODULE NTSYNC-MODULE VHBA-MODULE ADIOS-MODULE)
557
558
cd "$_srcname"
559
560
local modulesdir="$pkgdir/usr/lib/modules/$(<version)"
561
562
echo "Installing boot image..."
563
# systemd expects to find the kernel here to allow hibernation
564
# https://github.com/systemd/systemd/commit/edda44605f06a41fb86b7ab8128dcf99161d2344
565
install -Dm644 "$(make -s image_name)" "$modulesdir/vmlinuz"
566
567
# Used by mkinitcpio to name the kernel
568
echo "$pkgbase" | install -Dm644 /dev/stdin "$modulesdir/pkgbase"
569
570
echo "Installing modules..."
571
ZSTD_CLEVEL=19 make "${BUILD_FLAGS[@]}" INSTALL_MOD_PATH="$pkgdir/usr" INSTALL_MOD_STRIP=1 \
572
DEPMOD=/doesnt/exist modules_install # Suppress depmod
573
574
# remove build links
575
rm "$modulesdir"/build
576
}
577
578
_package-headers() {
579
pkgdesc="Headers and scripts for building modules for the $pkgdesc kernel"
580
depends=(binutils
581
glibc
582
libelf
583
libgcc
584
openssl
585
pahole
586
xxhash
587
zlib
588
zstd
589
"${pkgbase}")
590
provides=(LINUX-HEADERS)
591
592
cd "${_srcname}"
593
local builddir="$pkgdir/usr/lib/modules/$(<version)/build"
594
595
echo "Installing build files..."
596
install -Dt "$builddir" -m644 .config Makefile Module.symvers System.map \
597
localversion.* version vmlinux
598
599
if ! _is_ci_build; then
600
install -Dt "$builddir" -m644 tools/bpf/bpftool/vmlinux.h
601
fi
602
603
install -Dt "$builddir/kernel" -m644 kernel/Makefile
604
install -Dt "$builddir/arch/x86" -m644 arch/x86/Makefile
605
cp -t "$builddir" -a scripts
606
ln -srt "$builddir" "$builddir/scripts/gdb/vmlinux-gdb.py"
607
608
# required when STACK_VALIDATION is enabled
609
install -Dt "$builddir/tools/objtool" tools/objtool/objtool
610
611
# required when DEBUG_INFO_BTF_MODULES is enabled
612
if [ -f tools/bpf/resolve_btfids/resolve_btfids ]; then
613
install -Dt "$builddir/tools/bpf/resolve_btfids" tools/bpf/resolve_btfids/resolve_btfids
614
fi
615
616
echo "Installing headers..."
617
cp -t "$builddir" -a include
618
cp -t "$builddir/arch/x86" -a arch/x86/include
619
install -Dt "$builddir/arch/x86/kernel" -m644 arch/x86/kernel/asm-offsets.s
620
621
install -Dt "$builddir/drivers/md" -m644 drivers/md/*.h
622
install -Dt "$builddir/net/mac80211" -m644 net/mac80211/*.h
623
624
# https://bugs.archlinux.org/task/13146
625
install -Dt "$builddir/drivers/media/i2c" -m644 drivers/media/i2c/msp3400-driver.h
626
627
# https://bugs.archlinux.org/task/20402
628
install -Dt "$builddir/drivers/media/usb/dvb-usb" -m644 drivers/media/usb/dvb-usb/*.h
629
install -Dt "$builddir/drivers/media/dvb-frontends" -m644 drivers/media/dvb-frontends/*.h
630
install -Dt "$builddir/drivers/media/tuners" -m644 drivers/media/tuners/*.h
631
632
# https://bugs.archlinux.org/task/71392
633
install -Dt "$builddir/drivers/iio/common/hid-sensors" -m644 drivers/iio/common/hid-sensors/*.h
634
635
echo "Installing KConfig files..."
636
find . -name 'Kconfig*' -exec install -Dm644 {} "$builddir/{}" \;
637
638
# Install .rmeta files if they exist
639
if compgen -G "rust/*.rmeta" 1>/dev/null; then
640
install -Dt "$builddir/rust" -m644 rust/*.rmeta
641
fi
642
643
# Install .so files if they exist
644
if compgen -G "rust/*.so" 1>/dev/null; then
645
install -Dt "$builddir/rust" rust/*.so
646
fi
647
648
# Install generated Rust files
649
if [ -d rust/kernel ]; then
650
while IFS= read -r -d "" _gen; do
651
install -Dm644 "$_gen" "$builddir/$_gen"
652
done < <(find rust -type f -name 'generated_*.rs' -print0)
653
fi
654
655
echo "Installing unstripped VDSO..."
656
make INSTALL_MOD_PATH="$pkgdir/usr" vdso_install \
657
link= # Suppress build-id symlinks
658
659
echo "Removing unneeded architectures..."
660
local arch
661
for arch in "$builddir"/arch/*/; do
662
[[ $arch = */x86/ ]] && continue
663
echo "Removing $(basename "$arch")"
664
rm -r "$arch"
665
done
666
667
echo "Removing documentation..."
668
rm -r "$builddir/Documentation"
669
670
echo "Removing broken symlinks..."
671
find -L "$builddir" -type l -printf 'Removing %P\n' -delete
672
673
echo "Removing loose objects..."
674
find "$builddir" -type f -name '*.o' -printf 'Removing %P\n' -delete
675
676
echo "Stripping build tools..."
677
local file
678
while read -rd '' file; do
679
case "$(file -Sib "$file")" in
680
application/x-sharedlib\;*) # Libraries (.so)
681
strip -v $STRIP_SHARED "$file" ;;
682
application/x-archive\;*) # Libraries (.a)
683
strip -v $STRIP_STATIC "$file" ;;
684
application/x-executable\;*) # Binaries
685
strip -v $STRIP_BINARIES "$file" ;;
686
application/x-pie-executable\;*) # Relocatable binaries
687
strip -v $STRIP_SHARED "$file" ;;
688
esac
689
done < <(find "$builddir" -type f -perm -u+x ! -name vmlinux -print0)
690
691
echo "Stripping vmlinux..."
692
strip -v $STRIP_STATIC "$builddir/vmlinux"
693
694
echo "Adding symlink..."
695
mkdir -p "$pkgdir/usr/src"
696
ln -sr "$builddir" "$pkgdir/usr/src/$pkgbase"
697
}
698
699
_package-dbg(){
700
pkgdesc="Non-stripped vmlinux file for the $pkgdesc kernel"
701
depends=("${pkgbase}-headers")
702
703
cd "${_srcname}"
704
mkdir -p "$pkgdir/usr/src/debug/${pkgbase}"
705
install -Dt "$pkgdir/usr/src/debug/${pkgbase}" -m644 vmlinux
706
}
707
708
_package-zfs(){
709
pkgdesc="zfs module for the $pkgdesc kernel"
710
depends=('pahole' "${pkgbase}=${_kernver}")
711
provides=('ZFS-MODULE')
712
license=('CDDL')
713
714
cd "$_srcname"
715
local modulesdir="$pkgdir/usr/lib/modules/$(<version)/extramodules"
716
717
cd "${srcdir}/zfs"
718
install -dm755 "${modulesdir}"
719
install -m644 module/*.ko "${modulesdir}"
720
721
_sign_modules "${modulesdir}"
722
find "$pkgdir" -name '*.ko' -exec zstd --rm -19 -T0 {} +
723
# sed -i -e "s/EXTRAMODULES='.*'/EXTRAMODULES='${pkgver}-${pkgbase}'/" "$startdir/zfs.install"
724
}
725
726
_package-nvidia-open(){
727
pkgdesc="nvidia open modules of ${_nv_ver} driver for the ${pkgbase} kernel"
728
depends=("$pkgbase=$_kernver" "nvidia-utils=${_nv_ver}" "libglvnd")
729
provides=('NVIDIA-MODULE')
730
conflicts=("$pkgbase-nvidia")
731
license=('MIT AND GPL-2.0-only')
732
733
cd "$_srcname"
734
local modulesdir="$pkgdir/usr/lib/modules/$(<version)/extramodules"
735
736
cd "${srcdir}/${_nv_open_pkg}"
737
install -dm755 "${modulesdir}"
738
install -m644 kernel-open/*.ko "${modulesdir}"
739
install -Dt "$pkgdir/usr/share/licenses/${pkgname}" -m644 COPYING
740
741
_sign_modules "${modulesdir}"
742
find "$pkgdir" -name '*.ko' -exec zstd --rm -19 -T0 {} +
743
}
744
745
_package-r8125() {
746
pkgdesc="r8125 modules for the $pkgbase kernel"
747
depends=("$pkgbase=$_kernver")
748
license=('GPL-2.0-only')
749
750
cd "$_srcname"
751
local modulesdir="$pkgdir/usr/lib/modules/$(<version)/extramodules"
752
753
cd "${srcdir}/r8125"
754
install -dm755 "${modulesdir}"
755
install -m644 src/*.ko "${modulesdir}"
756
757
_sign_modules "${modulesdir}"
758
find "$pkgdir" -name '*.ko' -exec zstd --rm -19 -T0 {} +
759
760
# Blacklist r8169 so that r8125 is used instead
761
install -dm755 "${pkgdir}/usr/lib/modprobe.d"
762
echo "install r8169 /usr/bin/modprobe r8125 || /usr/bin/modprobe --ignore-install r8169" > "${pkgdir}/usr/lib/modprobe.d/${pkgname}.conf"
763
}
764
765
pkgname=("$pkgbase")
766
[ "$_build_debug" = "yes" ] && pkgname+=("$pkgbase-dbg")
767
pkgname+=("$pkgbase-headers")
768
[ "$_build_zfs" = "yes" ] && pkgname+=("$pkgbase-zfs")
769
[ "$_build_nvidia_open" = "yes" ] && pkgname+=("$pkgbase-nvidia-open")
770
[ "$_build_r8125" = "yes" ] && pkgname+=("$pkgbase-r8125")
771
for _p in "${pkgname[@]}"; do
772
eval "package_$_p() {
773
$(declare -f "_package${_p#$pkgbase}")
774
_package${_p#$pkgbase}
775
}"
776
done
777
778
b2sums=('d90b9a609d930cf596022050014ef75e11f3b9378fb51be7763743bc15b10d31caa8d48c59149ed2aea28853aae1ec6d7e68a8ce441b1bd014c9897cbeb8dba5'
779
'SKIP'
780
'e21485bd3d917be15837eb51ddb9aeb4a0df5fb7b18ccbf1d520aff2340833935e441f634e4ae8482a21ff38a9dec9f320bec3459aedf15087909b6eb2cff7db'
781
'ddaf90fd846e13cb213fb343f9599447d377dd51111cd2cbfbda2334836ba7c6925a28453353017a785163dbd1d5d44f1c7eca036c611a8dcf2cecab7d35c2de'
782
'87e191a93551948e364d6ca1739393a11c2758d327efd86c3b84455c8fd9330060b53d947d129401dc935209bec7a80df727da7498c319073a83520f96d37c7e'
783
'04cca5d4811dce379776c124469cb69f5275e7eaa61401da9e23077d0d60d4d06b85b646292b6db4639541d70b4283f732b102c1168d6d29e16f8cccc695e205')
784
Scan history
| Scanned at (UTC) | Severity | Rules |
|---|---|---|
| 2026-10-23 15:37:50 | Low | 1 |