APKBUILD 5.01 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=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.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"
Natanael Copa's avatar
Natanael Copa committed
29
arch="x86 x86_64"
30
license="GPL-2"
Natanael Copa's avatar
Natanael Copa committed
31

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

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

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

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

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

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

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

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

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

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

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

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

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

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

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

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

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