xref: /aosp_15_r20/external/libcxx/utils/docker/scripts/run_buildbot.sh (revision 58b9f456b02922dfdb1fad8a988d5fd8765ecb80)
1*58b9f456SAndroid Build Coastguard Worker#!/usr/bin/env bash
2*58b9f456SAndroid Build Coastguard Workerset -x
3*58b9f456SAndroid Build Coastguard Worker
4*58b9f456SAndroid Build Coastguard WorkerBOT_DIR=/b
5*58b9f456SAndroid Build Coastguard WorkerBOT_NAME=$1
6*58b9f456SAndroid Build Coastguard WorkerBOT_PASS=$2
7*58b9f456SAndroid Build Coastguard Worker
8*58b9f456SAndroid Build Coastguard Workermkdir -p $BOT_DIR
9*58b9f456SAndroid Build Coastguard Worker
10*58b9f456SAndroid Build Coastguard Worker#curl "https://repo.stackdriver.com/stack-install.sh" | bash -s -- --write-gcm
11*58b9f456SAndroid Build Coastguard Worker
12*58b9f456SAndroid Build Coastguard Workerapt-get update -y
13*58b9f456SAndroid Build Coastguard Workerapt-get upgrade -y
14*58b9f456SAndroid Build Coastguard Worker
15*58b9f456SAndroid Build Coastguard Worker# FIXME(EricWF): Remove this hack. It's only in place to temporarily fix linking libclang_rt from the
16*58b9f456SAndroid Build Coastguard Worker# debian packages.
17*58b9f456SAndroid Build Coastguard Worker# WARNING: If you're not a buildbot, DO NOT RUN!
18*58b9f456SAndroid Build Coastguard Workerapt-get install lld-8
19*58b9f456SAndroid Build Coastguard Workerrm /usr/bin/ld
20*58b9f456SAndroid Build Coastguard Workerln -s /usr/bin/lld-8 /usr/bin/ld
21*58b9f456SAndroid Build Coastguard Worker
22*58b9f456SAndroid Build Coastguard Workersystemctl set-property buildslave.service TasksMax=100000
23*58b9f456SAndroid Build Coastguard Worker
24*58b9f456SAndroid Build Coastguard Workerbuildslave stop $BOT_DIR
25*58b9f456SAndroid Build Coastguard Worker
26*58b9f456SAndroid Build Coastguard Workerchown buildbot:buildbot $BOT_DIR
27*58b9f456SAndroid Build Coastguard Worker
28*58b9f456SAndroid Build Coastguard Workerecho "Connecting as $BOT_NAME"
29*58b9f456SAndroid Build Coastguard Workerbuildslave create-slave --allow-shutdown=signal $BOT_DIR lab.llvm.org:9990 $BOT_NAME $BOT_PASS
30*58b9f456SAndroid Build Coastguard Worker
31*58b9f456SAndroid Build Coastguard Workerecho "Eric Fiselier <[email protected]>" > $BOT_DIR/info/admin
32*58b9f456SAndroid Build Coastguard Worker
33*58b9f456SAndroid Build Coastguard Worker{
34*58b9f456SAndroid Build Coastguard Worker  uname -a | head -n1
35*58b9f456SAndroid Build Coastguard Worker  cmake --version | head -n1
36*58b9f456SAndroid Build Coastguard Worker  g++ --version | head -n1
37*58b9f456SAndroid Build Coastguard Worker  ld --version | head -n1
38*58b9f456SAndroid Build Coastguard Worker  date
39*58b9f456SAndroid Build Coastguard Worker  lscpu
40*58b9f456SAndroid Build Coastguard Worker} > $BOT_DIR/info/host
41*58b9f456SAndroid Build Coastguard Worker
42*58b9f456SAndroid Build Coastguard Workerecho "SLAVE_RUNNER=/usr/bin/buildslave
43*58b9f456SAndroid Build Coastguard WorkerSLAVE_ENABLED[1]=\"1\"
44*58b9f456SAndroid Build Coastguard WorkerSLAVE_NAME[1]=\"buildslave1\"
45*58b9f456SAndroid Build Coastguard WorkerSLAVE_USER[1]=\"buildbot\"
46*58b9f456SAndroid Build Coastguard WorkerSLAVE_BASEDIR[1]=\"$BOT_DIR\"
47*58b9f456SAndroid Build Coastguard WorkerSLAVE_OPTIONS[1]=\"\"
48*58b9f456SAndroid Build Coastguard WorkerSLAVE_PREFIXCMD[1]=\"\"" > /etc/default/buildslave
49*58b9f456SAndroid Build Coastguard Worker
50*58b9f456SAndroid Build Coastguard Workerchown -R buildbot:buildbot $BOT_DIR
51*58b9f456SAndroid Build Coastguard Workersystemctl daemon-reload
52*58b9f456SAndroid Build Coastguard Workerservice buildslave restart
53*58b9f456SAndroid Build Coastguard Worker
54*58b9f456SAndroid Build Coastguard Workersleep 30
55*58b9f456SAndroid Build Coastguard Workercat $BOT_DIR/twistd.log
56*58b9f456SAndroid Build Coastguard Workergrep "slave is ready" $BOT_DIR/twistd.log || shutdown now
57*58b9f456SAndroid Build Coastguard Worker
58*58b9f456SAndroid Build Coastguard Worker# GCE can restart instance after 24h in the middle of the build.
59*58b9f456SAndroid Build Coastguard Worker# Gracefully restart before that happen.
60*58b9f456SAndroid Build Coastguard Workersleep 72000
61*58b9f456SAndroid Build Coastguard Workerwhile pkill -SIGHUP buildslave; do sleep 5; done;
62*58b9f456SAndroid Build Coastguard Workershutdown now