summaryrefslogtreecommitdiff
path: root/misc/dashboard/buildcron.sh
blob: 7aa70ce57145b0aa3b9622d6b684cdbe019100a7 (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
#!/usr/bin/env bash
# Copyright 2010 The Go Authors.  All rights reserved.
# Use of this source code is governed by a BSD-style
# license that can be found in the LICENSE file.

# This script can be run to create a new builder and then
# to keep it running via cron.  First, run it by hand until it
# starts up without errors and can run the loop.  Then, once
# you're confident that it works, add this to your crontab:
#
#   */5 * * * *  cd $HOME; path/to/buildcron.sh darwin 386 >/dev/null 2>/dev/null

if [ $# != 2 ]; then
	echo 'usage: buildcron.sh goos goarch' 1>&2
	exit 2
fi

export GOOS=$1
export GOARCH=$2

# Check if we are already running.
# First command must not be pipeline, to avoid seeing extra processes in ps.
all=$(ps axwwu)
pid=$(echo "$all" | grep "buildcron.sh $1 $2" | grep -v "sh -c" | grep -v $$ | awk '{print $2}')
if [ "$pid" != "" ]; then
	#echo already running buildcron.sh $1 $2
	#echo "$all" | grep "buildcron.sh $1 $2" | grep -v "sh -c" | grep -v $$
	exit 0
fi

export BUILDHOST=godashboard.appspot.com
export BUILDER=${GOOS}-${GOARCH}
export GOROOT=$HOME/go-$BUILDER/go
export GOBIN=$HOME/go-$BUILDER/bin

if [ ! -f ~/.gobuildkey-$BUILDER ]; then
	echo "need gobuildkey for $BUILDER in ~/.gobuildkey-$BUILDER" 1>&2
	exit 2
fi

if [ ! -d $GOROOT ]; then
	mkdir -p $GOROOT
	hg clone https://go.googlecode.com/hg/ $GOROOT
else
	cd $GOROOT
	hg pull -u || exit 1
fi
mkdir -p $GOROOT/bin

cd $GOROOT/..
cp go/misc/dashboard/{builder.sh,buildcontrol.py,googlecode_upload.py} .
chmod a+x builder.sh buildcontrol.py
cd go
../buildcontrol.py next $BUILDER
cd ..
./builder.sh