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

3
_flavor=grsec
4
pkgname=linux-${_flavor}
5
pkgver=2.6.35.8
6
_kernver=2.6.35
7
pkgrel=4
8 9
pkgdesc="Linux kernel with grsecurity"
url=http://grsecurity.net
10
depends="mkinitfs linux-firmware"
11
makedepends="perl installkernel bash"
12
options="!strip"
Natanael Copa's avatar
Natanael Copa committed
13
_config=${config:-kernelconfig.${CARCH}}
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.8-201011062054.patch
18
	0001-xfrm-use-gre-key-as-flow-upper-protocol-info.patch
19
	0004-arp-flush-arp-cache-on-device-change.patch
20
	r8169-fix-rx-checksum-offload.patch
21
	r8169-add-gro-support.patch
22
	setlocalversion.patch
23
	kernelconfig.x86
24
	kernelconfig.x86_64
25
	"
26
subpackages="$pkgname-dev linux-firmware:firmware"
27
license="GPL-2"
Natanael Copa's avatar
Natanael Copa committed
28

29 30
_abi_release=${pkgver}-${_flavor}

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

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

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

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

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

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

77 78
package() {
	cd "$srcdir"/build
79
	mkdir -p "$pkgdir"/boot "$pkgdir"/lib/modules
Natanael Copa's avatar
Natanael Copa committed
80
	make -j1 modules_install firmware_install install \
81
		INSTALL_MOD_PATH="$pkgdir" \
82 83
		INSTALL_PATH="$pkgdir"/boot \
		|| return 1
84

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

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

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

109 110
	# remove the stuff that poits to real sources. we want 3rd party
	# modules to believe this is the soruces
111 112
	rm "$dir"/Makefile "$dir"/source

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

	install -Dm644 "$srcdir"/build/Module.symvers \
		"$dir"/Module.symvers
131 132 133 134

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

137 138 139 140 141 142 143
firmware() {
	pkgdesc="Firmware for linux kernel"
	replaces="linux-grsec linux-vserver"
	mkdir -p "$subpkgdir"/lib
	mv "$pkgdir"/lib/firmware "$subpkgdir"/lib/
}

144
md5sums="091abeb4684ce03d1d936851618687b6  linux-2.6.35.tar.bz2
145
198e4e72ea9cc7f9f25bb5881167aa2e  patch-2.6.35.8.bz2
146
d5832cb57522a666a80227f68b771552  grsecurity-2.2.0-2.6.35.8-201011062054.patch
147
eed5bd98c0a3b976891c897763eceff5  0001-xfrm-use-gre-key-as-flow-upper-protocol-info.patch
148
776adeeb5272093574f8836c5037dd7d  0004-arp-flush-arp-cache-on-device-change.patch
149
0ccecafd4123dcad0b0cd7787553d734  r8169-fix-rx-checksum-offload.patch
150
139b39da44ecb577275be53d7d365949  r8169-add-gro-support.patch
151
8c224ba0cdf0aa572c7eb50379435be4  setlocalversion.patch
152 153
16d6b950b8c8d9c9e6b43eb76cd090f4  kernelconfig.x86
df042faf6a936aaec13baf2c28ec6e36  kernelconfig.x86_64"