aboutsummaryrefslogtreecommitdiffstats
path: root/main/linux-vanilla/APKBUILD
blob: 01f2589dec6fdf8f94ddb9d1dd7aa5a048d91326 (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
# Maintainer: Natanael Copa <ncopa@alpinelinux.org>

_flavor=vanilla
pkgname=linux-${_flavor}
pkgver=4.4.45
case $pkgver in
	*.*.*)	_kernver=${pkgver%.*};;
	*.*) _kernver=$pkgver;;
esac
pkgrel=0
pkgdesc="Linux vanilla kernel"
url="http://kernel.org"
depends="mkinitfs linux-firmware"
makedepends="perl sed installkernel bash gmp-dev bc linux-headers"
options="!strip"
_config=${config:-config-vanilla.${CARCH}}
install=
source="https://kernel.org/pub/linux/kernel/v${pkgver%%.*}.x/linux-$_kernver.tar.xz
	config-vanilla.aarch64
	config-vanilla.armhf
	config-vanilla.x86
	config-vanilla.x86_64
	config-vanilla.ppc
	config-vanilla.ppc64le

	0001-Add-dts-for-GIGABYTE-X-Gene-MP30-AR0.patch
	"
if [ "${pkgver%.0}" = "$pkgver" ]; then
	source="$source
	http://ftp.kernel.org/pub/linux/kernel/v${pkgver%%.*}.x/patch-$pkgver.xz"
fi
subpackages="$pkgname-dev"
arch="all"
license="GPL2"

_abi_release=${pkgver}
_carch=${CARCH}
case "$_carch" in
aarch64*) _carch="arm64" ;;
arm*) _carch="arm" ;;
ppc*) _carch="powerpc" ;;
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

	mkdir -p "$srcdir"/build
	cp "$srcdir"/$_config "$srcdir"/build/.config || return 1
	make -C "$srcdir"/linux-$_kernver O="$srcdir"/build ARCH="$_carch" HOSTCC="$HOSTCC" \
		silentoldconfig
}

# this is so we can do: 'abuild menuconfig' to reconfigure kernel
menuconfig() {
	cd "$srcdir"/build || return 1
	make ARCH="$_carch" menuconfig
	cp .config "$startdir"/$_config
}

build() {
	cd "$srcdir"/build
	make ARCH="$_carch" CC="${CC:-gcc}" \
		KBUILD_BUILD_VERSION="$((pkgrel + 1 ))-Alpine" \
		|| return 1
}

package() {
	cd "$srcdir"/build

	mkdir -p "$pkgdir"/boot "$pkgdir"/lib/modules

	local _install
	case "$CARCH" in
	aarch64*|arm*)	_install="zinstall dtbs_install" ;;
	*)		_install="install" ;;
	esac

	make -j1 modules_install firmware_install $_install \
		ARCH="$_carch" \
		INSTALL_MOD_PATH="$pkgdir" \
		INSTALL_PATH="$pkgdir"/boot \
		INSTALL_DTBS_PATH="$pkgdir"/usr/lib/linux-${_abi_release} \
		|| return 1

	rm -f "$pkgdir"/lib/modules/${_abi_release}/build \
		"$pkgdir"/lib/modules/${_abi_release}/source
	rm -rf "$pkgdir"/lib/firmware

	install -D include/config/kernel.release \
		"$pkgdir"/usr/share/kernel/$_flavor/kernel.release
}

dev() {
	# 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 grsec kernel"
	depends="gmp-dev bash"
	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 "$dir"/.config
	make -j1 -C "$srcdir"/linux-$_kernver O="$dir" ARCH="$_carch" HOSTCC="$HOSTCC" \
		silentoldconfig prepare modules_prepare scripts 

	# remove the stuff that poits 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?p=ubuntu/ubuntu-jaunty.git;a=blob;f=debian/rules.d/3-binary-indep.mk;hb=HEAD
	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' \) | cpio -pdm "$dir"
	cp -a drivers/media/dvb/dvb-core/*.h "$dir"/drivers/media/dvb/dvb-core
	cp -a drivers/media/video/*.h "$dir"/drivers/media/video
	cp -a drivers/media/dvb/frontends/*.h "$dir"/drivers/media/dvb/frontends
	cp -a scripts include "$dir"
	find $(find arch -name include -type d -print) -type f \
		| cpio -pdm "$dir"

	install -Dm644 "$srcdir"/build/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
}

md5sums="9a78fa2eb6c68ca5a40ed5af08142599  linux-4.4.tar.xz
fb219ff405db2d34ab1f7d052d2d2fbb  config-vanilla.aarch64
ec4bd577f32f24143def18f66c59bb18  config-vanilla.armhf
4497f7a7891e82cb145b0b9e9be48e99  config-vanilla.x86
73e220a5f6d5975a7c577524e53613f0  config-vanilla.x86_64
91b766efc7d356eacd4895cc328b7fe1  config-vanilla.ppc
e9a904a8419976b6f4a87e32ef003fdd  config-vanilla.ppc64le
e10e580b7aadf42ba595e35d3ff3fc69  0001-Add-dts-for-GIGABYTE-X-Gene-MP30-AR0.patch
8c83b4bc6b233bd87d8f75e92086583d  patch-4.4.45.xz"
sha256sums="401d7c8fef594999a460d10c72c5a94e9c2e1022f16795ec51746b0d165418b2  linux-4.4.tar.xz
4bcde0ce497ef057006dd98915aab5797eab0a84598aad03260e3a3f4413f572  config-vanilla.aarch64
223d31ce209e61a299ac314340cb82ebbe1c18167a09dedff317f0c4bee2d6a9  config-vanilla.armhf
005a169fbe77e9e0e35bb9783d6f526dc43335846c2cf97c94e68a20c6e76bca  config-vanilla.x86
0dff4ba5f486ecb573ffaa2088e323d6a494d096ebda3b58db7ab954038c0e4f  config-vanilla.x86_64
a8e465d96c743621273f77eddefa476b21947194bc174290671e2a8165557e61  config-vanilla.ppc
178c467d8a0fb85491fc4fc966375a712398e753ebd8b020d05368049a8a35e6  config-vanilla.ppc64le
b9bcbe11c017764075179fb61fb13f6d0eca2c5495402d8f4ace2331cfe0c0b4  0001-Add-dts-for-GIGABYTE-X-Gene-MP30-AR0.patch
8d359628e1b6918308998510f6f5724b7f5f27016bcaee3760f4ad1f4a8a93fb  patch-4.4.45.xz"
sha512sums="13c8459933a8b80608e226a1398e3d1848352ace84bcfb7e6a4a33cb230bbe1ab719d4b58e067283df91ce5311be6d2d595fc8c19e2ae6ecc652499415614b3e  linux-4.4.tar.xz
897b4b7d4dc2b5a72f4497283d5b90336e6097e79872325255296c01498389c883f1a266f8732833ab492936fbdb1d32606b0c8e67136c7b90268352b56e8cad  config-vanilla.aarch64
2e8711861f7765cb35f70b905dc40189b1436afca11b35b3000a426d4c1afed2d9028ef71589e37340ed0c0e5e12abe45375d122712dec47d2edc0df7ea73faf  config-vanilla.armhf
74f1fe3bb14800688fca27c5dd7943d357af4f1f9703b04553d7479fcf6aabd0304a2df4b6f7fff65d6c7fecf86dae3199814d6516d30b7688b6f5f78b354070  config-vanilla.x86
bcf576c45626236928d987feaab3a3be0852a7cc33ede71f4148548a1146955df56bef82816f3285c2d4b1a44d26f99e35adb5bbeada0cf5d7a3db5b1939e804  config-vanilla.x86_64
8e28e997eb8847b395f2f3accf675c7fd6ba0c3dda71c7caf9d5429ca1be227ce417ff04b7696cde01ce24e8c5cc26d4ae879feaf514d2f63b3eb7702698efed  config-vanilla.ppc
59474c6a5d96abb081430d88aec500f1e4d0ddf6ae006d06c1db069c680c509306ded0234a27ce07d8fcfd32481e6dd7402f4e6fc198833c0ed65b3887559683  config-vanilla.ppc64le
ebc1b89ff0985246889f68c32fb0bd326eb0f015a97b913bf8e2b92855c75809d114c57aff8f3f74d120694f1c5891d7a11ebe4aadaadd1954a947e762bf121d  0001-Add-dts-for-GIGABYTE-X-Gene-MP30-AR0.patch
37c8fb23b9456e67f515ac3baf03a5eecd1fcbf534d222564579ba47db19c2ccff92275fc977279c49d1e8df3c7e51e64552446f1789cd08c7d994b8367bfe2b  patch-4.4.45.xz"