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

_flavor=vanilla
pkgname=linux-${_flavor}
pkgver=4.4.27
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="http://ftp.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

	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" ;;
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}" \
		KCFLAGS="-fno-pie" \
		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" \
		KCFLAGS="-fno-pie" \
		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
976d8b7e42c210d8d3b25d2260974289  config-vanilla.aarch64
6f923d5029129429bceae658a832ff4c  config-vanilla.armhf
60c2b6b5d9c671470fff8266555ad3d8  config-vanilla.x86
1b7e060937dd969d42480e48b516b721  config-vanilla.x86_64
e10e580b7aadf42ba595e35d3ff3fc69  0001-Add-dts-for-GIGABYTE-X-Gene-MP30-AR0.patch
30f92f72f977f27a767655deda8f1097  patch-4.4.27.xz"
sha256sums="401d7c8fef594999a460d10c72c5a94e9c2e1022f16795ec51746b0d165418b2  linux-4.4.tar.xz
223ea86754f402f6aabb4a1e4be6a1a4eb9d1d82f5009291f95cf141fa0ddb3d  config-vanilla.aarch64
6a923534767f24e0adc515e4c29ee7b95498be4fc0c9ba61142669bacd8d7cb0  config-vanilla.armhf
e7df86b65f7064eca60b8ac5a21260161a4eae8a48b6dfe7f057751f119c492a  config-vanilla.x86
70d4f132f8fd55df918b7f6a1348b9901644117c48acb4cff6731e461ef538a9  config-vanilla.x86_64
b9bcbe11c017764075179fb61fb13f6d0eca2c5495402d8f4ace2331cfe0c0b4  0001-Add-dts-for-GIGABYTE-X-Gene-MP30-AR0.patch
578caffa00f5056a921f672c585734cd572b1e3e33227b71a54ef27873f7ea20  patch-4.4.27.xz"
sha512sums="13c8459933a8b80608e226a1398e3d1848352ace84bcfb7e6a4a33cb230bbe1ab719d4b58e067283df91ce5311be6d2d595fc8c19e2ae6ecc652499415614b3e  linux-4.4.tar.xz
f60eaafca6c30c065293606e584a822cff6634d19b2be5a28a18745c3e2c8463b410cae1bf259c055a271c6e99037b57b4fb6d9d566d1e90899297943685437d  config-vanilla.aarch64
b31f3708f177f4841e89e7eb01a4e93bd977c79f3255522c01c1664d36fd680dfaf31fb407d6e00b0a4dcee31f8e7daba5119b51377a3a6056f37aefb9067da2  config-vanilla.armhf
84f1779ab4ee7bbdcddca2c713947af0768d2b29e53f607c728b7c2f7de64bf5d9b5e1556e0d2a8479ff7a15a8532e38fd949098fd478bcbf571707d0aef5c3c  config-vanilla.x86
cacc61470c25934fff51dcdf2f6188aeb833eb881399d6b7f97548e399095c3279704655dc090ce3a56c089e8b0fb101e1469500f79b4fd28b4335658435b901  config-vanilla.x86_64
ebc1b89ff0985246889f68c32fb0bd326eb0f015a97b913bf8e2b92855c75809d114c57aff8f3f74d120694f1c5891d7a11ebe4aadaadd1954a947e762bf121d  0001-Add-dts-for-GIGABYTE-X-Gene-MP30-AR0.patch
18d68cb6957eaf06c54ac79766f3e4f87094a54d24e2e0d7578d929a705bc119b5767250c88b5fbae5fc85de05a9d2287fa77dde19669c00a82ebf2f48a4ad2a  patch-4.4.27.xz"