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

3
_flavor=grsec
4
pkgname=linux-${_flavor}
5
pkgver=3.10.15
6 7 8 9
case $pkgver in
*.*.*)	_kernver=${pkgver%.*};;
*.*)	_kernver=${pkgver};;
esac
10
pkgrel=0
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-$pkgver-unofficial.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
	fix-memory-map-for-PIE-applications.patch
29
	ipv6-udp-packets-following-an-UFO-enqueued-packet-needs-al.patch
30

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

38
_abi_release=${pkgver}-${pkgrel}-${_flavor}
39

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

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

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

67 68
	echo "-$pkgrel" > localversion-alpine

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

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

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

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

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

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

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

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

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

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

	install -Dm644 "$srcdir"/build/Module.symvers \
		"$dir"/Module.symvers
147 148 149 150

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

153
md5sums="4f25cd5bec5f8d5a7d935b3f2ccb8481  linux-3.10.tar.xz
154 155
70cc9bd12b04382c3783da96edda4562  patch-3.10.15.xz
84a82b973a08abc43cbf74a8935c59ae  grsecurity-2.9.1-3.10.15-unofficial.patch
156 157 158 159 160 161
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
162
c6a4ae7e8ca6159e1631545515805216  fix-memory-map-for-PIE-applications.patch
163
bbb9f3edd60fd5c53ac98f4eab83641c  ipv6-udp-packets-following-an-UFO-enqueued-packet-needs-al.patch
164 165
866e6c4daed45d563829804f8ad50ed9  kernelconfig.x86
272aaddd0a19a5052208bc25551995a3  kernelconfig.x86_64"
166
sha256sums="df27fa92d27a9c410bfe6c4a89f141638500d7eadcca5cce578954efc2ad3544  linux-3.10.tar.xz
167 168
bb0108609a95ddfe5030938e45ad123445af4e29510a0b1bd8cede89de8c013b  patch-3.10.15.xz
02736977e0abd475ba3c463b381186d306fd2f6c264968c47c685f0fce08c820  grsecurity-2.9.1-3.10.15-unofficial.patch
169 170 171 172 173 174
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
175
500f3577310be52e87b9fecdc2e9c4ca43210fd97d69089f9005d484563f74c7  fix-memory-map-for-PIE-applications.patch
176
4e2ac6cf0b5f6ef4c2f468aedb3f4b7a2737ef3abef4cf712492ba5daec4b30d  ipv6-udp-packets-following-an-UFO-enqueued-packet-needs-al.patch
177 178
7fd28634998ef1fddafed5f2516e902924245d2464b9e86476bfaa55ccfc3bc3  kernelconfig.x86
f2843ae4f9b3e3c27f3138ce4b740c2803bdab0c7a910c662d951843803b9554  kernelconfig.x86_64"
179
sha512sums="5fb109fcbd59bf3dffc911b853894f0a84afa75151368f783a1252c5ff60c7a1504de216c0012be446df983e2dea400ad8eeed3ce04f24dc61d0ef76c174dc35  linux-3.10.tar.xz
180 181
41f612dc912df68a69bb44343748be5c7b3c1525654890a1d896f466ef6aa22d35343f59a2c4319cde1858a6407f9366817c762670dd711d9ff2890291fa60cc  patch-3.10.15.xz
7838f4f43c1259d587979255a403b17be26d687aac91d43084417057267fd12643e99beccfbe21f22ed3d423080d9cdd7086598c8cc7e922ddae1024ce1f8005  grsecurity-2.9.1-3.10.15-unofficial.patch
182 183 184 185 186 187
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
188
4665c56ae1bbac311f9205d64918e84ee8b01d47d6e2396ff6b8adfb10aada7f7254531ce62e31edbb65c2a54a830f09ad05d314dfcd75d6272f4068945ad7c7  fix-memory-map-for-PIE-applications.patch
189
39fc019ac5ea5ada03c29846f22ddab0735e288bb3ad8d2109628e5d77d24bd09e6972eea6ee912768391399efe069e77c0e53b8a22329328bcc51f09f963f05  ipv6-udp-packets-following-an-UFO-enqueued-packet-needs-al.patch
190 191
1721542ff111c8ec550323dae6f6174131db180668cbf14f01dc4c76ffbbb479715919a80c35d8c8ac22a6479dd3b42700be6ddc5ef2a8b6a62de811c7ae86df  kernelconfig.x86
d49bf57bd0aae17d762d87d5bf983e48219d71ca44bc0c3120db94d357192c07146a8938cef9d435218e4bb748691ec426387545837be637d47e45cdc4482d71  kernelconfig.x86_64"