This repository has been archived by the owner on Jun 25, 2023. It is now read-only.
-
-
Notifications
You must be signed in to change notification settings - Fork 0
/
PKGBUILD
265 lines (222 loc) Β· 11.4 KB
/
PKGBUILD
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
# Maintainer: gontier-julien <[email protected]>
pkgbase=linux-lts-yaok-v3
pkgver=6.1.25
pkgrel=1
pkgdesc='Linux-lts YAOK V3, Yet Another Optimized Kernel'
url='https://cdn.kernel.org/'
arch=(x86_64 x86_64_v3)
license=(GPL2)
makedepends=(bc libelf pahole cpio perl tar xz
xmlto python-sphinx graphviz imagemagick git
clang llvm llvm-libs lld)
options=('!strip')
_srcname=linux-${pkgver}
_patchsource="https://raw.githubusercontent.com/sirlucjan/kernel-patches/master/6.1"
_frogpatch="https://raw.githubusercontent.com/Frogging-Family/linux-tkg/master/linux-tkg-patches/6.1"
source=(
"https://cdn.kernel.org/pub/linux/kernel/v6.x/linux-${pkgver}.tar.xz"
"https://raw.githubusercontent.com/graysky2/kernel_compiler_patch/master/more-uarches-for-kernel-5.17%2B.patch"
"${_frogpatch}/0003-glitched-cfs-additions.patch"
"${_frogpatch}/0002-clear-patches.patch"
"${_patchsource}/fixes-miscellaneous-v43-sep/0005-elevator-remove-redundant-code-in-elv_unregister_que.patch"
"${_patchsource}/fixes-miscellaneous-v43-sep/0012-objtool-Optimize-elf_dirty_reloc_sym.patch"
"${_patchsource}/fixes-miscellaneous-v43-sep/0013-kbuild-revive-parallel-execution-for-.tmp_initcalls..patch"
"${_patchsource}/fixes-miscellaneous-v43-sep/0016-epoll-ep_autoremove_wake_function-should-use-list_de.patch"
"${_patchsource}/fixes-miscellaneous-v43-sep/0019-mm-remove-PageMovable-export.patch"
"${_patchsource}/fixes-miscellaneous-v43-sep/0023-kthread_worker-check-all-delayed-works-when-destroy-.patch"
"${_patchsource}/fixes-miscellaneous-v43-sep/0037-lib-string-Use-strchr-in-strpbrk.patch"
"${_patchsource}/zen-patches-sep/0009-ZEN-mm-Disable-watermark-boosting-by-default.patch"
"${_patchsource}/zen-patches-sep/0010-ZEN-mm-Stop-kswapd-early-when-nothing-s-waiting-for-.patch"
"${_patchsource}/zen-patches-sep/0012-ZEN-mm-Don-t-hog-the-CPU-and-zone-lock-in-rmqueue_bu.patch"
"config" # Kernel config
)
validpgpkeys=(
'ABAF11C65A2970B130ABE3C479BE3E4300411886' # Linus Torvalds
'647F28654894E3BD457199BE38DBBDC86092693E' # Greg Kroah-Hartman
'E27E5D8A3403A2EF66873BBCDEA66FF797772CDC' # Sasha Levin
)
b2sums=('a8eeec298534e825935d94d1bcdbd6224955f5a6715592a27bea48a360582b3c5f640b277a3f076948d074bb6097814a58dbee8ae9fa8b217588935d6c799728' # Linux 6.1.25
'508ff463d936e07e0c3ac2017da12bda52d3db5d98d45fe908f35c4d9fadb253cc9d5c17b8915ec600b5024fcecc2746a04d32096e7ebf691438d4ab8bd067a8' # Graysky2 patch for x86-64-v3
'4d71339dc96627043e843fa0a627fbf7ee7b25bf5388cf95cc98cf5a04cfd12778ad194ab4a12233d499bf6683189fe285514a240e88807eefec0718e014c20a' # Frog TKG CFS patch
'c270f1ad7b3898ea499f0a3dad93708f3546f5be66e7f912b192093d734477e8f0210f318d28be432f0ffff7cf10ea7d849234b3164ce62aa4cdd7fe426d4b5c' # Clear-Linux patch
'5606494edff42a641aca81b38fab1da1f5f4bed1754a654d0679ea23c7f1d86afe9f10e0452861a8ed545c2135d20a7690f69d2067a60a8ab3b2aa3c4beccec4' # Fixes patch 1
'3828f6da0a0863ef3b46c51360fc52071143e9cf902d5c5b1ff9c4e4792ce331aa1617fb654999fcb99d3a6b5e6ab0fba91a694c352a5a1b2b0ab68e4948c1b7' # Fixes patch 2
'fec15aaba839c764d5b445b62d915d2e745f1c08f4a46fc0732a0035f9585878b45473e5a683440eb3fa773d6386a2092ecf6cd8c9b1339091f7889c4b43a511' # Fixes patch 3
'0cc563a3093c2ff73fa58f3542fca6c8a8767700249aaa46a91685055971f9b6befc71afbc614cc55499453a22fcfea5e076ed56a89245443a2a5c0c2d531c6c' # Fixes patch 4
'1b59e717d5904daf243d1f0646f90c86dfb29a2e10f92635ddd29f25b044440c6402ca0e0ceeab592d803586e53773bd270221c99ea3a66fc32d3c9683e89fb7' # Fixes patch 5
'582e5ad6ed2d27ae31e9142df61deae7d1f8c5c03a6981302f048071bfd34ce45ab5ddf7d27e4c7f820e5b99f407354c8f1358fb66d57b8999078266feabe4f1' # Fixes patch 6
'0f274e477ac18fa7ca0b1e1c1e6856a4646c255fcf61a896dfecba7990458ca774162fe8df75ec4f5ae04c9ee6c50a166ef29dc0b5e344a71c3c362da82a9d24' # Fixes patch 7
'c246ac7660d991d48648b07ff440295fdb7d66be4feb584541a35b5b07cb68fd9ffd28bbad8b7ef0ae98e315c6b83856cf5f22b1190afd7d15b2720eb3fc8708' # Zen fixes patch 1
'a75186b025528315b7757b0bceaf9d4903a337ae7a771d4620c6eb6d7d5fa5ebb2997056e76da408a7bbb3c9a1faffeb0fbe54dc74c6e74ae373b9b70169951e' # Zen fixes patch 2
'7970dc4764b39860436875b7c0a3120503f3b3d7d09f02e3b196178ccc6476b3d222b227e5127a1ffd5ed6cb20395352a3ed0392d5c31608b929b884de5a5744' # Zen fixes patch 3
'3fe9b4575d03260f1df2e5cc890cf267c3e78cfd08d1bcae45bdf43eddaf13d96ed0efe30c5507423871d787f3629679a70ba2449db9315f65c5dd4e36718a66') # Kernel config
BUILD_FLAGS=(
CC=clang CXX=clang++ LD=ld.lld
LLVM=1
LLVM_IAS=1
)
export KBUILD_BUILD_HOST=archlinux
export KBUILD_BUILD_USER=$pkgbase
export KBUILD_BUILD_TIMESTAMP="$(date -Ru${SOURCE_DATE_EPOCH:+d @$SOURCE_DATE_EPOCH})"
prepare() {
cd $_srcname
echo "Setting version..."
scripts/setlocalversion --save-scmversion
echo "-$pkgrel" > localversion.10-pkgrel
echo "${pkgbase#linux}" > localversion.20-pkgname
local src
for src in "${source[@]}"; do
src="${src%%::*}"
src="${src##*/}"
[[ $src = *.patch ]] || continue
echo "Applying patch $src..."
patch -Np1 < "../$src"
done
echo "Setting config..."
cp ../config .config
# make prepare
make ${BUILD_FLAGS[*]} olddefconfig
make -s kernelrelease > version
echo "Prepared $pkgbase version $(<version)"
echo -e "\033[0;32mEnabling Frog TKG CFS patch..."
scripts/config --enable CONFIG_ZENIFY
echo -e "\033[0;32mEnabling Graysky2 x86-64-v3..."
scripts/config --disable CONFIG_GENERIC_CPU
scripts/config --enable CONFIG_GENERIC_CPU3
echo -e "\033[0;32mEnabling LLVM FULL-LTO..."
scripts/config --enable LTO_CLANG_FULL
scripts/config --disable LTO_CLANG_THIN
scripts/config --disable LTO_NONE
echo -e "\033[0;31mDisabling NUMA by default..."
scripts/config --disable CONFIG_NUMA
echo -e "\033[0;31mDisabling SELinux..."
scripts/config --disable CONFIG_SECURITY_SELINUX
echo -e "\033[0;31mDisabling TOMOYO..."
scripts/config --disable CONFIG_SECURITY_TOMOYO
echo -e "\033[0;31mDisabling AppArmor..."
scripts/config --disable CONFIG_SECURITY_APPARMOR
echo -e "\033[0;31mDisabling YAMA..."
scripts/config --disable CONFIG_SECURITY_YAMA
echo -e "\033[0;31mSet correct LSM config..."
scripts/config --set-str CONFIG_LSM lockdown,integrity,bpf
echo -e "\033[0;31mDisabling SYSFB..."
scripts/config --disable CONFIG_SYSFB_SIMPLEFB
echo -e "\033[0;31mDisabling TCP_CONG_CUBIC..."
scripts/config --module CONFIG_TCP_CONG_CUBIC
scripts/config --disable CONFIG_DEFAULT_CUBIC
echo -e "\033[0;32mSetting performance governor..."
scripts/config --disable CONFIG_CPU_FREQ_DEFAULT_GOV_SCHEDUTIL
scripts/config --enable CONFIG_CPU_FREQ_DEFAULT_GOV_PERFORMANCE
echo -e "\033[0;31mDisabling uneeded governors..."
scripts/config --disable CONFIG_CPU_FREQ_GOV_ONDEMAND
scripts/config --disable CONFIG_CPU_FREQ_GOV_CONSERVATIVE
scripts/config --disable CONFIG_CPU_FREQ_GOV_USERSPACE
scripts/config --disable CONFIG_CPU_FREQ_GOV_SCHEDUTIL
echo -e "\033[0;32mEnabling PREEMPT..."
scripts/config --disable CONFIG_PREEMPT_NONE
scripts/config --disable CONFIG_PREEMPT_VOLUNTARY
scripts/config --enable CONFIG_PREEMPT
scripts/config --enable CONFIG_PREEMPT_COUNT
scripts/config --enable CONFIG_PREEMPTION
scripts/config --enable CONFIG_PREEMPT_DYNAMIC
echo -e "\033[0;31mDisabling Rust support..."
scripts/config --disable CONFIG_HAVE_RUST
echo -e "\033[0;31mDisabling some additional debuging..."
scripts/config --disable CONFIG_DEBUG_BUGVERBOSE
scripts/config --disable CONFIG_HAVE_DEBUG_KMEMLEAK
scripts/config --disable SLUB_DEBUG
}
build() {
cd $_srcname
make ${BUILD_FLAGS[*]} -j$(nproc) all
}
_package() {
pkgdesc="The $pkgdesc kernel and modules"
depends=(coreutils kmod initramfs)
optdepends=('wireless-regdb: to set the correct wireless channels of your country'
'linux-firmware: firmware images needed for some devices')
provides=(VIRTUALBOX-GUEST-MODULES WIREGUARD-MODULE KSMBD-MODULE)
cd $_srcname
local kernver="$(<version)"
local modulesdir="$pkgdir/usr/lib/modules/$kernver"
echo "Installing boot image..."
# systemd expects to find the kernel here to allow hibernation
# https://github.com/systemd/systemd/commit/edda44605f06a41fb86b7ab8128dcf99161d2344
install -Dm644 "$(make -s image_name)" "$modulesdir/vmlinuz"
# Used by mkinitcpio to name the kernel
echo "$pkgbase" | install -Dm644 /dev/stdin "$modulesdir/pkgbase"
echo "Installing modules..."
make INSTALL_MOD_PATH="$pkgdir/usr" INSTALL_MOD_STRIP=1 \
DEPMOD=/doesnt/exist modules_install # Suppress depmod
# remove build and source links
rm "$modulesdir"/{source,build}
}
_package-headers() {
pkgdesc="Headers and scripts for building modules for the $pkgdesc kernel"
depends=(clang llvm llvm-libs lld pahole)
cd $_srcname
local builddir="$pkgdir/usr/lib/modules/$(<version)/build"
echo "Installing build files..."
install -Dt "$builddir" -m644 .config Makefile Module.symvers System.map \
localversion.* version vmlinux
install -Dt "$builddir/kernel" -m644 kernel/Makefile
install -Dt "$builddir/arch/x86" -m644 arch/x86/Makefile
cp -t "$builddir" -a scripts
# required when STACK_VALIDATION is enabled
install -Dt "$builddir/tools/objtool" tools/objtool/objtool
echo "Installing headers..."
cp -t "$builddir" -a include
cp -t "$builddir/arch/x86" -a arch/x86/include
install -Dt "$builddir/arch/x86/kernel" -m644 arch/x86/kernel/asm-offsets.s
install -Dt "$builddir/drivers/md" -m644 drivers/md/*.h
install -Dt "$builddir/net/mac80211" -m644 net/mac80211/*.h
# https://bugs.archlinux.org/task/13146
install -Dt "$builddir/drivers/media/i2c" -m644 drivers/media/i2c/msp3400-driver.h
# https://bugs.archlinux.org/task/20402
install -Dt "$builddir/drivers/media/usb/dvb-usb" -m644 drivers/media/usb/dvb-usb/*.h
install -Dt "$builddir/drivers/media/dvb-frontends" -m644 drivers/media/dvb-frontends/*.h
install -Dt "$builddir/drivers/media/tuners" -m644 drivers/media/tuners/*.h
# https://bugs.archlinux.org/task/71392
install -Dt "$builddir/drivers/iio/common/hid-sensors" -m644 drivers/iio/common/hid-sensors/*.h
echo "Installing KConfig files..."
find . -name 'Kconfig*' -exec install -Dm644 {} "$builddir/{}" \;
echo "Removing unneeded architectures..."
local arch
for arch in "$builddir"/arch/*/; do
[[ $arch = */x86/ ]] && continue
echo "Removing $(basename "$arch")"
rm -r "$arch"
done
echo "Removing documentation..."
rm -r "$builddir/Documentation"
echo "Removing broken symlinks..."
find -L "$builddir" -type l -printf 'Removing %P\n' -delete
echo "Removing loose objects..."
find "$builddir" -type f -name '*.o' -printf 'Removing %P\n' -delete
echo "Stripping build tools..."
local file
while read -rd '' file; do
case "$(file -Sbi "$file")" in
application/x-sharedlib\;*) # Libraries (.so)
strip -v $STRIP_SHARED "$file" ;;
application/x-archive\;*) # Libraries (.a)
strip -v $STRIP_STATIC "$file" ;;
application/x-executable\;*) # Binaries
strip -v $STRIP_BINARIES "$file" ;;
application/x-pie-executable\;*) # Relocatable binaries
strip -v $STRIP_SHARED "$file" ;;
esac
done < <(find "$builddir" -type f -perm -u+x ! -name vmlinux -print0)
echo "Stripping vmlinux..."
strip -v $STRIP_STATIC "$builddir/vmlinux"
echo "Adding symlink..."
mkdir -p "$pkgdir/usr/src"
ln -sr "$builddir" "$pkgdir/usr/src/$pkgbase"
}
pkgname=("$pkgbase" "$pkgbase-headers" )
for _p in "${pkgname[@]}"; do
eval "package_$_p() {
$(declare -f "_package${_p#$pkgbase}")
_package${_p#$pkgbase}
}"
done