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

3
_flavor=grsec
4
pkgname=linux-${_flavor}
5
pkgver=2.6.32.9
6
_kernver=2.6.32
7
pkgrel=1
8 9
pkgdesc="Linux kernel with grsecurity"
url=http://grsecurity.net
10
depends="mkinitfs linux-firmware"
11
makedepends="perl installkernel"
12
options="!strip"
13
_config=${config:-kernelconfig.${CARCH:-x86}}
14
install=
15 16
source="ftp://ftp.kernel.org/pub/linux/kernel/v2.6/linux-$_kernver.tar.bz2
	ftp://ftp.kernel.org/pub/linux/kernel/v2.6/patch-$pkgver.bz2
17
	grsecurity-2.1.14-2.6.32.9-201002231820.patch
18 19
	ip_gre.patch
	arp.patch
20
	kernelconfig.x86
21
	"
22
subpackages="$pkgname-dev linux-firmware:firmware"
23
license="GPL-2"
Natanael Copa's avatar
Natanael Copa committed
24

25 26
_abi_release=${pkgver}-${_flavor}

27
prepare() {
28 29
	cd "$srcdir"/linux-$_kernver
	if [ "$_kernver" != "$pkgver" ]; then
30
		bunzip2 -c < ../patch-$pkgver.bz2 | patch -p1 -N || return 1
31 32
	fi

33
	for i in ../*.diff ../*.patch; do
34
		[ -f $i ] || continue
35
		msg "Applying $i..."
36
		patch -s -p1 -N < $i || return 1
37 38 39 40
	done

	mkdir -p "$srcdir"/build
	cp "$srcdir"/$_config "$srcdir"/build/.config
41
	make -C "$srcdir"/linux-$_kernver O="$srcdir"/build HOSTCC="$CC" \
42
		silentoldconfig
43 44 45 46
}

# this is so we can do: 'abuild menuconfig' to reconfigure kernel
menuconfig() {
47
	cd "$srcdir"/build || return 1
48 49 50 51 52 53
	make menuconfig
	cp .config "$startdir"/$_config
}

build() {
	cd "$srcdir"/build
54
	make CC="$CC" || return 1
55
}
Natanael Copa's avatar
Natanael Copa committed
56

57 58
package() {
	cd "$srcdir"/build
59
	mkdir -p "$pkgdir"/boot "$pkgdir"/lib/modules
Natanael Copa's avatar
Natanael Copa committed
60
	make modules_install install \
61 62 63
		INSTALL_MOD_PATH="$pkgdir" \
		INSTALL_PATH="$pkgdir"/boot

64 65
	rm -f "$pkgdir"/lib/modules/${_abi_release}/build \
		"$pkgdir"/lib/modules/${_abi_release}/source
66
	install -D include/config/kernel.release \
67
		"$pkgdir"/usr/share/kernel/$_flavor/kernel.release
Natanael Copa's avatar
Natanael Copa committed
68 69
}

70 71 72 73 74 75 76 77
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
	#
78
	pkgdesc="Headers and script for third party modules for grsec kernel"
79
	local dir="$subpkgdir"/usr/src/linux-headers-${_abi_release}
80 81 82

	# first we import config, run prepare to set up for building 
	# external modules, and create the scripts
83
	mkdir -p "$dir"
84
	cp "$srcdir"/$_config "$dir"/.config
85
	make -j1 -C "$srcdir"/linux-$_kernver O="$dir" HOSTCC="$CC" \
86 87
		silentoldconfig prepare scripts

88 89
	# remove the stuff that poits to real sources. we want 3rd party
	# modules to believe this is the soruces
90 91
	rm "$dir"/Makefile "$dir"/source

92 93
	# copy the needed stuff from real sources
	#
94
	# this is taken from ubuntu kernel build script
95
	# http://kernel.ubuntu.com/git?p=ubuntu/ubuntu-jaunty.git;a=blob;f=debian/rules.d/3-binary-indep.mk;hb=HEAD
96 97 98 99 100 101 102 103 104 105 106
	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"
107 108 109

	install -Dm644 "$srcdir"/build/Module.symvers \
		"$dir"/Module.symvers
110 111 112 113

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

116 117 118 119 120 121 122
firmware() {
	pkgdesc="Firmware for linux kernel"
	replaces="linux-grsec linux-vserver"
	mkdir -p "$subpkgdir"/lib
	mv "$pkgdir"/lib/firmware "$subpkgdir"/lib/
}

123
md5sums="260551284ac224c3a43c4adac7df4879  linux-2.6.32.tar.bz2
124 125
7f615dd3b4a3b19fb86e479996a2deb5  patch-2.6.32.9.bz2
7da77829d4d994498218c412caed1db8  grsecurity-2.1.14-2.6.32.9-201002231820.patch
126 127
3ef822f3a2723b9a80c3f12954457225  ip_gre.patch
4c39a161d918e7f274292ecfd168b891  arp.patch
128
782074af6a1f1b1b1c9a33f5ac1b42bf  kernelconfig.x86"