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

3
_flavor=grsec
4
pkgname=linux-${_flavor}
5
pkgver=2.6.35.9
6
_kernver=2.6.35
7
pkgrel=3
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.9-unofficial.patch
18
	0001-xfrm-use-gre-key-as-flow-upper-protocol-info.patch
19
	xfrm-fix-gre-key-endianess.patch
20
	0004-arp-flush-arp-cache-on-device-change.patch
21
	r8169-fix-rx-checksum-offload.patch
22
	r8169-add-gro-support.patch
23
	0001-Staging-hv-fix-sleeping-while-atomic-issue.patch
24
	setlocalversion.patch
25
	kernelconfig.x86
26
	kernelconfig.x86_64
27
	"
28
subpackages="$pkgname-dev linux-firmware:firmware"
29
license="GPL-2"
Natanael Copa's avatar
Natanael Copa committed
30

31 32
_abi_release=${pkgver}-${_flavor}

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

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

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

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

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

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

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

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

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

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

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

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

	install -Dm644 "$srcdir"/build/Module.symvers \
		"$dir"/Module.symvers
133 134 135 136

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

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

146
md5sums="091abeb4684ce03d1d936851618687b6  linux-2.6.35.tar.bz2
147 148
eca407cf4872ad77ae23adc8242389c4  patch-2.6.35.9.bz2
bec8a242eb219c14ce45150a0155a5ac  grsecurity-2.2.0-2.6.35.9-unofficial.patch
149
eed5bd98c0a3b976891c897763eceff5  0001-xfrm-use-gre-key-as-flow-upper-protocol-info.patch
150
ea7a7eb2775b71ae5ef24d029a4905bd  xfrm-fix-gre-key-endianess.patch
151
776adeeb5272093574f8836c5037dd7d  0004-arp-flush-arp-cache-on-device-change.patch
152
0ccecafd4123dcad0b0cd7787553d734  r8169-fix-rx-checksum-offload.patch
153
139b39da44ecb577275be53d7d365949  r8169-add-gro-support.patch
154
648d8b477248f233c318a3b7a961febf  0001-Staging-hv-fix-sleeping-while-atomic-issue.patch
155
8c224ba0cdf0aa572c7eb50379435be4  setlocalversion.patch
156 157
a9494f66196bc6308da0f129221d31b8  kernelconfig.x86
b38f1f99f8f3b75c52d4a1ab2b0d13fd  kernelconfig.x86_64"