File: linux-build.sh

package info (click to toggle)
lksctp-tools 1.0.19%2Bdfsg-1
  • links: PTS, VCS
  • area: main
  • in suites: bookworm, sid
  • size: 1,272 kB
  • sloc: ansic: 13,566; makefile: 270; sh: 26
file content (112 lines) | stat: -rwxr-xr-x 1,798 bytes parent folder | download
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
#!/bin/bash -ex

VERS="master v5.4 v4.19 v4.17 v4.16 v4.13 v4.12 v4.11 v4.10"

nproc=$(/usr/bin/getconf _NPROCESSORS_ONLN)
basedir=$(pwd)

function cleanup()
{
	cd "$basedir"
	[ ! -d linux ] || rm -rf linux
	[ ! -d "linux-$KERNEL" ] || rm -rf "linux-$KERNEL"
	make distclean || :
}

function clone_kernel()
{
	git clone https://github.com/torvalds/linux
}

function download_kernel()
{
	VER="$1"
	URL="https://www.kernel.org/pub/linux/kernel/v4.x/linux-$VER.tar.xz"
	wget "$URL"
	tar xf "linux-$VER.tar.xz"
}

function __prep_kernel()
{
	make mrproper
	make allmodconfig
	make -j $nproc modules_prepare
	make -j $nproc headers_install
	KERNEL_HEADERS=$(pwd)/usr/include
	popd
}

function git_prep_kernel()
{
	VER="$1"

	pushd "linux"
	git checkout "$VER"
	__prep_kernel
}

function download_prep_kernel()
{
	VER="$1"

	pushd "linux-$VER"
	__prep_kernel
}

function build_lksctp()
{
	local use_builddir="$1"

	make distclean || :
	./bootstrap

	#CFLAGS="-Werror"
	if [ -n "$KERNEL_HEADERS" ]; then
		CFLAGS="$CFLAGS -I$KERNEL_HEADERS"
	fi
	export CFLAGS

	if [ "$use_builddir" == 1 ]; then
		mkdir build
		pushd build
		../configure
	else
		./configure
	fi

	make -j $nproc

	make -j $nproc distcheck

	if [ "$use_builddir" == 1 ]; then
		popd
		rm -rf build
	fi
}

# When building the coverity_scan branch, allow only the 6th job to continue
# to avoid travis-ci/travis-ci#1975. 6th = gcc7, linux tip
if [[ "${TRAVIS_BRANCH}" == "coverity_scan" ]]; then
	exit 0
fi

trap cleanup EXIT
if [ -z "$KERNEL" ]; then
	clone_kernel

	for ver in $VERS; do
		git_prep_kernel "$ver"
		build_lksctp
		build_lksctp 1
	done
else
	if [ "$KERNEL" == 'master' ]; then
		clone_kernel
		git_prep_kernel "$KERNEL"
	else
		download_kernel "$KERNEL"
		download_prep_kernel "$KERNEL"
	fi
	build_lksctp
	build_lksctp 1
fi