-
Notifications
You must be signed in to change notification settings - Fork 0
/
batchbuild
executable file
·146 lines (115 loc) · 4.09 KB
/
batchbuild
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
#!/bin/bash
[ -n "${DEBUG}" ] && set -x
echo " ::: start at $(date)"
T1="$(date +%s)"
export PATH=${PATH}:~/bin
export ARCH=${ARCH:-arm arm64 riscv i386 x86}
# Usage: batchbuild repo/branch
REMOTE=$(echo $1 | sed s@/.*@@g)
BRANCH=$(echo $1 | sed s@.*/@@)
CHECKOUT="$2"
if [ "$(dirname "$1")" == "." ] ; then
REMOTE="$1"
BRANCH="HEAD"
fi
case "${REMOTE}" in
rmk)
;;
soc)
;;
arm-soc)
;;
next)
;;
mainline)
;;
stable*)
;;
cros)
;;
riscv)
;;
*)
TO="[email protected]"
;;
esac
: ${CHECKOUT:="${REMOTE}/${BRANCH}"}
case ${REMOTE} in
next)
BUILDID=$(cd /src || exit ; git describe --match=next* "${CHECKOUT}")
;;
*)
BUILDID=$(cd /src || exit ; git describe --match=v* "${CHECKOUT}")
;;
esac
if [ -f "/logs/${REMOTE}/${BUILDID}/index.html" ] ; then
echo "Version ${REMOTE}/${BUILDID} has already been built. Aborting"
exit 0
fi
echo " ::: Email will go to: ${TO}"
cd /build || exit 1
echo " ::: Cloning sources"
git clone --quiet --reference=/src --depth=1 -n file:///src . && git checkout --quiet "${BUILDID}"
cp ~/makefile.batchbuild makefile
echo " ::: Building ${BUILDID}"
mkdir -p "/logs/${REMOTE}/${BUILDID}"
mkdir -p /logs/emails
echo " ::: Full builds for: ${ARCH}"
(grep -v "CONFIG_LPAE is not" arch/arm/configs/multi_v7_defconfig ; echo "CONFIG_LPAE=y") > arch/arm/configs/multi_lpae_defconfig
(grep -v "CONFIG_SMP=y" arch/arm/configs/multi_v7_defconfig ; echo "CONFIG_SMP=n") > arch/arm/configs/multi_v7_nosmp_defconfig
(grep -v "CONFIG_SMP=y" arch/arm64/configs/defconfig ; echo "CONFIG_SMP=n") > arch/arm64/configs/nosmp_defconfig
# rpc_defconfig isn't supported by our binutils any more.
rm -f arch/arm/configs/rpc_defconfig
if [ -f arch/riscv/Makefile ] ; then
(grep -v "CONFIG_SMP=y" arch/riscv/configs/defconfig ; echo "CONFIG_SMP=n") > arch/riscv/configs/nosmp_defconfig
(grep -v "CONFIG_ARCH_RV32I is not" arch/riscv/configs/defconfig ; echo "CONFIG_ARCH_RV32I=y") > arch/riscv/configs/rv32_defconfig
(echo "CONFIG_ARCH_RV32I=y" ; echo "CONFIG_ARCH_RV64I=n") > allmod.config
mkdir /tmp/rvcfg && make O=/tmp/rvcfg ARCH=riscv KCONFIG_ALLCONFIG=1 allmodconfig >/dev/null 2>&1
mv /tmp/rvcfg/.config arch/riscv/configs/rv32_allmod_defconfig
rm -rf /tmp/rvcfg allmod.config
fi
# Hack to deal with missing jobserver tokens due to make getting stuck in
# pselect.
( while true ; do killall -s CHLD make ; sleep 1 ; done >/dev/null 2>&1 ) &
rm -f buildall.*
# Build list of targets (build-<arch>-config)
TARG=""
for arch in ${ARCH} ; do
if [ "${arch}" == "x86" ] || [ "${arch}" == "i386" ] ; then
CFGS="defconfig allnoconfig allmodconfig tinyconfig"
else
CFGS="$(basename -a arch/${arch}/configs/*defconfig) allnoconfig allmodconfig tinyconfig"
fi
for f in ${CFGS} ; do
if [ ! -f /logs/${REMOTE}/${BUILDID}/buildall.${arch}.${f}.log.failed -a \
! -f /logs/${REMOTE}/${BUILDID}/buildall.${arch}.${f}.log.passed ] ; then
TARG="$TARG build-${arch}-${f}"
else
echo " ::: Skipping ${arch} ${f} since it's already built"
fi
done
done
# Kick off main build
make ${TARG} LOGDIR="/logs/${REMOTE}/${BUILDID}" -sk -j $(($(nproc) + 8))
T2="$(date +%s)"
# No longer nuke output directory if we get terminated
touch /logs/${REMOTE}/${BUILDID}/.done
(cd "/logs/${REMOTE}/${BUILDID}" || exit ;
TO="${TO}" \
REMOTE="${REMOTE}" \
REMOTEURL="$(cd /src || exit ; git remote show -n "${REMOTE}"| awk '/Fetch URL:/{print $3}')" \
BUILDID="${BUILDID}" \
BRANCH="${BRANCH}" \
TOPCOMMITS="$(cd /src || exit ; git log --oneline -3 "${BUILDID}")" \
BUILDTIME=$((T2-T1)) /usr/local/bin/buildreport > "/logs/emails/${REMOTE}.${BUILDID}.$(date +%Y%m%d-%H%M%S).txt"
)
echo " ::: done with ${REMOTE} ${BUILDID} at $(date)"
exit 0