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

3
_flavor=grsec
4
pkgname=linux-${_flavor}
5 6
pkgver=2.6.35.7
_kernver=2.6.35
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.2.0-2.6.35.7-201010232009.patch
18
	0004-arp-flush-arp-cache-on-device-change.patch
19
	r8169-fix-rx-checksum-offload.patch
20
	r8169-add-gro-support.patch
21
	kernelconfig.x86
22
	"
23
subpackages="$pkgname-dev linux-firmware:firmware"
24
license="GPL-2"
Natanael Copa's avatar
Natanael Copa committed
25

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

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

35 36 37 38 39
	# first apply patches in specified order
	for i in $source; do
		case $i in
		*.patch)
			msg "Applying $i..."
40 41 42 43
			if ! patch -s -p1 -N -i "$srcdir"/$i; then
				echo $i >>failed
				_patch_failed=1
			fi
44 45
			;;
		esac
46 47
	done

48 49 50 51 52 53
	if ! [ -z "$_patch_failed" ]; then
		error "The following patches failed:"
		cat failed
		return 1
	fi

54 55
	mkdir -p "$srcdir"/build
	cp "$srcdir"/$_config "$srcdir"/build/.config
56
	make -C "$srcdir"/linux-$_kernver O="$srcdir"/build HOSTCC="${CC:-gcc}" \
57
		silentoldconfig
58 59 60 61
}

# this is so we can do: 'abuild menuconfig' to reconfigure kernel
menuconfig() {
62
	cd "$srcdir"/build || return 1
63 64 65 66 67 68
	make menuconfig
	cp .config "$startdir"/$_config
}

build() {
	cd "$srcdir"/build
69
	make CC="${CC:-gcc}" \
70 71
		KBUILD_BUILD_VERSION="$((pkgrel + 1 ))-Alpine" \
		|| return 1
72
}
Natanael Copa's avatar
Natanael Copa committed
73

74 75
package() {
	cd "$srcdir"/build
76
	mkdir -p "$pkgdir"/boot "$pkgdir"/lib/modules
77
	make modules_install firmware_install install \
78 79 80
		INSTALL_MOD_PATH="$pkgdir" \
		INSTALL_PATH="$pkgdir"/boot

81 82
	rm -f "$pkgdir"/lib/modules/${_abi_release}/build \
		"$pkgdir"/lib/modules/${_abi_release}/source
83
	install -D include/config/kernel.release \
84
		"$pkgdir"/usr/share/kernel/$_flavor/kernel.release
Natanael Copa's avatar
Natanael Copa committed
85 86
}

87 88 89 90 91
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
	#
92
	# this way you dont need to install the 300-400 kernel sources to
93 94
	# build a tiny kernel module
	#
95
	pkgdesc="Headers and script for third party modules for grsec kernel"
96
	local dir="$subpkgdir"/usr/src/linux-headers-${_abi_release}
97

98
	# first we import config, run prepare to set up for building
99
	# external modules, and create the scripts
100
	mkdir -p "$dir"
101
	cp "$srcdir"/$_config "$dir"/.config
102
	make -j1 -C "$srcdir"/linux-$_kernver O="$dir" HOSTCC="${CC:-gcc}" \
103 104
		silentoldconfig prepare scripts

105 106
	# remove the stuff that poits to real sources. we want 3rd party
	# modules to believe this is the soruces
107 108
	rm "$dir"/Makefile "$dir"/source

109 110
	# copy the needed stuff from real sources
	#
111
	# this is taken from ubuntu kernel build script
112
	# http://kernel.ubuntu.com/git?p=ubuntu/ubuntu-jaunty.git;a=blob;f=debian/rules.d/3-binary-indep.mk;hb=HEAD
113 114 115 116 117 118 119 120 121 122 123
	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"
124 125 126

	install -Dm644 "$srcdir"/build/Module.symvers \
		"$dir"/Module.symvers
127 128 129 130

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

133 134 135 136 137 138 139
firmware() {
	pkgdesc="Firmware for linux kernel"
	replaces="linux-grsec linux-vserver"
	mkdir -p "$subpkgdir"/lib
	mv "$pkgdir"/lib/firmware "$subpkgdir"/lib/
}

140 141 142
md5sums="091abeb4684ce03d1d936851618687b6  linux-2.6.35.tar.bz2
6a00ec267b0100f20a3fa900b97a5b7f  patch-2.6.35.7.bz2
4a1ceddc62ff83b136f32dbab50e15f8  grsecurity-2.2.0-2.6.35.7-201010232009.patch
143
776adeeb5272093574f8836c5037dd7d  0004-arp-flush-arp-cache-on-device-change.patch
144
0ccecafd4123dcad0b0cd7787553d734  r8169-fix-rx-checksum-offload.patch
145
139b39da44ecb577275be53d7d365949  r8169-add-gro-support.patch
146
f6b46f11945c77d01679c87e95d512ee  kernelconfig.x86"