summaryrefslogtreecommitdiffstats
path: root/main/linux-vserver/APKBUILD
blob: be32d6f15d8da647fc9d47334f290a445882ee53 (plain)
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
33
34
35
36
37
38
39
40
41
42
43
44
45
46
47
48
49
50
51
52
53
54
55
56
57
58
59
60
61
62
63
64
65
66
67
68
69
70
71
72
73
74
75
76
77
78
79
80
81
82
83
84
85
86
87
88
89
90
91
92
93
94
95
96
97
98
99
100
101
102
103
104
105
106
107
108
109
110
111
112
113
114
115
116
117
118
119
120
121
122
123
124
125
126
127
128
129
130
131
132
133
134
135
136
137
138
139
140
141
142
143
144
145
146
147
148
149
150
151
152
153
154
155
156
157
158
159
160
# Maintainer: Natanael Copa <ncopa@alpinelinux.org>

_flavor=vserver
pkgname=linux-${_flavor}
pkgver=3.10.19
pkgrel=0
_vsver=vs2.3.6.8

if [ "${pkgver##*.*.*}" = "$pkgver" ]; then
	_kernver=$pkgver
else
	_kernver=${pkgver%.*}
fi

pkgdesc="Linux kernel with vserver"
url="http://linux-vserver.org/"
depends="mkinitfs linux-firmware"
makedepends="perl installkernel bash bc"
options="!strip"
_config=${config:-kernelconfig.${CARCH}}
install=
source="http://www.kernel.org/pub/linux/kernel/v3.x/linux-$_kernver.tar.xz
	http://www.kernel.org/pub/linux/kernel/v3.x/patch-$pkgver.xz
	patch-$pkgver-$_vsver.diff
	aslr-pie.patch
	CVE-2013-4348.patch
	kernelconfig.x86
	kernelconfig.x86_64
	"
subpackages="$pkgname-dev"
arch="all"
license="GPL-2"

_abi_release=${pkgver}-${_vsver}

prepare() {
	cd "$srcdir"/linux-$_kernver
	if [ "${pkgver%.0}" = "$pkgver" ]; then
		msg "Applying $i"
		unxz -c < ../patch-$pkgver.xz | patch -p1 -N || return 1
	fi

	# ERR is no valid signal
	sed -i -e '/^trap/s/ERR//' scripts/link-vmlinux.sh

	# first apply patches in specified order
	for i in $source; do
		i=${i##*/}
		case $i in
		*.patch|*.diff)
			msg "Applying $i..."
			patch -s -p1 -i "$srcdir"/$i || return 1
			;;
		esac
	done

	mkdir -p "$srcdir"/build
	cp "$srcdir"/$_config "$srcdir"/build/.config || return 1
	make -C "$srcdir"/linux-$_kernver O="$srcdir"/build HOSTCC="${CC:-gcc}" \
		silentoldconfig
}

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

build() {
	cd "$srcdir"/build
	export GCC_SPECS=hardenednopie.specs
	make CC="${CC:-gcc}" \
		KBUILD_BUILD_VERSION="$((pkgrel + 1 ))-Alpine" \
		|| return 1
}

package() {
	cd "$srcdir"/build
	mkdir -p "$pkgdir"/boot "$pkgdir"/lib/modules
	make -j1 modules_install install \
		INSTALL_MOD_PATH="$pkgdir" \
		INSTALL_PATH="$pkgdir"/boot \
		|| return 1

	rm -rf "$pkgdir"/lib/modules/*/build \
		"$pkgdir"/lib/modules/*/source
	rm -rf "$pkgdir"/lib/firmware

	install -D include/config/kernel.release \
		"$pkgdir"/usr/share/kernel/$_flavor/kernel.release
}

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

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

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

	# copy the needed stuff from real sources
	#
	# this is taken from ubuntu kernel build script
	# http://kernel.ubuntu.com/git?p=ubuntu/ubuntu-jaunty.git;a=blob;f=debian/rules.d/3-binary-indep.mk;hb=HEAD
	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"

	install -Dm644 "$srcdir"/build/Module.symvers \
		"$dir"/Module.symvers

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

md5sums="4f25cd5bec5f8d5a7d935b3f2ccb8481  linux-3.10.tar.xz
b7f932eecbbf5636ad69add480fa1573  patch-3.10.19.xz
16269e10835d0f8446e8b5e0016c87bf  patch-3.10.19-vs2.3.6.8.diff
35e2e5c7a5f0de3cdf540bb4ae894349  aslr-pie.patch
09ae7985af988c75ff35ed503558eb8b  CVE-2013-4348.patch
7f62c6c40c9638d83d4fa11eace3f9ac  kernelconfig.x86
aa2ac10901c87db6a4a70ed3d8cc49a8  kernelconfig.x86_64"
sha256sums="df27fa92d27a9c410bfe6c4a89f141638500d7eadcca5cce578954efc2ad3544  linux-3.10.tar.xz
c420b1da0aefe23e4a6953e579374fd377385b6041f967694cf4f828e2f3252e  patch-3.10.19.xz
56247228dc90b9dfe162f4ad704863f3d8bd713a16f81e885a0338c963df94ec  patch-3.10.19-vs2.3.6.8.diff
c18b47c7cd07837ca1c4f4702ef72e688a307b02f1f74012b329cea7d910ec85  aslr-pie.patch
39acdfc0bb2298e3a9ba62ee42ac2b6556fc31d8eaa2c085f84897cdeaa1a996  CVE-2013-4348.patch
1c06446173692d14e7db21b873e6b9053770ed1290a0e199e575dfebd2781072  kernelconfig.x86
ed941323278a48033f96cdfd4e66a25cb26171b31cbc96583817f7291d47f721  kernelconfig.x86_64"
sha512sums="5fb109fcbd59bf3dffc911b853894f0a84afa75151368f783a1252c5ff60c7a1504de216c0012be446df983e2dea400ad8eeed3ce04f24dc61d0ef76c174dc35  linux-3.10.tar.xz
6a8bfb124f90f1c8ed27ce3315629601b1b72d4bc8b1d2b776424e56b3a72e4cd03bcebe6cde35223a3beba75ec6d69e949e217504acc611becb7e62aa88f05c  patch-3.10.19.xz
9e6ed233e4618d9a9368d907631b9643f91e42fac1115f50f3e57deeea946f0d8673f82f92ed134bc2b1ca4ba7198dae9327b3f157673f21bab73e5a46bee79f  patch-3.10.19-vs2.3.6.8.diff
41c74619359791a65dc2c017e8fdae9e8614c8c6d3306bec59dac84bc74455ea1b9c5d35d98c7ce414d8621d91c9dbe868916a8b89be6c60d1013235ef5c21ab  aslr-pie.patch
6c5165692519c630cb96a254088e55d4d7412bd0f45920c0bf514dd9c68d24625da91798158fe502b6c214a7b8d44ae6b2e49b39aed6da3c1344f816f90405a3  CVE-2013-4348.patch
4612728f2f6b3d9ac043606511c2f6147f98aa716d16c8633776b83d1b98d997277e650cab537e2f87c1225541294f51302598cd5e543a353d768bbc68e91ab4  kernelconfig.x86
a3d9e72659f6a53b4bc47350fbf427263c2cc8320ef61e64f22a7402c4ba16d8ae2a3df5057ab09431d4b8a4e2c2a41b86d188b89d830c7301c6943360e83954  kernelconfig.x86_64"