blob: 0542b09b5098992988ccf90c06bd7fc05e53b6de (
plain)
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
348
349
350
351
352
353
354
355
356
357
358
359
360
361
362
363
364
365
366
367
|
# Maintainer: whiteman808 <whiteman808@paraboletancza.org>
# Contributor: David P. <megver83@parabola.nu>
# Contributor: André Silva <emulatorman@hyperbola.info>
# Contributor: Márcio Silva <coadde@hyperbola.info>
# Based on linux-hardened package
_replacesarchkernel=('linux%') # '%' gets replaced with kernel suffix
_replacesoldkernels=() # '%' gets replaced with kernel suffix
_replacesoldmodules=() # '%' gets replaced with kernel suffix
pkgbase=linux-libre-hardened
pkgver=6.17.13.hardened1
pkgrel=2
pkgdesc='Security-Hardened Linux-libre'
url='https://linux-libre.fsfla.org/'
arch=(x86_64)
license=(GPL-2.0-only)
makedepends=(
bc
cpio
gettext
libelf
pahole
perl
python
rust
rust-bindgen
rust-src
tar
xz
# htmldocs
graphviz
imagemagick
python-sphinx
python-yaml
texlive-latexextra
)
options=(
!debug
!strip
)
_srcname=linux-6.17.13
_srctag=v${pkgver%.*}-${pkgver##*.}
source=(
"https://linux-libre.fsfla.org/pub/linux-libre/releases/${_srcname##*-}-gnu/linux-libre-${_srcname##*-}-gnu.tar.xz"{,.sign}
"https://linux-libre.fsfla.org/pub/linux-libre/releases/${pkgver%.*}-gnu/patch-6.17-gnu-${pkgver%.*}-gnu.xz"{,.sign}
"https://linux-libre.fsfla.org/pub/linux-libre/releases/${pkgver%.*}-gnu/patch-6.17.12-gnu-${pkgver%.*}-gnu.xz"{,.sign}
"https://github.com/anthraxx/linux-hardened/releases/download/${_srctag}/linux-hardened-${_srctag}.patch"{,.sig}
"https://repo.parabola.nu/other/linux-libre/logos/logo_linux_"{clut224.ppm,vga16.ppm,mono.pbm}{,.sig}
config # the main kernel config file
# maintain the TTY over USB disconnects
# http://www.coreboot.org/EHCI_Gadget_Debug
0001-usb-serial-gadget-no-TTY-hangup-on-USB-disconnect-WI.patch
# fix Atmel maXTouch touchscreen support
# https://labs.parabola.nu/issues/877
# http://www.fsfla.org/pipermail/linux-libre/2015-November/003202.html
0002-fix-Atmel-maXTouch-touchscreen-support.patch
)
validpgpkeys=(
474402C8C582DAFBE389C427BCB7CF877E7D47A7 # Alexandre Oliva
65EEFE022108E2B708CBFCF7F9E712E59AF5F22A # Daniel Micay
6DB9C4B4F0D8C0DC432CF6E4227CA7C556B2BA78 # David P.
E240B57E2C4630BA768E2F26FC1B547C8D8172C8 # Levente Polyak
)
sha256sums=('8d716a6051ef7bcc11406a100d5c9daee580ce1dd032580b188fd0316d0dec0f'
'SKIP'
'a2bbedf5c5367ef9862bc35caf4e4c782450bba99a22968b2ef9bd0aa84c4ddb'
'SKIP'
'6b9665736d1b94b33261a9a625d093084bfe9e9b2cab8e2db90cb267c035700c'
'SKIP'
'4c6671688c0f9fc1782f5de268e185de19accc706cbd0256c5df48c74df37eb3'
'SKIP'
'bfd4a7f61febe63c880534dcb7c31c5b932dde6acf991810b41a939a93535494'
'SKIP'
'6de8a8319271809ffdb072b68d53d155eef12438e6d04ff06a5a4db82c34fa8a'
'SKIP'
'13bd7a8d9ed6b6bc971e4cd162262c5a20448a83796af39ce394d827b0e5de74'
'SKIP'
'ec7cbaea6a8341ae004dad4c8530bc14dd9bb54281db07447ade4ccaabdac15f'
'0376bd5efa31d4e2a9d52558777cebd9f0941df8e1adab916c868bf0c05f2fc3'
'351fd96be8cd5ebd0435c0a8a978673fc023e3b1026085e67f86d815b2285e25')
b2sums=('917d26cb0e711b3edf61ebcec38b8f73cae0a335598e42ae8ec17395a10f0b1a574fc10479a26349dd3d65898a81836caa4347494cac78f20c93cd024e064cde'
'SKIP'
'6e056269ad7378d2416de5e5e9d56df91f617ff98d497f0044ab59afa74b48e4faae83ffac83e319f975f9dc1fb2416bbb35ba5ef6854443331b642aa01ddade'
'SKIP'
'921fbbdafbe1be60d5dd66606e142fe7b0427313eaf5765443dcb40d59996f60e28d1755a4270a241783e7ee8cf606290280af382a2a5e2f050c0f12385287b3'
'SKIP'
'67e8af0e06150c9839a2bd1c17e2db14a23fab4cfe3179582cb00866592996ae982838061194ecbd1e940c706acaa1f44822368fa0990232477f8cc329f21e11'
'SKIP'
'73fee2ae5cb1ffd3e6584e56da86a8b1ff6c713aae54d77c0dab113890fc673dc5f300eb9ed93fb367b045ece8fa80304ff277fe61665eccf7b7ce24f0c045eb'
'SKIP'
'd02a1153a4285b32c774dca4560fe37907ccf30b8e487a681b717ed95ae9bed5988875c0a118938e5885ae9d2857e53a6f216b732b6fa3368e3c5fe08c86382c'
'SKIP'
'580911af9431c066bbc072fd22d5e2ef65f12d8358cec5ff5a4f1b7deebb86cef6b5c1ad631f42350af72c51d44d2093c71f761234fb224a8b9dbb3b64b8201d'
'SKIP'
'439d4db460a2ddfc668fa69053b359ebf4acaad2a7bd3430c9c993de4b851119a0cd481e5e579ed539553a1ddf5a49bea88124e3a1b55a7d9ed87071194f1962'
'c2214154c36900e311531bfe68184f31639f5c50fed23bc3803a7f18439b7ff258552a39f02fed0ea92f10744e17a6c55cef0ef1a98187f978fe480fb3dddc14'
'0c7ceba7cd90087db3296610a07886f337910bad265a32c052d3a703e6eb8e53f355ab9948d72d366408d968d8ee7435084dd89bef5ed0b69355fd884c2cd468')
_replacesarchkernel=("${_replacesarchkernel[@]/\%/${pkgbase#linux-libre}}")
_replacesoldkernels=("${_replacesoldkernels[@]/\%/${pkgbase#linux-libre}}")
_replacesoldmodules=("${_replacesoldmodules[@]/\%/${pkgbase#linux-libre}}")
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
sed -i 's/\(override CFLAGS += \)-Werror\(.*\)/\1\2/g' tools/lib/bpf/Makefile
if [ "${_srcname##*-}" != "${pkgver%.*}" ]; then
echo "Applying upstream patch..."
patch -Np1 < "../patch-${_srcname##*-}-gnu-${pkgver%.*}-gnu"
fi
echo "Adding freedo as boot logo..."
install -m644 -t drivers/video/logo \
../logo_linux_{clut224.ppm,vga16.ppm,mono.pbm}
echo "Setting version..."
echo "-$pkgrel" > localversion.10-pkgrel
echo "${pkgbase#linux-libre}" > localversion.20-pkgname
# save extraversion as localversion to fit linux-hardened patch while keeping the original value
awk '/^EXTRAVERSION/ {print $3}' Makefile > localversion.00-extraversion
sed -i '/^EXTRAVERSION[[:space:]]*=/ s/=.*$/=/' Makefile
local src
for src in "${source[@]}"; do
src="${src%%::*}"
src="${src##*/}"
src="${src%.zst}"
[[ $src = *.patch ]] || continue
echo "Applying patch $src..."
patch -Np1 < "../$src"
done
# save extraversion as localversion after patching for correct string concatenation order
awk '/^EXTRAVERSION/ {gsub(/arch/, "parabola", $3); print $3}' Makefile > localversion.01-extraversion
sed -i '/^EXTRAVERSION[[:space:]]*=/ s/=.*$/=/' Makefile
echo "Setting config..."
cp ../config .config
make olddefconfig
diff -u ../config .config || :
make -s kernelrelease > version
echo "Prepared $pkgbase version $(<version)"
}
build() {
cd $_srcname
make htmldocs &
local pid_docs=$!
make HOSTCFLAGS+="-Wno-error=discarded-qualifiers" \
KCFLAGS+="-Wno-error=discarded-qualifiers" all
make -C tools/bpf/bpftool vmlinux.h feature-clang-bpf-co-re=1
wait "${pid_docs}"
}
_package() {
pkgdesc="The $pkgdesc kernel and modules"
depends=(
coreutils
initramfs
kmod
)
optdepends=(
'linux-libre-firmware: firmware images needed for some devices'
'scx-scheds: to use sched-ext schedulers'
'wireless-regdb: to set the correct wireless channels of your country'
'usbctl: deny_new_usb control'
)
provides=(
KSMBD-MODULE
NTSYNC-MODULE
VIRTUALBOX-GUEST-MODULES
WIREGUARD-MODULE
)
# replaces=(
# )
provides+=(
# "${_replacesarchkernel[@]/%/=$pkgver}"
"LINUX-ABI_VERSION=$pkgver"
)
conflicts+=(
"${_replacesarchkernel[@]}"
"${_replacesoldkernels[@]}"
"${_replacesoldmodules[@]}"
)
# replaces+=(
# "${_replacesarchkernel[@]}"
# "${_replacesoldkernels[@]}"
# "${_replacesoldmodules[@]}"
# )
cd $_srcname
local modulesdir="$pkgdir/usr/lib/modules/$(<version)"
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..."
ZSTD_CLEVEL=19 make INSTALL_MOD_PATH="$pkgdir/usr" INSTALL_MOD_STRIP=1 \
DEPMOD=/doesnt/exist modules_install # Suppress depmod
# remove build link
rm "$modulesdir"/build
}
_package-headers() {
pkgdesc="Headers and scripts for building modules for the $pkgdesc kernel"
depends=(pahole)
provides=(
# "${_replacesarchkernel[@]/%/-headers=$pkgver}"
)
conflicts=(
"${_replacesarchkernel[@]/%/-headers}"
"${_replacesoldkernels[@]/%/-headers}"
)
# replaces=(
# "${_replacesarchkernel[@]/%/-headers}"
# "${_replacesoldkernels[@]/%/-headers}"
# )
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 tools/bpf/bpftool/vmlinux.h
install -Dt "$builddir/kernel" -m644 kernel/Makefile
install -Dt "$builddir/arch/x86" -m644 arch/x86/Makefile
cp -t "$builddir" -a scripts
ln -srt "$builddir" "$builddir/scripts/gdb/vmlinux-gdb.py"
# required when STACK_VALIDATION is enabled
install -Dt "$builddir/tools/objtool" tools/objtool/objtool
# required when DEBUG_INFO_BTF_MODULES is enabled
install -Dt "$builddir/tools/bpf/resolve_btfids" tools/bpf/resolve_btfids/resolve_btfids
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 "Installing Rust files..."
# install -Dt "$builddir/rust" -m644 rust/*.rmeta
# install -Dt "$builddir/rust" rust/*.so
echo "Installing unstripped VDSO..."
make INSTALL_MOD_PATH="$pkgdir/usr" vdso_install \
link= # Suppress build-id symlinks
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 -Sib "$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"
}
_package-docs() {
pkgdesc="Documentation for the $pkgdesc kernel"
provides=(
# "${_replacesarchkernel[@]/%/-docs=$pkgver}"
)
conflicts=(
"${_replacesarchkernel[@]/%/-docs}"
"${_replacesoldkernels[@]/%/-docs}"
)
# replaces=(
# "${_replacesarchkernel[@]/%/-docs}"
# "${_replacesoldkernels[@]/%/-docs}"
# )
cd $_srcname
local builddir="$pkgdir/usr/lib/modules/$(<version)/build"
echo "Installing documentation..."
local src dst
while read -rd '' src; do
dst="${src#Documentation/}"
dst="$builddir/Documentation/${dst#output/}"
install -Dm644 "$src" "$dst"
done < <(find Documentation -name '.*' -prune -o ! -type d -print0)
echo "Adding symlink..."
mkdir -p "$pkgdir/usr/share/doc"
ln -sr "$builddir/Documentation" "$pkgdir/usr/share/doc/$pkgbase"
}
pkgname=(
"$pkgbase"
"$pkgbase-headers"
"$pkgbase-docs"
)
for _p in "${pkgname[@]}"; do
eval "package_$_p() {
$(declare -f "_package${_p#$pkgbase}")
_package${_p#$pkgbase}
}"
done
# vim:set ts=8 sts=2 sw=2 et:
|