source: branches/contrib/bitten/slaves/include/slaves.inc.sh @ 464

Last change on this file since 464 was 464, checked in by amain, 7 years ago

bitten: fix patch issue in slave

File size: 2.6 KB
Line 
1#!/bin/bash
2#
3# DebWrt - Debian on Embedded devices
4#
5# Copyright (C) 2012 Johan van Zoomeren <amain@debwrt.net>
6#
7# This program is free software: you can redistribute it and/or modify
8# it under the terms of the GNU General Public License as published by
9# the Free Software Foundation, either version 3 of the License, or
10# (at your option) any later version.
11#
12# This program is distributed in the hope that it will be useful,
13# but WITHOUT ANY WARRANTY; without even the implied warranty of
14# MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE.  See the
15# GNU General Public License for more details.
16#
17# You should have received a copy of the GNU General Public License
18# along with this program.  If not, see <http://www.gnu.org/licenses/>.
19
20run=${1}
21ini=${2}
22recipe=${3}
23
24if [ ! "${run}" = "run" ]
25then
26  svn update ${BASEDIR}
27  exec ${BASEDIR}/bin/$(basename $0) run $@
28else
29  shift
30  shift
31fi
32
33if [ -f "${recipe}" ]
34then
35   # assume user supplied local recipy file
36   shift
37   mode=local
38else
39   unset recipe
40   mode=remote
41fi
42
43function usage()
44{
45   cat <<EOF
46usage: $(basename $0) <slave.ini> [ recipe.xml ] [ slave-arg1, .. ]
47
48Start bitten slave with <slave.ini> configuration.
49
50EOF
51
52   exit 1
53}
54
55function patches()
56{
57   bcount=$(find /usr/local/lib/python2.6/dist-packages -name 'Bitten-*' | wc -l)
58
59   if [ ${bcount} -eq 0 ]
60   then
61      echo "E: Can't find bitten-slave. Unable to apply patches."
62      exit 1
63   fi
64
65   find /usr/local/lib/python2.6/dist-packages -name 'Bitten-*' \
66     | while read dir
67       do
68         sudo patch -N -p 1 -d ${dir} <${BASEDIR}/patches/001_exit_no_pending.patch #>/dev/null
69         sudo patch -N -p 1 -d ${dir} <${BASEDIR}/patches/002_basedir_makedirs #>/dev/null
70       done 
71
72   echo
73}
74
75[ ! -f "${ini}" ] && usage
76
77eval $(awk -f ${BASEDIR}/include/ini.awk ${ini})
78
79arch=${1/.*/}
80name=$(hostname -f)
81work=~/build
82server_or_recipe="${recipe:-http://dev.debwrt.net}"
83log=${work}/bitten.log
84basedir='${config}/${platform}/${build}'
85
86mkdir -p ${work}
87
88cat <<EOF
89Starting Bitten Slave
90
91slave name         : ${name}
92ini                : ${ini}
93work               : ${work}
94basedir            : ${basedir}
95log                : ${log}
96mode               : ${mode}
97recipe             : ${server_or_recipe}
98
99EOF
100
101patches
102bitten-slave --verbose \
103             --single \
104             --keep-files \
105             --config ${ini} \
106             --work-dir ${work} \
107             --build-dir ${basedir} \
108             --log ${log} \
109             --name ${name} \
110             --exit-no-pending \
111             --dump-reports \
112             $@ \
113             ${server_or_recipe}
114
Note: See TracBrowser for help on using the repository browser.