summaryrefslogtreecommitdiff
path: root/aports/linux-lts/APKBUILD
blob: e7cc1383d43b7d81cff9e12e10530bff21ba5a87 (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
# Maintainer: Gabor Pali <pali.gabor@gmail.com>

pkgname=linux-lts
pkgver=5.15.35
case $pkgver in
	*.*.*)	_kernver=${pkgver%.*};;
	*.*) _kernver=$pkgver;;
esac
pkgrel=0
pkgdesc="Linux LTS kernel"
url="https://www.kernel.org"
depends=
makedepends="perl flex bison elfutils-dev sed installkernel bc linux-headers linux-firmware-any openssl1.1-compat-dev diffutils findutils zstd"
options="!strip"
install=
source="https://cdn.kernel.org/pub/linux/kernel/v${pkgver%%.*}.x/linux-$_kernver.tar.xz
	config-lts.x86_64
	"
subpackages=

if [ "${pkgver%.0}" = "$pkgver" ]; then
	source="$source
	https://cdn.kernel.org/pub/linux/kernel/v${pkgver%%.*}.x/patch-$pkgver.xz"
fi

arch="x86_64"
license="GPL-2.0"

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() {
	local _config=config-lts.x86_64
	local _builddir="$srcdir"/build-lts.x86_64
	mkdir -p "$_builddir"
	echo "-$pkgrel-lts" > "$_builddir"/localversion-alpine \
		|| return 1

	cp "$srcdir"/$_config "$_builddir"/.config
	make -C "$srcdir"/linux-$_kernver \
		O="$_builddir" \
		ARCH="x86_64" \
		listnewconfig oldconfig
}

build() {
	unset LDFLAGS
	export KBUILD_BUILD_TIMESTAMP="$(date -Ru${SOURCE_DATE_EPOCH:+d @$SOURCE_DATE_EPOCH})"
	cd "$srcdir"/build-lts.x86_64
	make ARCH="x86_64" CC="${CC:-gcc}" \
		KBUILD_BUILD_VERSION="$((pkgrel + 1 ))-Alpine"
}

package() {
	local _outdir="$pkgdir"
	local _abi_release=${pkgver}-${pkgrel}-lts
	export KBUILD_BUILD_TIMESTAMP="$(date -Ru${SOURCE_DATE_EPOCH:+d @$SOURCE_DATE_EPOCH})"

	cd "$srcdir"/build-lts.x86_64
	# 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

	make -j1 modules_install install \
		ARCH="x86_64" \
		INSTALL_MOD_PATH="$_outdir" \
		INSTALL_PATH="$_outdir"/boot \
		INSTALL_DTBS_PATH="$_outdir/boot/dtbs-lts"

	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/lts/kernel.release
}

sha512sums="
d25ad40b5bcd6a4c6042fd0fd84e196e7a58024734c3e9a484fd0d5d54a0c1d87db8a3c784eff55e43b6f021709dc685eb0efa18d2aec327e4f88a79f405705a  linux-5.15.tar.xz
9c636ad41e166cc06be1063040cafda9d1fe5afcc96310080970c4ca0c26a73bca30eafcd738a7d3830aede014a3ceab559b4e20d03810a056157b4daab977ea  config-lts.x86_64
3e4e3f4634bb170b5ddf5cf090c0b17968af44485b23e791d91124ecb578ab58220a6c988e8e8a1bf775e03d1683565aa3ab3eb21964dcd0c2950cc6033a4861  patch-5.15.35.xz
"