aboutsummaryrefslogtreecommitdiffstats
path: root/main/linux-lts/APKBUILD
blob: b0f5f16336609f3cbca70adac8cf10a2f13dc52d (plain) (blame)
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
# Maintainer: Natanael Copa <ncopa@alpinelinux.org>

_flavor=lts
pkgname=linux-${_flavor}
pkgver=5.4.73
case $pkgver in
	*.*.*)	_kernver=${pkgver%.*};;
	*.*) _kernver=$pkgver;;
esac
pkgrel=0
pkgdesc="Linux lts kernel"
url="https://www.kernel.org"
depends="mkinitfs"
_depends_dev="perl gmp-dev elfutils-dev bash flex bison"
makedepends="$_depends_dev sed installkernel bc linux-headers linux-firmware-any openssl-dev
	diffutils"
options="!strip"
_config=${config:-config-lts.${CARCH}}
install=
source="https://cdn.kernel.org/pub/linux/kernel/v${pkgver%%.*}.x/linux-$_kernver.tar.xz
	0002-powerpc-config-defang-gcc-check-for-stack-protector-.patch

	0001-arm64-dts-lx2160a-add-mdio-device-tree-nodes.patch
	0001-arm64-dts-lx2160a-add-lx2160acex7-device-tree-build.patch
	0002-arm64-dts-lx2160a-add-lx2160acex7-device-tree.patch
	0005-arm64-dts-lx2160a-cex7-add-ltc3882-support.patch
	0006-arm64-dts-lx2160a-cex7-add-on-module-eeproms.patch
	0007-pci-hotplug-declare-IDT-bridge-as-hotpluggabl-bridge.patch
	0008-pci-spr2803-quirk-to-fix-class-ID.patch

	config-lts.aarch64
	config-lts.armv7
	config-lts.x86
	config-lts.x86_64
	config-lts.ppc64le
	config-lts.s390x
	config-lts.mips64
	config-lts.mips

	config-virt.aarch64
	config-virt.armv7
	config-virt.ppc64le
	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 !armhf"
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

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
	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*
	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-$_flavor"

	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 include/config/kernel.release \
		"$_outdir"/usr/share/kernel/$_buildflavor/kernel.release
}

# main flavor installs in $pkgdir
package() {
	depends="$depends linux-firmware-any"

	_package lts "$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}
	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="9f60f77e8ab972b9438ac648bed17551c8491d6585a5e85f694b2eaa4c623fbc61eb18419b2656b6795eac5deec0edaa04547fc6723fbda52256bd7f3486898f  linux-5.4.tar.xz
d19365fe94431008768c96a2c88955652f70b6df6677457ee55ee95246a64fdd2c6fed9b3bef37c29075178294a7fc91f148ead636382530ebfa822be4ad8c2f  0002-powerpc-config-defang-gcc-check-for-stack-protector-.patch
cfcd03668a80944706c66f89055f641c972c1839bf33123c19d63681d3d3958c8a0d4ab0679af9b921d0e9fd0c25445b8c417a21d1519e3d196780a0d5bd1520  0001-arm64-dts-lx2160a-add-mdio-device-tree-nodes.patch
1c87556c43b20c70e40d628624f0043a7dea1c3e66be26e15f594a1aed449a11f214795617d25309e1c1d5af92ec644222c4e68be652be043bdda80af0c0ece2  0001-arm64-dts-lx2160a-add-lx2160acex7-device-tree-build.patch
e75ab07e3d2d0d3fd085fb4132b3fee1650ae3bf1b6eaefe1f92b90071547a4f3ceef35ad4ce0f9345e78fac2de1697f6db3de1a526e730262be7ff299bd0038  0002-arm64-dts-lx2160a-add-lx2160acex7-device-tree.patch
d27bf4b8169ac047f60beae326da8f5e4d4f887c893cb4dd97f87d0c363d02e00704bf07d2026d9fd622b612cd9abbebfe4c5adfb7c033d73939b959e9652add  0005-arm64-dts-lx2160a-cex7-add-ltc3882-support.patch
926cb8f9a15f82bb90db962c9b7f7cbb3dbb754d3b1a0d7d12c0593ea60de8f07744ccd7c86e0e43daf1eab3392cc8624786680e1244fa96982e676a908ab88d  0006-arm64-dts-lx2160a-cex7-add-on-module-eeproms.patch
ca5aafac37e0b5f3fcbaf801e12f98beb58ffaf1d8c88f76caff22b059831869b4094e7fdcb6d6860422d6b2d036e072caff460e1feb84bd04d10740ad56265b  0007-pci-hotplug-declare-IDT-bridge-as-hotpluggabl-bridge.patch
cbe85cf34e8420c91d2276c2d2aa0ab5023af68e57a1fa613f073f16a76766c67f585eda71c28f232bd0625e0dc8275a9eddc95f49409205dc0dbcc28c9fac1c  0008-pci-spr2803-quirk-to-fix-class-ID.patch
420a09ff89e2d7398700c7101e147b04c4475358e2dcc20ba1ba6b6ad070d9a908142696f2197b63bcc7d5067fb42319a47481d0ea525d7a819e9b9a81ab9c07  config-lts.aarch64
5072c9dee618b4359ad0ddbfcb093ac58458ac02ae0a6f286b29062c6511995289836503afe271ccd0a89d46cf1f84f490515e2c5831f02805ba1725e7982f1d  config-lts.armv7
b50da290de10c207cf5a4fd3add289bc3588779ca7a9794920db1037654bdbcaf6605edce6abcedf1f731814bb6d5ab3beca82b27c3577139aa4d34e09e9d729  config-lts.x86
fc578b6b822479610b8d59695bc92b0a87fb94b193b42f4990901f65741cbb6931a743b8691dee243222b5ff78742c8687d070b5c14c6ab85f3aa06779fab8fb  config-lts.x86_64
3c53f06e5c0e8761cccaf02450758f339966d0ebf9cec6fe26544d64def3be4f08b8e101488239e5c6f506f6f6d76bf3cdf9b58d0e2f333781c173ac0b353a88  config-lts.ppc64le
fe7dcc1a54602e87a508fcb3aff71c94d31f977d1cebf55cc617fa824f16d716c2b62393251830d8002372061f108e63ebc685e70172c1c00f996bb5045afe5e  config-lts.s390x
318a386eed6b0972e8960e32355f67c9b1ae2dcc6e561f78424e236431adf4cb1937a5d5b79af4fc298ac62aa6cf4138a0647f4709efaabfc892eab2af5c784d  config-lts.mips64
692770ff415a0bdf8e430d7c0f5b139f7fe5498a533db869077f4b4571b8342a13cc4e1bf111d297ca437d23f1e821fe52e5d1ad7266ac3073b665bdf93c0160  config-lts.mips
e7e2472509e3b6a473591a7fce5da4403082a0ef61aeeb31a2a57ddd4f722d72a1deacf39b26c9c287fa3ef1465acca3a1640c56ce463ae97e65a0d736906c21  config-virt.aarch64
aa31cc527adcc13195bc4caa7e6500a79b0be250a6206a9526266440a062bba80183ce3664c2e58910df1de22557f5309efda20db62f7f356da15ab52eb80eae  config-virt.armv7
6a8490d4ca6f68ddfffe323280d5debe57b3d441b3590659d0fb8e646340ca113f38586fca715ce07a280acd7436608de8623e7afc84942eda5dc09d351e4ca5  config-virt.ppc64le
b134d4327540f0bdf88c64424283abee895fc612f3cfde3f1881b5d65fda9f5f06f07cb74d281cb17f785136f482842d4f2893d8df03bece7ad13e4b2bdb9a3d  config-virt.x86
68eaf16e263507a1f550c272a17382413a10b9c46586c9f0828224e1d824fabd14d9f9cf5de8ec023f266b53e602132dbbd3c14e12d9e436515a07396f47968a  config-virt.x86_64
3e0cdb783e8c008c09d7c5ea7fdc8e5af42cacab297ddc4c7c9816140eb4dee4061e550f51f47810db8e84a0c41fb1dba9e95ff18dc08a7e233c99a67fc415e3  patch-5.4.73.xz"