APKBUILD 8.3 KB
Newer Older
1
# Maintainer: Natanael Copa <ncopa@alpinelinux.org>
2

3
_flavor=grsec
4
pkgname=linux-${_flavor}
5
pkgver=3.9.8
6 7 8 9
case $pkgver in
*.*.*)	_kernver=${pkgver%.*};;
*.*)	_kernver=${pkgver};;
esac
10
pkgrel=1
11 12
pkgdesc="Linux kernel with grsecurity"
url=http://grsecurity.net
13
depends="mkinitfs linux-firmware"
Natanael Copa's avatar
Natanael Copa committed
14
makedepends="perl installkernel bash gmp-dev bc"
15
options="!strip"
Natanael Copa's avatar
Natanael Copa committed
16
_config=${config:-kernelconfig.${CARCH}}
17
install=
18
source="http://ftp.kernel.org/pub/linux/kernel/v3.x/linux-$_kernver.tar.xz
19
	http://ftp.kernel.org/pub/linux/kernel/v3.x/patch-$pkgver.xz
20
	grsecurity-2.9.1-3.9.8-201306302052.patch
21 22 23 24 25 26 27

	0001-net-inform-NETDEV_CHANGE-callbacks-which-flags-were-.patch
	0002-arp-flush-arp-cache-on-IFF_NOARP-change.patch
	0003-ipv4-properly-refresh-rtable-entries-on-pmtu-redirec.patch
	0004-ipv4-rate-limit-updating-of-next-hop-exceptions-with.patch
	0005-ipv4-use-separate-genid-for-next-hop-exceptions.patch
	0006-ipv4-use-next-hop-exceptions-also-for-input-routes.patch
28

29
	kernelconfig.x86
30
	kernelconfig.x86_64
31
	"
32
subpackages="$pkgname-dev"
33
arch="x86 x86_64 arm"
34
license="GPL-2"
Natanael Copa's avatar
Natanael Copa committed
35

36
_abi_release=${pkgver}-${pkgrel}-${_flavor}
37

38
prepare() {
39
	local _patch_failed=
40
	cd "$srcdir"/linux-$_kernver
41 42
	if [ "${pkgver%.0}" = "$pkgver" ]; then
		msg "Applying patch-$pkgver.xz"
43
		unxz -c < "$srcdir"/patch-$pkgver.xz | patch -p1 -N || return 1
44 45
	fi

46 47 48 49 50
	# first apply patches in specified order
	for i in $source; do
		case $i in
		*.patch)
			msg "Applying $i..."
51 52 53 54
			if ! patch -s -p1 -N -i "$srcdir"/$i; then
				echo $i >>failed
				_patch_failed=1
			fi
55 56
			;;
		esac
57 58
	done

59 60 61 62 63 64
	if ! [ -z "$_patch_failed" ]; then
		error "The following patches failed:"
		cat failed
		return 1
	fi

65 66
	echo "-$pkgrel" > localversion-alpine

67
	mkdir -p "$srcdir"/build
68
	cp "$srcdir"/$_config "$srcdir"/build/.config || return 1
69
	make -C "$srcdir"/linux-$_kernver O="$srcdir"/build HOSTCC="${CC:-gcc}" \
70
		silentoldconfig
71 72 73 74
}

# this is so we can do: 'abuild menuconfig' to reconfigure kernel
menuconfig() {
75
	cd "$srcdir"/build || return 1
76 77 78 79 80 81
	make menuconfig
	cp .config "$startdir"/$_config
}

build() {
	cd "$srcdir"/build
82
	export GCC_SPECS=/usr/share/gcc/hardenednopie.specs
83
	make CC="${CC:-gcc}" \
84 85
		KBUILD_BUILD_VERSION="$((pkgrel + 1 ))-Alpine" \
		|| return 1
86
}
Natanael Copa's avatar
Natanael Copa committed
87

88 89
package() {
	cd "$srcdir"/build
90
	mkdir -p "$pkgdir"/boot "$pkgdir"/lib/modules
Natanael Copa's avatar
Natanael Copa committed
91
	make -j1 modules_install firmware_install install \
92
		INSTALL_MOD_PATH="$pkgdir" \
93 94
		INSTALL_PATH="$pkgdir"/boot \
		|| return 1
95

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

100
	install -D include/config/kernel.release \
101
		"$pkgdir"/usr/share/kernel/$_flavor/kernel.release
Natanael Copa's avatar
Natanael Copa committed
102 103
}

104 105 106 107 108
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
	#
109
	# this way you dont need to install the 300-400 kernel sources to
110 111
	# build a tiny kernel module
	#
112
	pkgdesc="Headers and script for third party modules for grsec kernel"
113
	depends="gmp-dev bash"
114
	local dir="$subpkgdir"/usr/src/linux-headers-${_abi_release}
115

116
	# first we import config, run prepare to set up for building
117
	# external modules, and create the scripts
118
	mkdir -p "$dir"
119
	cp "$srcdir"/$_config "$dir"/.config
120
	make -j1 -C "$srcdir"/linux-$_kernver O="$dir" HOSTCC="${CC:-gcc}" \
121
		silentoldconfig prepare modules_prepare scripts 
122

123 124
	# remove the stuff that poits to real sources. we want 3rd party
	# modules to believe this is the soruces
125 126
	rm "$dir"/Makefile "$dir"/source

127 128
	# copy the needed stuff from real sources
	#
129
	# this is taken from ubuntu kernel build script
130
	# http://kernel.ubuntu.com/git?p=ubuntu/ubuntu-jaunty.git;a=blob;f=debian/rules.d/3-binary-indep.mk;hb=HEAD
131 132 133 134 135 136 137 138 139 140 141
	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"
142 143 144

	install -Dm644 "$srcdir"/build/Module.symvers \
		"$dir"/Module.symvers
145 146 147 148

	mkdir -p "$subpkgdir"/lib/modules/${_abi_release}
	ln -sf /usr/src/linux-headers-${_abi_release} \
		"$subpkgdir"/lib/modules/${_abi_release}/build
149 150
}

151
md5sums="4348c9b6b2eb3144d601e87c19d5d909  linux-3.9.tar.xz
152
c5f2166686a913abf550bfed8b77df27  patch-3.9.8.xz
153
647f77555169969b4245c62c0fd0f1ab  grsecurity-2.9.1-3.9.8-201306302052.patch
154 155 156 157 158 159
a16f11b12381efb3bec79b9bfb329836  0001-net-inform-NETDEV_CHANGE-callbacks-which-flags-were-.patch
656ae7b10dd2f18dbfa1011041d08d60  0002-arp-flush-arp-cache-on-IFF_NOARP-change.patch
aa454ffb96428586447775c21449e284  0003-ipv4-properly-refresh-rtable-entries-on-pmtu-redirec.patch
2a12a3717052e878c0cd42aa935bfcf4  0004-ipv4-rate-limit-updating-of-next-hop-exceptions-with.patch
6ce5fed63aad3f1a1ff1b9ba7b741822  0005-ipv4-use-separate-genid-for-next-hop-exceptions.patch
1a5800a2122ba0cc0d06733cb3bb8b8f  0006-ipv4-use-next-hop-exceptions-also-for-input-routes.patch
160 161
d89089b3c7eb94dd9f65cf8a357fc36d  kernelconfig.x86
eb147f09fef5996a488c247790205cd6  kernelconfig.x86_64"
162
sha256sums="60bc3e64ee5dc778de2cd7cd7640abf518a4c9d4f31b8ed624e16fad53f54541  linux-3.9.tar.xz
163
2eda9068e81269467e3c247f3343a146731fc45284b12b4bc546bc44dbb263e7  patch-3.9.8.xz
164
b111346072b7907d3a284f12a08c490cbfe35592537bc59442014c95080c3a33  grsecurity-2.9.1-3.9.8-201306302052.patch
165 166 167 168 169 170
6af3757ac36a6cd3cda7b0a71b08143726383b19261294a569ad7f4042c72df3  0001-net-inform-NETDEV_CHANGE-callbacks-which-flags-were-.patch
dc8e82108615657f1fb9d641efd42255a5761c06edde1b00a41ae0d314d548f0  0002-arp-flush-arp-cache-on-IFF_NOARP-change.patch
0985caa0f3ee8ed0959aeaa4214f5f8057ae8e61d50dcae39194912d31e14892  0003-ipv4-properly-refresh-rtable-entries-on-pmtu-redirec.patch
260fd1807838b68305a96992bf7d3302a2a8ef3a3b08fe079ba9a07e6422f736  0004-ipv4-rate-limit-updating-of-next-hop-exceptions-with.patch
ae32bb72afa170e6c3788c564b342763aba5945afacc1e2ebfc096adf50d77a3  0005-ipv4-use-separate-genid-for-next-hop-exceptions.patch
fc613ac466610b866b721c41836fd5bfb2d4b75bceb67972dc6369d7f62ff47e  0006-ipv4-use-next-hop-exceptions-also-for-input-routes.patch
171 172
de3c17420664ae4e52826c6e602aade0deeae94f72253f85b3e48771491ed5d6  kernelconfig.x86
e1cce320f207cc2ba72b9d154c7060c8cbed52c664319dfd21f24e8956d0bf3e  kernelconfig.x86_64"
173
sha512sums="77fa521f42380409f8ab400c26f7b00e225cb075ef40834bb263325cfdcc3e65aef8511ec2fc2b50bbf4f50e226fb5ab07d7a479aaf09162adbbf318325d0790  linux-3.9.tar.xz
174
60b7d694d39faf937e7b732eb3117b8442059c5c8857c9d439eec8a87d5bc185505e64062f5ae02c3512acf5af778caf615c35d3499cb8089a4569c05da65b9c  patch-3.9.8.xz
175
81912f5c19b8bc891a1ad8ed57bfe91d79c6c301410eb4ef9e58f57caefba2661d9732b306d695e712fd8e7c9b5bbb67659759fade26f4ec853d9cb96d347df9  grsecurity-2.9.1-3.9.8-201306302052.patch
176 177 178 179 180 181
81e78593288e8b0fd2c03ea9fc1450323887707f087e911f172450a122bc9b591ee83394836789730d951aeec13d0b75a64e1c05f04364abf8f80d883ddc4a02  0001-net-inform-NETDEV_CHANGE-callbacks-which-flags-were-.patch
51ecb15b669f6a82940a13a38939116e003bf5dfd24496771c8279e907b72adcc63d607f0340a2940d757e12ddadb7d45c7af78ae311d284935a6296dbcac00c  0002-arp-flush-arp-cache-on-IFF_NOARP-change.patch
57d0a8bd35d19cf657ded58efe24517d2252aec6984040713ba173a34edb5887ececaa2985076bc6a149eaa57639fd98a042c1c2d226ed4ad8dd5ed0e230717e  0003-ipv4-properly-refresh-rtable-entries-on-pmtu-redirec.patch
d2f578ad1d6e1fe52b55863e5bf338ae8201b828a498ec3e42e549c55295d3d1c6c3adfa9e226d711e3486628ed56ab996484e219d79ac4b0c0ec684ebd380aa  0004-ipv4-rate-limit-updating-of-next-hop-exceptions-with.patch
28a33e644bf2faf99c8dd6dbccfe14e140dfdd8824a8fb2d58aa7deb9e572f130d92b6b35ee181084050d82166bdf2e498a451a2a538a67b7ab84204405d2d87  0005-ipv4-use-separate-genid-for-next-hop-exceptions.patch
249140374c19a5599876268ff5b3cda2e136681aee103b4a9fff5d7d346f8e3295a907fb43db0701b8a9fece64c299ad2abac0434259cce6631307ce84090205  0006-ipv4-use-next-hop-exceptions-also-for-input-routes.patch
182 183
c51ac429c3e811976318a7ca2a4f7fc48bcf290e885ceeb09a1a56ee32c37b673f6e789789cf36876747bd54e4dc55d340ad888ba0eb8e7f45f60e8ef7ea67b4  kernelconfig.x86
584e778f96a05388051b05eb6f1c20377bc8aad72d0cd678323af7aaaab85ecc992244fe6bf3f27ab88131903490fd8af3c3fb56062490dd90dca1ba91d4da21  kernelconfig.x86_64"