APKBUILD 4.9 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=9
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
	kernelconfig.x86
27
	kernelconfig.x86_64
28
	"
29
subpackages="$pkgname-dev"
30
arch="x86 x86_64 arm"
31
license="GPL-2"
Natanael Copa's avatar
Natanael Copa committed
32

33 34
_abi_release=${pkgver}-${_flavor}

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

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

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

62
	mkdir -p "$srcdir"/build
63
	cp "$srcdir"/$_config "$srcdir"/build/.config || return 1
64
	make -C "$srcdir"/linux-$_kernver O="$srcdir"/build HOSTCC="${CC:-gcc}" \
65
		silentoldconfig
66 67 68 69
}

# this is so we can do: 'abuild menuconfig' to reconfigure kernel
menuconfig() {
70
	cd "$srcdir"/build || return 1
71 72 73 74 75 76
	make menuconfig
	cp .config "$startdir"/$_config
}

build() {
	cd "$srcdir"/build
77
	export GCC_SPECS=/usr/share/gcc/hardenednopie.specs
78
	make CC="${CC:-gcc}" \
79 80
		KBUILD_BUILD_VERSION="$((pkgrel + 1 ))-Alpine" \
		|| return 1
81
}
Natanael Copa's avatar
Natanael Copa committed
82

83 84
package() {
	cd "$srcdir"/build
85
	mkdir -p "$pkgdir"/boot "$pkgdir"/lib/modules
Natanael Copa's avatar
Natanael Copa committed
86
	make -j1 modules_install firmware_install install \
87
		INSTALL_MOD_PATH="$pkgdir" \
88 89
		INSTALL_PATH="$pkgdir"/boot \
		|| return 1
90

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

95
	install -D include/config/kernel.release \
96
		"$pkgdir"/usr/share/kernel/$_flavor/kernel.release
Natanael Copa's avatar
Natanael Copa committed
97 98
}

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

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

118 119
	# remove the stuff that poits to real sources. we want 3rd party
	# modules to believe this is the soruces
120 121
	rm "$dir"/Makefile "$dir"/source

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

	install -Dm644 "$srcdir"/build/Module.symvers \
		"$dir"/Module.symvers
140 141 142 143

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

146
md5sums="1a1760420eac802c541a20ab51a093d1  linux-3.6.tar.xz
147
bd4bba74093405887d521309a74c19e9  patch-3.6.11.xz
148
4d225839f004e4133c5fa48b7ca0ddf5  patch-3.6.11-al2.patch
149
3838e6334ed957fd73e793e1816fe66c  grsecurity-2.9.1-3.6.11-al1-unofficial-0.patch
150
776adeeb5272093574f8836c5037dd7d  0004-arp-flush-arp-cache-on-device-change.patch
151
daf2cbb558588c49c138fe9ca2482b64  r8169-num-rx-desc.patch
152
d9b4a528e722d10ba53034ebd440c31b  ipv4-remove-output-route-check-in-ipv4_mtu.patch
153
63468b44e34fa19237e0a2a1f6737b14  0001-r8169-remove-the-obsolete-and-incorrect-AMD-workarou.patch
154
44a37e1289e1056300574848aea8bd31  r8169-fix-vlan-tag-reordering.patch
155 156
373db5888708938c6b1baed6da781fcb  kernelconfig.x86
190788fb10e79abce9d570d5e87ec3b4  kernelconfig.x86_64"