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

3
_flavor=grsec
4
pkgname=linux-${_flavor}
5 6 7
pkgver=2.6.35.10
_kernver=2.6.35
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
source="ftp://ftp.kernel.org/pub/linux/kernel/v2.6/linux-$_kernver.tar.bz2
16 17 18 19 20 21
	http://www.kernel.org/pub/linux/kernel/v2.6/longterm/v${pkgver%.*}/patch-$pkgver.bz2
	grsecurity-2.2.0-$pkgver-unofficial.patch
	0001-xfrm-use-gre-key-as-flow-upper-protocol-info.patch
	xfrm-fix-gre-key-endianess.patch
	0004-arp-flush-arp-cache-on-device-change.patch
	r8169-add-gro-support.patch
22

23 24 25 26
	0001-Staging-hv-fix-sleeping-while-atomic-issue.patch
	0004-staging-hv-fix-netvsc-sleeping-while-atomic.patch

	setlocalversion.patch
27
	kernelconfig.x86
28
	kernelconfig.x86_64
29
	"
30
subpackages="$pkgname-dev linux-firmware:firmware"
31
arch="x86 x86_64 arm"
32
license="GPL-2"
Natanael Copa's avatar
Natanael Copa committed
33

34 35
_abi_release=${pkgver}-${_flavor}

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

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

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

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

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

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

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

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

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

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

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

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

	install -Dm644 "$srcdir"/build/Module.symvers \
		"$dir"/Module.symvers
136 137 138 139

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

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

149 150 151 152 153 154 155 156 157 158
md5sums="091abeb4684ce03d1d936851618687b6  linux-2.6.35.tar.bz2
0741b3219a009fdfc41c766416007fcf  patch-2.6.35.10.bz2
3855791bfc2ee4fff05fc3c783a3a477  grsecurity-2.2.0-2.6.35.10-unofficial.patch
eed5bd98c0a3b976891c897763eceff5  0001-xfrm-use-gre-key-as-flow-upper-protocol-info.patch
ea7a7eb2775b71ae5ef24d029a4905bd  xfrm-fix-gre-key-endianess.patch
776adeeb5272093574f8836c5037dd7d  0004-arp-flush-arp-cache-on-device-change.patch
139b39da44ecb577275be53d7d365949  r8169-add-gro-support.patch
648d8b477248f233c318a3b7a961febf  0001-Staging-hv-fix-sleeping-while-atomic-issue.patch
7cae2d1e1947fa57d7aaaf31c649471c  0004-staging-hv-fix-netvsc-sleeping-while-atomic.patch
8c224ba0cdf0aa572c7eb50379435be4  setlocalversion.patch
159 160
b331582845fd4a702591b67eec47d687  kernelconfig.x86
1f9af7129d5b44eb3c3a60237af4ef70  kernelconfig.x86_64"