APKBUILD 4.51 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=3
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
	setlocalversion.patch
22
	kernelconfig.x86
23
	"
24
subpackages="$pkgname-dev linux-firmware:firmware"
25
license="GPL-2"
Natanael Copa's avatar
Natanael Copa committed
26

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

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

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

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

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

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

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

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

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

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

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

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

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

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

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

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

141 142 143
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
144
776adeeb5272093574f8836c5037dd7d  0004-arp-flush-arp-cache-on-device-change.patch
145
0ccecafd4123dcad0b0cd7787553d734  r8169-fix-rx-checksum-offload.patch
146
139b39da44ecb577275be53d7d365949  r8169-add-gro-support.patch
147
8c224ba0cdf0aa572c7eb50379435be4  setlocalversion.patch
148
16d6b950b8c8d9c9e6b43eb76cd090f4  kernelconfig.x86"