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

3
_flavor=grsec
4
pkgname=linux-${_flavor}
5
pkgver=3.6.11
6
_kernver=3.6
7
pkgrel=10
8 9
pkgdesc="Linux kernel with grsecurity"
url=http://grsecurity.net
10
depends="mkinitfs linux-firmware"
Natanael Copa's avatar
Natanael Copa committed
11
makedepends="perl installkernel bash gmp-dev"
12
options="!strip"
Natanael Copa's avatar
Natanael Copa committed
13
_config=${config:-kernelconfig.${CARCH}}
14
install=
15
source="http://ftp.kernel.org/pub/linux/kernel/v3.x/linux-$_kernver.tar.xz
16
	http://ftp.kernel.org/pub/linux/kernel/v3.x/patch-$pkgver.xz
17
	patch-3.6.11-al2.patch
18
	grsecurity-2.9.1-3.6.11-al1-unofficial-0.patch
19 20
	
	0004-arp-flush-arp-cache-on-device-change.patch
21
	r8169-num-rx-desc.patch
22
	ipv4-remove-output-route-check-in-ipv4_mtu.patch
23
	0001-r8169-remove-the-obsolete-and-incorrect-AMD-workarou.patch
24
	r8169-fix-vlan-tag-reordering.patch
25

26 27 28 29 30 31
	xsa39-pvops-0001-xen-netback-shutdown-the-ring-if-it-contains-garbage.patch
	xsa39-pvops-0002-xen-netback-don-t-leak-pages-on-failure-in-xen_netbk.patch
	xsa39-pvops-0003-xen-netback-free-already-allocated-memory-on-failure.patch
	xsa39-pvops-0004-netback-correct-netbk_tx_err-to-handle-wrap-around.patch


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

39 40
_abi_release=${pkgver}-${_flavor}

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

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

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

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

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

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

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

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

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

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

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

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

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

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

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

152
md5sums="1a1760420eac802c541a20ab51a093d1  linux-3.6.tar.xz
153
bd4bba74093405887d521309a74c19e9  patch-3.6.11.xz
154
4d225839f004e4133c5fa48b7ca0ddf5  patch-3.6.11-al2.patch
155
3838e6334ed957fd73e793e1816fe66c  grsecurity-2.9.1-3.6.11-al1-unofficial-0.patch
156
776adeeb5272093574f8836c5037dd7d  0004-arp-flush-arp-cache-on-device-change.patch
157
daf2cbb558588c49c138fe9ca2482b64  r8169-num-rx-desc.patch
158
d9b4a528e722d10ba53034ebd440c31b  ipv4-remove-output-route-check-in-ipv4_mtu.patch
159
63468b44e34fa19237e0a2a1f6737b14  0001-r8169-remove-the-obsolete-and-incorrect-AMD-workarou.patch
160
44a37e1289e1056300574848aea8bd31  r8169-fix-vlan-tag-reordering.patch
161 162 163 164
706652ed6c17c5f7bb46a6c8318f9e75  xsa39-pvops-0001-xen-netback-shutdown-the-ring-if-it-contains-garbage.patch
286101482a2e4b7d8c0dff16af36b3e9  xsa39-pvops-0002-xen-netback-don-t-leak-pages-on-failure-in-xen_netbk.patch
89dbb0886c9d17c3c4a5ff4f1443e936  xsa39-pvops-0003-xen-netback-free-already-allocated-memory-on-failure.patch
bce9f08c86570a0a86ef36f1d2e7a2dd  xsa39-pvops-0004-netback-correct-netbk_tx_err-to-handle-wrap-around.patch
165 166
373db5888708938c6b1baed6da781fcb  kernelconfig.x86
190788fb10e79abce9d570d5e87ec3b4  kernelconfig.x86_64"