-
Notifications
You must be signed in to change notification settings - Fork 2
/
dispatch.sh
executable file
·103 lines (82 loc) · 2.34 KB
/
dispatch.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
set -ex
/bin/echo "vvvvvvvvvvvvvvvvvvv dispatch.sh vvvvvvvvvvvvvvvvvvvvvv"
export WORKSPACE
if [ -z "$WORKSPACE" ] ; then
/bin/echo "Uh, workspace not set."
exit 1
fi
# The new way is to set SCRIPT, along with some other important
# variables. The old way is to infer that stuff from JOB_NAME.
if [[ -z "$SCRIPT" ]]; then
# Old way
/bin/echo "IF you fail here your job name is corrupt."
/bin/echo "Format:"
/bin/echo "some-script-name.IMAGETYPE.UBUNTUCODENAME.ARCH"
[[ $JOB_NAME =~ ([^\.]+)\.([^\.]+)\.([^\.]+)\.([^\.]+) ]]
SCRIPT=${BASH_REMATCH[1]}.sh
IMAGETYPE=${BASH_REMATCH[2]}
UBUNTU_DISTRO=${BASH_REMATCH[3]}
ARCH=${BASH_REMATCH[4]}
/bin/echo <<EOF
SCRIPT=$SCRIPT
IMAGETYPE=$IMAGETYPE
UBUNTU_DISTRO=$UBUNTU_DISTRO
ARCH=$ARCH
EOF
if [[ $SCRIPT =~ ^([^_]+)_([^_]+)$ ]] ; then
SCRIPT=${BASH_REMATCH[1]}
SCRIPTARGS=${BASH_REMATCH[2]}
fi
fi
#
# update buildfarm utils
#
cd $WORKSPACE
if [ -d buildfarm ] ; then
cd buildfarm
git clean -dfx
git reset --hard HEAD
git pull
cd ..
else
git clone git://github.com/willowgarage/buildfarm.git
fi
. ./buildfarm/buildfarm_util.sh
export > env
sudo mkdir -p /var/cache/pbuilder/ccache
sudo chmod a+w /var/cache/pbuilder/ccache
cat > pbuilder-env.sh <<EOF
#!/bin/bash -ex
/bin/echo "vvvvvvvvvvvvvvvvvvv pbuilder-env.sh vvvvvvvvvvvvvvvvvvvvvv"
export CCACHE_DIR="/var/cache/pbuilder/ccache"
export PATH="/usr/lib/ccache:${PATH}"
export WORKSPACE=$WORKSPACE
export UBUNTU_DISTRO=$UBUNTU_DISTRO
export ARCH=$ARCH
export IMAGETYPE=$IMAGETYPE
export ROSDISTRO_NAME=$ROSDISTRO_NAME
export OS_NAME=$OS_NAME
export OS_PLATFORM=$OS_PLATFORM
export STACK_NAME=$STACK_NAME
export STACK_YAML_URL=$STACK_YAML_URL
export JOB_TYPE=$JOB_TYPE
pwd
ls -l
cd $WORKSPACE
ls -l
chmod 755 $WORKSPACE/buildfarm/${SCRIPT}
exec $WORKSPACE/buildfarm/${SCRIPT} ${SCRIPTARGS}
EOF
chmod 755 pbuilder-env.sh
TOP=$(cd `dirname $0` ; /bin/pwd)
/usr/bin/env
$WORKSPACE/buildfarm/create_chroot.sh $IMAGETYPE $UBUNTU_DISTRO $ARCH
if ! which pbuilder; then
sudo apt-get -y install pbuilder
fi
sudo pbuilder execute \
--basetgz /var/cache/pbuilder/$IMAGETYPE.$UBUNTU_DISTRO.$ARCH.tgz \
--bindmounts "/var/cache/pbuilder/ccache /home" \
--inputfile $WORKSPACE/buildfarm/$SCRIPT \
-- $WORKSPACE/pbuilder-env.sh $SCRIPT
/bin/echo "^^^^^^^^^^^^^^^^^^ dispatch.sh ^^^^^^^^^^^^^^^^^^^^"