blob: abc2f4949aa8f55f10e2850b0d0d912bb6466ffb (
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
|
# Copyright 2020-2023 BaldEagleOS Authors
# Distributed under the terms of the GNU General Public License v2
# Documentation for adding new kernels -- do not remove!
#
# Find latest kernel release here:
# https://github.com/openSUSE/kernel/releases
EAPI=8
inherit check-reqs mount-boot toolchain-funcs
DESCRIPTION="OpenSUSE Sources (and optional binary kernel)"
HOMEPAGE="https://github.com/openSUSE/kernel"
LICENSE="GPL-2"
KEYWORDS="x86 amd64"
SLOT=$(ver_cut 1-2)
RESTRICT="binchecks strip mirror"
IUSE="binary btrfs dtrace custom-cflags ec2 luks lvm sign-modules zfs debug firmware mdadm mcelog plymouth systemd wireguard"
BDEPEND="
virtual/libelf
debug? ( dev-util/dwarves )
sys-devel/bc
"
DEPEND="
net-misc/dhcp[client]
binary? (
sys-kernel/dracut
dev-util/pahole
)
btrfs? ( sys-fs/btrfs-progs )
dtrace? (
dev-util/dtrace-utils
dev-libs/libdtrace-ctf
)
firmware? (
sys-kernel/linux-firmware
)
luks? ( sys-fs/cryptsetup )
lvm? ( sys-fs/lvm2 )
mdadm? ( sys-fs/mdadm )
mcelog? ( app-admin/mcelog )
plymouth? (
x11-libs/libdrm[libkms]
sys-boot/plymouth[udev]
)
sign-modules? (
|| ( dev-libs/openssl
dev-libs/libressl
)
sys-apps/kmod
)
systemd? ( sys-apps/systemd )
!systemd? ( sys-fs/eudev )
wireguard? ( virtual/wireguard )
zfs? ( sys-fs/zfs )
"
SRC_URI="https://github.com/openSUSE/kernel/archive/v${PV}.tar.gz -> linux_${PV}.tar.gz"
S="$WORKDIR/kernel-${PV}"
# install sources to /usr/src/$LINUX_SRCDIR
LINUX_SRCDIR=linux-${PF}
get_patch_list() {
[[ -z "${1}" ]] && die "No patch series file specified"
local patch_series="${1}"
while read line ; do
if [[ "${line:0:1}" != "#" ]] ; then
echo "${line}"
fi
done < "${patch_series}"
}
tweak_config() {
einfo "Setting $2=$3 in kernel config."
sed -i -e "/^$2=/d" $1
echo "$2=$3" >> $1
}
setno_config() {
einfo "Setting $2*=y to n in kernel config."
sed -i -e "s/^$2\(.*\)=.*/$2\1=n/g" $1
}
setyes_config() {
einfo "Setting $2*=* to y in kernel config."
sed -i -e "s/^$2\(.*\)=.*/$2\1=y/g" $1
}
zap_config() {
einfo "Removing *$2* from kernel config."
sed -i -e "/$2/d" $1
}
pkg_pretend() {
# Ensure we have enough disk space to compile
if use binary ; then
CHECKREQS_DISK_BUILD="5G"
check-reqs_pkg_setup
fi
}
get_certs_dir() {
# find a certificate dir in /etc/kernel/certs/ that contains signing cert for modules.
for subdir in $PF $P linux; do
certdir=/etc/kernel/certs/$subdir
if [ -d $certdir ]; then
if [ ! -e $certdir/signing_key.pem ]; then
eerror "$certdir exists but missing signing key; exiting."
exit 1
fi
echo $certdir
return
fi
done
}
pkg_setup() {
export REAL_ARCH="$ARCH"
unset ARCH; unset LDFLAGS #will interfere with Makefile if set
}
src_prepare() {
default
eapply -p1 "${FILESDIR}/shiftfs.patch"
cd "${S}"
#for debpatch in $( get_patch_list "${WORKDIR}/debian/patches/series" ); do
# epatch -p1 "${WORKDIR}/debian/patches/${debpatch}"
#done
# end of debian-specific stuff...
# do not include debian devs certificates
#rm -rf "${WORKDIR}"/debian/certs
sed -i -e "s:^\(EXTRAVERSION =\).*:\1 ${MODULE_EXT}:" Makefile || die
sed -i -e 's:#export\tINSTALL_PATH:export\tINSTALL_PATH:' Makefile || die
rm -f .config >/dev/null
#cp -a "${WORKDIR}"/debian "${T}"
#make -s mrproper || die "make mrproper failed"
#make -s include/linux/version.h || die "make include/linux/version.h failed"
#cd "${S}"
#cp -aR "${WORKDIR}"/debian "${S}"/debian
## XFS LIBCRC kernel config fixes, FL-823
#epatch "${FILESDIR}"/${DEB_PV_BASE}/${PN}-${DEB_PV_BASE}-xfs-libcrc32c-fix.patch
## FL-4424: enable legacy support for MCELOG.
#epatch "${FILESDIR}"/${DEB_PV_BASE}/${PN}-${DEB_PV_BASE}-mcelog.patch
## do not configure debian devs certs.
#epatch "${FILESDIR}"/${DEB_PV_BASE}/${PN}-${DEB_PV_BASE}-nocerts.patch
## FL-3381. enable IKCONFIG
#epatch "${FILESDIR}"/${DEB_PV_BASE}/${PN}-${DEB_PV_BASE}-ikconfig.patch
## increase bluetooth polling patch
#epatch "${FILESDIR}"/${DEB_PV_BASE}/${PN}-${DEB_PV_BASE}-fix-bluetooth-polling.patch
#epatch "${FILESDIR}"/${DEB_PV_BASE}/export_kernel_fpu_functions_5_3.patch
local arch featureset subarch
featureset="standard"
if [[ ${REAL_ARCH} == x86 ]]; then
arch="i386"
subarch="686-pae"
elif [[ ${REAL_ARCH} == amd64 ]]; then
arch="x86_64"
subarch="amd64"
else
die "Architecture not handled in ebuild"
fi
#cp "${FILESDIR}"/config-extract . || die
#chmod +x config-extract || die
#./config-extract ${arch} ${featureset} ${subarch} || die
tar -xvaf "${FILESDIR}/config.tar.bz2" config/${arch}/default
mv config/${arch}/default .config
setno_config .config CONFIG_DEBUG
if use ec2; then
setyes_config .config CONFIG_BLK_DEV_NVME
setyes_config .config CONFIG_XEN_BLKDEV_FRONTEND
setyes_config .config CONFIG_XEN_BLKDEV_BACKEND
setyes_config .config CONFIG_IXGBEVF
fi
if use sign-modules; then
certs_dir=$(get_certs_dir)
echo
if [ -z "$certs_dir" ]; then
eerror "No certs dir found in /etc/kernel/certs; aborting."
die
else
einfo "Using certificate directory of $certs_dir for kernel module signing."
fi
echo
# turn on options for signing modules.
# first, remove existing configs and comments:
zap_config .config CONFIG_MODULE_SIG
# now add our settings:
tweak_config .config CONFIG_MODULE_SIG y
tweak_config .config CONFIG_MODULE_SIG_FORCE n
tweak_config .config CONFIG_MODULE_SIG_ALL n
tweak_config .config CONFIG_MODULE_SIG_HASH \"sha512\"
tweak_config .config CONFIG_MODULE_SIG_KEY \"${certs_dir}/signing_key.pem\"
tweak_config .config CONFIG_SYSTEM_TRUSTED_KEYRING y
tweak_config .config CONFIG_SYSTEM_EXTRA_CERTIFICATE y
tweak_config .config CONFIG_SYSTEM_EXTRA_CERTIFICATE_SIZE 4096
echo "CONFIG_MODULE_SIG_SHA512=y" >> .config
ewarn "This kernel will ALLOW non-signed modules to be loaded with a WARNING."
ewarn "To enable strict enforcement, YOU MUST add module.sig_enforce=1 as a kernel boot"
ewarn "parameter (to params in /etc/boot.conf, and re-run boot-update.)"
echo
fi
if use custom-cflags; then
MARCH="$(python -c "import portage; print(portage.settings[\"CFLAGS\"])" | sed 's/ /\n/g' | grep "march")"
if [ -n "$MARCH" ]; then
sed -i -e 's/-mtune=generic/$MARCH/g' arch/x86/Makefile || die "Canna optimize this kernel anymore, captain!"
fi
fi
# get config into good state:
yes "" | make oldconfig >/dev/null 2>&1 || die
cp .config "${T}"/config || die
#make -s mrproper || die "make mrproper failed"
}
src_configure() {
if use binary; then
debug-print-function ${FUNCNAME} "${@}"
tc-export_build_env
MAKEARGS=(
V=1
HOSTCC="$(tc-getBUILD_CC)"
HOSTCXX="$(tc-getBUILD_CXX)"
HOSTCFLAGS="${BUILD_CFLAGS}"
HOSTLDFLAGS="${BUILD_LDFLAGS}"
CROSS_COMPILE=${CHOST}-
AS="$(tc-getAS)"
CC="$(tc-getCC)"
LD="$(tc-getLD)"
AR="$(tc-getAR)"
NM="$(tc-getNM)"
STRIP=":"
OBJCOPY="$(tc-getOBJCOPY)"
OBJDUMP="$(tc-getOBJDUMP)"
# we need to pass it to override colliding Gentoo envvar
ARCH=$(tc-arch-kernel)
)
mkdir -p "${WORKDIR}"/modprep || die
cp "${T}"/.config "${WORKDIR}"/modprep/ || die
emake O="${WORKDIR}"/modprep "${MAKEARGS[@]}" olddefconfig || die "kernel configure failed"
emake O="${WORKDIR}"/modprep "${MAKEARGS[@]}" modules_prepare || die "modules_prepare failed"
cp -pR "${WORKDIR}"/modprep "${WORKDIR}"/build || die
fi
}
src_compile() {
if use binary; then
debug-print-function ${FUNCNAME} "${@}"
emake O="${WORKDIR}"/build "${MAKEARGS[@]}" all || "kernel build failed"
fi
}
src_install() {
# copy sources into place:
dodir /usr/src
cp -a "${S}" "${D}"/usr/src/${LINUX_SRCDIR} || die
cd "${D}"/usr/src/${LINUX_SRCDIR}
# prepare for real-world use and 3rd-party module building:
make mrproper || die
cp "${T}"/config .config || die
# if we didn't use genkernel, we're done. The kernel source tree is left in
# an unconfigured state - you can't compile 3rd-party modules against it yet.
use binary || return
make prepare || die
make scripts || die
# OK, now the source tree is configured to allow 3rd-party modules to be
# built against it, since we want that to work since we have a binary kernel
# built.
cp -a "${WORKDIR}"/out/* "${D}"/ || die "couldn't copy output files into place"
# module symlink fixup:
rm -f "${D}"/lib/modules/*/source || die
rm -f "${D}"/lib/modules/*/build || die
cd "${D}"/lib/modules
local moddir="$(ls -d [234]*)"
ln -s /usr/src/${LINUX_SRCDIR} "${D}"/lib/modules/${moddir}/source || die
ln -s /usr/src/${LINUX_SRCDIR} "${D}"/lib/modules/${moddir}/build || die
# Fixes FL-14
cp "${WORKDIR}/build/System.map" "${D}/usr/src/${LINUX_SRCDIR}/" || die
cp "${WORKDIR}/build/Module.symvers" "${D}/usr/src/${LINUX_SRCDIR}/" || die
if use sign-modules; then
for x in $(find "${D}"/lib/modules -iname *.ko); do
# $certs_dir defined previously in this function.
${WORKDIR}/build/scripts/sign-file sha512 $certs_dir/signing_key.pem $certs_dir/signing_key.x509 $x || die
done
# install the sign-file executable for future use.
exeinto /usr/src/${LINUX_SRCDIR}/scripts
doexe ${WORKDIR}/build/scripts/sign-file
fi
# The new naming scheme leaves an extra -${PN} at the name of various things in /boot. This should fix that.
cd ${D}/boot
for x in $(ls *); do
xnew=${x%-${PN}}
mv $x ${xnew} || die
done
}
pkg_postinst() {
if use binary && [[ -h "${ROOT}"usr/src/linux ]]; then
rm "${ROOT}"usr/src/linux
fi
if use binary && [[ ! -e "${ROOT}"usr/src/linux ]]; then
ewarn "With binary use flag enabled /usr/src/linux"
ewarn "symlink automatically set to debian kernel"
ln -sf ${LINUX_SRCDIR} "${ROOT}"usr/src/linux
fi
if [ -e ${ROOT}lib/modules ]; then
depmod -a $DEP_PV
fi
if [ -e /etc/boot.conf ]; then
ego boot update
fi
}
|