blob: 9380c3cca07b3022fe26e3a5a2f9da721012d6da (
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
|
# Maintainer: Natanael Copa <ncopa@alpinelinux.org>
_flavor=vanilla
pkgname=linux-${_flavor}
pkgver=4.14.47
case $pkgver in
*.*.*) _kernver=${pkgver%.*};;
*.*) _kernver=$pkgver;;
esac
pkgrel=0
pkgdesc="Linux vanilla kernel"
url="http://kernel.org"
depends="mkinitfs"
_depends_dev="perl gmp-dev elfutils-dev bash"
makedepends="$_depends_dev sed installkernel bc linux-headers"
options="!strip"
_config=${config:-config-vanilla.${CARCH}}
install=
source="https://cdn.kernel.org/pub/linux/kernel/v${pkgver%%.*}.x/linux-$_kernver.tar.xz
0001-HID-apple-fix-Fn-key-Magic-Keyboard-on-bluetooth.patch
config-vanilla.aarch64
config-vanilla.armhf
config-vanilla.x86
config-vanilla.x86_64
config-vanilla.ppc
config-vanilla.ppc64le
config-vanilla.s390x
config-virt.x86
config-virt.x86_64
"
subpackages="$pkgname-dev:_dev:$CBUILD_ARCH"
_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
if [ "${pkgver%.0}" = "$pkgver" ]; then
source="$source
https://cdn.kernel.org/pub/linux/kernel/v${pkgver%%.*}.x/patch-$pkgver.xz"
fi
arch="all"
license="GPL-2.0"
_carch=${CARCH}
case "$_carch" in
aarch64*) _carch="arm64" ;;
arm*) _carch="arm" ;;
mips*) _carch="mips" ;;
ppc*) _carch="powerpc" ;;
s390*) _carch="s390" ;;
esac
HOSTCC="${CC:-gcc}"
HOSTCC="${HOSTCC#${CROSS_COMPILE}}"
prepare() {
local _patch_failed=
cd "$srcdir"/linux-$_kernver
if [ "$_kernver" != "$pkgver" ]; then
msg "Applying patch-$pkgver.xz"
unxz -c < "$srcdir"/patch-$pkgver.xz | patch -p1 -N || return 1
fi
# 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*
for i in $_flavors; do
local _config=config-$i.${CARCH}
local _builddir="$srcdir"/build-$i
mkdir -p "$_builddir"
echo "-$pkgrel-$i" > "$srcdir"/build-$i/localversion-alpine \
|| return 1
cp "$srcdir"/$_config "$_builddir"/.config || return 1
make -C "$srcdir"/linux-$_kernver \
O="$_builddir" \
ARCH="$_carch" HOSTCC="$HOSTCC" \
silentoldconfig || return 1
done
}
build() {
unset LDFLAGS
for i in $_flavors; do
cd "$srcdir"/build-$i
make ARCH="$_carch" CC="${CC:-gcc}" \
KBUILD_BUILD_VERSION="$((pkgrel + 1 ))-Alpine" \
|| return 1
done
}
_package() {
local _buildflavor="$1" _outdir="$2"
local _abi_release=${pkgver}-${pkgrel}-${_buildflavor}
cd "$srcdir"/build-$_buildflavor || return 1
mkdir -p "$_outdir"/boot "$_outdir"/lib/modules
local _install
case "$CARCH" in
arm*)
local _dtbdir="$_outdir"/usr/lib/linux-${_abi_release}
mkdir -p "$_dtbdir"
for i in arch/arm/boot/dts/*.dtb ; do
install -m644 "$i" "$_dtbdir"
done
_install=zinstall
;;
*)
_install=install
;;
esac
make -j1 modules_install $_install \
ARCH="$_carch" \
INSTALL_MOD_PATH="$_outdir" \
INSTALL_PATH="$_outdir"/boot \
|| return 1
rm -f "$_outdir"/lib/modules/${_abi_release}/build \
"$_outdir"/lib/modules/${_abi_release}/source
rm -rf "$_outdir"/lib/firmware
install -D include/config/kernel.release \
"$_outdir"/usr/share/kernel/$_buildflavor/kernel.release
}
# main flavor installs in $pkgdir
package() {
depends="$depends linux-firmware"
_package vanilla "$pkgdir"
}
# subflavors install in $subpkgdir
virt() {
_package virt "$subpkgdir"
}
_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}
# 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 \
|| return 1
make -j1 -C "$srcdir"/linux-$_kernver O="$dir" ARCH="$_carch" HOSTCC="$HOSTCC" \
silentoldconfig 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' \) \
-print | cpio -pdm "$dir" || return 1
cp -a scripts include "$dir" || return 1
find $(find arch -name include -type d -print) -type f \
| cpio -pdm "$dir"
install -Dm644 "$srcdir"/build-$_flavor/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="77e43a02d766c3d73b7e25c4aafb2e931d6b16e870510c22cef0cdb05c3acb7952b8908ebad12b10ef982c6efbe286364b1544586e715cf38390e483927904d8 linux-4.14.tar.xz
5373728be2b507c3db5e042e1d768740df7965078868afdc46418b1adc4cae3d8f9f1aedb59975a0f2acf8754340499354fcf97c503397a5d9886ccc9689b782 0001-HID-apple-fix-Fn-key-Magic-Keyboard-on-bluetooth.patch
b79afa544256df295ed2a904d917efe7048aa0d30951732d0809de1dd3e423c5f0138f16a1854a95df35f850c213fbaacde87a701f5cf6ed09349907e3d54744 config-vanilla.aarch64
251b9498b18929724b084718085709ba4f899820f3373231744918f7bc1d8d02554529ddcf249a6e952e55eb2c3d908c6fc2dacc773a44a3587e48dbdf3dd358 config-vanilla.armhf
60939f6d5aea7f591f6fa451a33101cdfe68f12b1246b63af8bd5f865b9f8c0e86b0edcf3ec7fe71e6ba77f0ab7f766b2b417111c8ecc4e3d375c12cfb84ddb7 config-vanilla.x86
bfe57873160d1c6c28dafc837b6bcb53df47fc2f9f6ecde8e2f1b4c66a9c474bc14a8dbfe8f4c74f762a40ff7d3207d09bbb4b44725b6d4d33540fa7095d6d54 config-vanilla.x86_64
03a14f009996319fc24fc1a4eae26e250f7cf6213bcdce0f82c3d0b4b54b81517f55e0445df0460d30f6b61f22519f04ac219ce3017c7cf72acd14c43e781a8b config-vanilla.ppc
e45f9e547ba193e2096e71b0e4a4632252eecfcc593b87446f31cd97a4e4792ab36b270e1c5f6c42d8f53a0e46b3239cd437fcec36e4c20ca98033b551bcad24 config-vanilla.ppc64le
10ecea3e0a101a898e347a42d74f9a3d8f226153cf487e1d65f59fb557b6fdaccab0d2ad6cf705c6cdeb5ed053eb7c5edecc655b3700e4ba237e965c0b6e417e config-vanilla.s390x
408a37fdf7dd467c1a874b0de54e72379378e2f4338a964fe2a50d80ddbb8916cb3bd23f000c6f57727384a24e011e06d5f4af6017453391e4cc60fd57892bda config-virt.x86
c6a7e5f405739856ceab097f878bcf102597ba33a375b8270ba1f0c59784204a587e0d0dbbbd1cd0fc52829552bf147019f7590bdc7034a0881ef5b327c40013 config-virt.x86_64
8617397002936b43c598350c562cb0dac1d93577b1b1e13478835f554d08289facf2051276db7a3eacfe1bd5aa2e5ffdbe3ba86d05454c6b4e27f42ea8f05945 patch-4.14.47.xz"
|