This repository has been archived by the owner on May 6, 2021. It is now read-only.
-
Notifications
You must be signed in to change notification settings - Fork 24
/
build-kernel-deb.sh
executable file
·111 lines (92 loc) · 3.07 KB
/
build-kernel-deb.sh
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
#!/bin/sh -x
set -e
if [ ! -e Makefile ]; then
echo "$0: no Makefile, aborting." 1>&2
exit 3
fi
# Actually build the project
# clear out any $@ potentially passed in
set --
# enable ccache if it is installed
export CCACHE_DIR="$PWD/../../ccache"
if command -v ccache >/dev/null; then
if [ ! -e "$CCACHE_DIR" ]; then
echo "$0: have ccache but cache directory does not exist: $CCACHE_DIR" 1>&2
else
set -- CC='ccache gcc' CXX='ccache g++'
fi
else
echo "$0: no ccache found, compiles will be slower." 1>&2
fi
flavor=`hostname | sed -e "s|gitbuilder-\([^-]*\)-\([^-]*\)-\([^-]*\)-\([^-]*\)-\([^-]*\)$|\5|"`
config="../../kernel-config-deb.$flavor"
if [ ! -e "$config" ]; then
echo "no $config found for flavor $flavor"
exit 1
fi
install -d -m0755 build~/out
(
# we really need this to get the packages the way we want them, so just enforce it here
grep -v '^CONFIG_LOCALVERSION_AUTO=' $config
echo 'CONFIG_LOCALVERSION_AUTO=y'
) >build~/out/.config
echo "$0: new kernel config options:"
# listnewconfig was contained in v2.6.36, but it seems out/ignore/*
# doesn't work quite right to ignore everything before that, so
# instead just ignore errors coming from it
ionice -c3 nice -n20 make O=build~/out listnewconfig "$@" || :
echo "$0: running make oldconfig..."
yes '' | ionice -c3 nice -n20 make O=build~/out oldconfig "$@"
#echo "$0: applying perf.patch..."
#patch -p1 < ../../perf.patch
echo "$0: building..."
# build dir has ~ suffix so it gets ignored by git and doesn't make
# the source tree look modified (get "+" in version); using subdir out
# so the debs go to e.g.
# build~/linux-image-2.6.38-ceph-00020-g4b2a58a_ceph_amd64.deb
NCPU=$(( 2 * `grep -c processor /proc/cpuinfo` ))
ionice -c3 nice -n20 make O=build~/out LOCALVERSION=-ceph deb-pkg -j$NCPU "$@" || exit 4
REV="$(git rev-parse HEAD)"
OUTDIR="../out/output/sha1/$REV"
OUTDIR_TMP="${OUTDIR}.tmp"
install -d -m0755 -- "$OUTDIR_TMP"
printf '%s\n' "$REV" >"$OUTDIR_TMP/sha1"
mv -- build~/*.deb "$OUTDIR_TMP/"
cp -- build~/out/.config $OUTDIR_TMP/config
cp -- build~/out/include/config/kernel.release $OUTDIR_TMP/version
# build a simple repro in OUTDIR_TMP too
DIST="squeeze" # this could be anything
(
cd $OUTDIR_TMP
install -d -m0755 -- "conf"
cat > conf/distributions <<EOF
Codename: $DIST
Suite: stable
Components: main
Architectures: i386 amd64 source
Origin: New Dream Network
Description: Kernel autobuilds
DebIndices: Packages Release . .gz .bz2
DscIndices: Sources Release .gz .bz2
EOF
for f in image headers;
do
reprepro -b . includedeb $DIST linux-$f-*.deb
# make a consistently named symlink
normal=`ls linux-$f-*.deb | grep -v -- -dbg`
ln -s $normal linux-$f.deb
dbg=`ls linux-$f-*.deb | grep -- -dbg || true`
if [ -n "$dbd" ]; then
ln -s $dbg linux-$f-dbg.deb
fi
done
)
# we're successful, the files are ok to be published; try to be as
# atomic as possible about replacing potentially existing OUTDIR
if [ -e "$OUTDIR" ]; then
rm -rf -- "$OUTDIR.old"
mv -- "$OUTDIR" "$OUTDIR.old"
fi
mv -- "$OUTDIR_TMP" "$OUTDIR"
rm -rf -- "$OUTDIR.old"
exit 0