blob: c39fac152c883663eaf9207883fa4d4a1f7d28b3 (
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
|
# Maintainer: Milan P. Stanić <mps@arvanta.net>
_flavor=elm
pkgname=linux-${_flavor}
# NOTE: this kernel is intended for testing
# please resist urge to upgrade it blindly
pkgver=5.17.6
case $pkgver in
*.*.*) _kernver=${pkgver%.*};;
*.*) _kernver=$pkgver;;
esac
pkgrel=1
pkgdesc="Linux latest stable kernel for elm chromebooks"
url="https://www.kernel.org"
_depends_dev="perl gmp-dev bash flex bison"
makedepends="$_depends_dev sed installkernel bc linux-headers linux-firmware-any
openssl-dev>3 diffutils findutils vboot-utils u-boot-tools dtc"
options="!strip !check"
_config=${config:-config-elm.${CARCH}}
install=
#subpackages="$pkgname-dev:_dev:$CBUILD_ARCH"
source="https://cdn.kernel.org/pub/linux/kernel/v${pkgver%%.*}.x/linux-$_kernver.tar.xz"
case $pkgver in
*.*.0) source="$source";;
*.*.*) source="$source
https://cdn.kernel.org/pub/linux/kernel/v${pkgver%%.*}.x/patch-$pkgver.xz" ;;
esac
source="$source
config-elm.aarch64
kernel.its.elm
fix-mmc1-speed.patch
fix-spi-nor-max-frequency.patch
fix-mmc-order.patch
mps-ter12x24-font-kernel.patch
"
arch="aarch64"
license="GPL-2.0"
_flavors=
for _i in $source; do
case $_i in
config-*.$CARCH)
_f=${_i%.$CARCH}
_f=${_f#config-}
_flavors="$_flavors ${_f}"
if [ "linux-$_f" != "$pkgname" ]; then
subpackages="$subpackages linux-${_f}::$CBUILD_ARCH linux-${_f}-dev:_dev:$CBUILD_ARCH"
fi
;;
esac
done
_carch=${CARCH}
case "$_carch" in
aarch64*) _carch="arm64" ;;
arm*) _carch="arm" ;;
esac
prepare() {
local _patch_failed=
cd "$srcdir"/linux-$_kernver
case $pkgver in
*.*.0);;
*)
msg "Applying patch-$pkgver.xz"
unxz -c < "$srcdir"/patch-$pkgver.xz | patch -p1 -N ;;
esac
# first apply patches in specified order
for i in $source; do
case $i in
*.patch)
msg "Applying $i..."
if ! patch -s -p1 -N -i "$srcdir"/$i; then
echo $i >>failed
_patch_failed=1
fi
;;
esac
done
if ! [ -z "$_patch_failed" ]; then
error "The following patches failed:"
cat failed
return 1
fi
# remove localversion from patch if any
rm -f localversion*
oldconfig
}
oldconfig() {
for i in $_flavors; do
local _config=config-$i.${CARCH}
local _builddir="$srcdir"/build-$i.$CARCH
mkdir -p "$_builddir"
echo "-$pkgrel-$i" > "$_builddir"/localversion-alpine \
|| return 1
cp "$srcdir"/$_config "$_builddir"/.config
make -C "$srcdir"/linux-$_kernver \
O="$_builddir" \
ARCH="$_carch" \
listnewconfig oldconfig
done
}
build() {
unset LDFLAGS
export KBUILD_BUILD_TIMESTAMP="$(date -Ru${SOURCE_DATE_EPOCH:+d @$SOURCE_DATE_EPOCH})"
for i in $_flavors; do
cd "$srcdir"/build-$i.$CARCH
make ARCH="$_carch" CC="${CC:-gcc}" \
KBUILD_BUILD_VERSION="$((pkgrel + 1 ))-Alpine"
done
}
_package() {
local _buildflavor="$1" _outdir="$2"
local _abi_release=${pkgver}-${pkgrel}-${_buildflavor}
export KBUILD_BUILD_TIMESTAMP="$(date -Ru${SOURCE_DATE_EPOCH:+d @$SOURCE_DATE_EPOCH})"
cd "$srcdir"/build-$_buildflavor.$CARCH
# modules_install seems to regenerate a defect Modules.symvers on s390x. Work
# around it by backing it up and restore it after modules_install
cp Module.symvers Module.symvers.backup
mkdir -p "$_outdir"/boot "$_outdir"/lib/modules
local _install
case "$CARCH" in
arm*|aarch64) _install="zinstall dtbs_install";;
*) _install=install;;
esac
make -j1 modules_install $_install \
ARCH="$_carch" \
INSTALL_MOD_PATH="$_outdir" \
INSTALL_PATH="$_outdir"/boot \
INSTALL_DTBS_PATH="$_outdir/boot/dtbs-$_buildflavor"
cp Module.symvers.backup Module.symvers
rm -f "$_outdir"/lib/modules/${_abi_release}/build \
"$_outdir"/lib/modules/${_abi_release}/source
rm -rf "$_outdir"/lib/firmware
install -D -m644 include/config/kernel.release \
"$_outdir"/usr/share/kernel/$_buildflavor/kernel.release
}
# main flavor installs in $pkgdir
package() {
_package elm "$pkgdir"
local _builddir="$srcdir"/build-$_flavor.$CARCH
cd $_builddir
cp $srcdir/kernel.its.elm .
mkimage -D "-I dts -O dtb -p 2048" -f kernel.its.elm vmlinux.uimg
dd if=/dev/zero of=bootloader.bin bs=512 count=1
echo "console=tty1 earlyprintk=tty1 init=/sbin/init root=PARTUUID=%U/PARTNROFF=1 rootwait rw noinitrd loglevel=7" > cmdline
vbutil_kernel \
--pack $pkgdir/boot/vmlinux.kpart-$pkgver-$pkgrel-$_flavor \
--version 1 \
--vmlinuz vmlinux.uimg \
--arch aarch64 \
--keyblock /usr/share/vboot/devkeys/kernel.keyblock \
--signprivate kernel_data_key.vbprivk \
--signprivate /usr/share/vboot/devkeys/kernel_data_key.vbprivk \
--config cmdline \
--bootloader bootloader.bin
rm cmdline bootloader.bin
rm $pkgdir/boot/vmlinuz-elm
cd $pkgdir/boot
ln -s vmlinux.kpart-$pkgver-$pkgrel-$_flavor vmlinux.kpart
}
_dev() {
local _flavor=$(echo $subpkgname | sed -E 's/(^linux-|-dev$)//g')
local _abi_release=${pkgver}-${pkgrel}-$_flavor
# copy the only the parts that we really need for build 3rd party
# kernel modules and install those as /usr/src/linux-headers,
# simlar to what ubuntu does
#
# this way you dont need to install the 300-400 kernel sources to
# build a tiny kernel module
#
pkgdesc="Headers and script for third party modules for $_flavor kernel"
depends="$_depends_dev"
local dir="$subpkgdir"/usr/src/linux-headers-${_abi_release}
export KBUILD_BUILD_TIMESTAMP="$(date -Ru${SOURCE_DATE_EPOCH:+d @$SOURCE_DATE_EPOCH})"
# first we import config, run prepare to set up for building
# external modules, and create the scripts
mkdir -p "$dir"
cp "$srcdir"/config-$_flavor.${CARCH} "$dir"/.config
echo "-$pkgrel-$_flavor" > "$dir"/localversion-alpine
make -j1 -C "$srcdir"/linux-$_kernver O="$dir" ARCH="$_carch" \
syncconfig prepare modules_prepare scripts
# remove the stuff that points to real sources. we want 3rd party
# modules to believe this is the soruces
rm "$dir"/Makefile "$dir"/source
# copy the needed stuff from real sources
#
# this is taken from ubuntu kernel build script
# http://kernel.ubuntu.com/git/ubuntu/ubuntu-zesty.git/tree/debian/rules.d/3-binary-indep.mk
cd "$srcdir"/linux-$_kernver
find . -path './include/*' -prune \
-o -path './scripts/*' -prune -o -type f \
\( -name 'Makefile*' -o -name 'Kconfig*' -o -name 'Kbuild*' -o \
-name '*.sh' -o -name '*.pl' -o -name '*.lds' -o -name 'Platform' \) \
-print | cpio -pdm "$dir"
cp -a scripts include "$dir"
find $(find arch -name include -type d -print) -type f \
| cpio -pdm "$dir"
install -Dm644 "$srcdir"/build-$_flavor.$CARCH/Module.symvers \
"$dir"/Module.symvers
mkdir -p "$subpkgdir"/lib/modules/${_abi_release}
ln -sf /usr/src/linux-headers-${_abi_release} \
"$subpkgdir"/lib/modules/${_abi_release}/build
}
sha512sums="
89f0a7ca69d20a539d4b612a7028a30a5e98b402e4b6b88516f14237e5da4b626d7929eab8b40fccc90766e8f3bae87e9858a19077ffad20d8204acf18794f5b linux-5.17.tar.xz
294199421db88a203e1ccfa0833d394e7ab444860875327979bd1dda1fcb1c211809728f2e39c1ce20b14754bc9e20183a885d0b74aae92dba58197d09b0590c patch-5.17.6.xz
bb41f3f12831661d8efc9c846225ddf7cb0c546de4197898413caf8f5fc06ee468b7e0e31e7a68c54b03f0b57df3513f910e741822313c35006c025a9316dff0 config-elm.aarch64
112af92af4a3f61867ffc20076d057845aa8c9139e58153d0c88f4d7185d9a9628fa79d4edfa8855f095fb70d257bfbd7c4573a7431d4b17706415b411a50775 kernel.its.elm
65c57a6d9a5bd5b6ec8798d1c46091bb72377ed1349b66e9a0a1a50ffa077f044f2bfdd30eab974c9c9774fc62d8dd5020a38432d108fce7f4fc1ed6648ea703 fix-mmc1-speed.patch
9e17fb96b81590da0f9b0917ddd2b9d195bab5cde2a4e7feb19991c50a8ac8e4502445715153ced8666e5b6575137c1d49899bb0ae9ab4505ed8f1ff7e569269 fix-spi-nor-max-frequency.patch
00e7afdab1dc89a6e0426829685d85cebb98fb95cb13a253d01326fd22f78ddf792bbe3b5be4c9bc93784f1fa93f87f604a4b6c6710660319db6f2e35dd09835 fix-mmc-order.patch
fcea50a1ba2356d64a9c3ee0b7b7c326654996956d68eb445fafdb4320b4104b6321f768f0ce4ceb5cd4696be3a7332908ba1de7054fb20bf8c97f4234bfa6a4 mps-ter12x24-font-kernel.patch
"
|