aboutsummaryrefslogtreecommitdiffstats
diff options
context:
space:
mode:
authorMichał Łyszczek <michal.lyszczek@bofc.pl>2017-12-27 15:09:44 +0100
committerMichał Łyszczek <michal.lyszczek@bofc.pl>2017-12-27 15:09:44 +0100
commit8c9d3d4ceda54fd074425770c3d6c2024e2ed095 (patch)
tree9da800fb21060d1f586ab6d2616d6e6e5bf9567f
parenta3177a3cfc92c1159c156127f20b618e7952dd76 (diff)
downloadbuilder-slaves-8c9d3d4ceda54fd074425770c3d6c2024e2ed095.tar.gz
builder-slaves-8c9d3d4ceda54fd074425770c3d6c2024e2ed095.tar.bz2
builder-slaves-8c9d3d4ceda54fd074425770c3d6c2024e2ed095.zip
Added code to generate buildbot packages for specified projects
-rwxr-xr-xS99-buildbot.in65
-rw-r--r--buildbot-slave.tac.template70
-rw-r--r--control.template11
-rwxr-xr-xgen-packages.sh52
-rw-r--r--test.project.in4
5 files changed, 202 insertions, 0 deletions
diff --git a/S99-buildbot.in b/S99-buildbot.in
new file mode 100755
index 0000000..95aedf3
--- /dev/null
+++ b/S99-buildbot.in
@@ -0,0 +1,65 @@
+#!/bin/sh
+
+project=`basename ${0} | cut -f2 -d.`
+
+if [ "${project}" = "S99-buildbot" ]
+then
+ echo "this script should not be called directly, you should make a link"
+ echo "to this script with slave name as extension"
+ exit 0
+fi
+
+SLAVE_PATH="/var/lib/buildbot-${project}"
+USER=buildbot
+GROUP=buildbot
+export PATH="${PATH}:/usr/native-toolchain/bin"
+export LD_LIBRARY_PATH="/usr/native-toolchain/${TARGET}/lib"
+
+start()
+{
+ echo -n "Starting buildbot-${project} slave... "
+ /usr/bin/twistd --no_save --uid=${USER} --gid=${GROUP} \
+ --pidfile=/var/run/buildbot-${project}.pid \
+ --python=${SLAVE_PATH}/buildbot.tac
+
+ if [ $? -ne 0 ]
+ then
+ echo "[error]"
+ exit 1
+ fi
+
+ echo "[ok]"
+}
+
+stop()
+{
+ echo -n "Stopping buildbot slave... "
+ kill -15 `cat /var/run/buildbot-${project}.pid`
+
+ if [ $? -ne 0 ]
+ then
+ echo "[error]"
+ exit 1
+ fi
+
+ echo "[ok]"
+}
+
+case "${1}" in
+ start)
+ start
+ ;;
+
+ stop)
+ stop
+ ;;
+
+ restart)
+ stop
+ start
+ ;;
+
+ *)
+ echo "Usage: $0 {start|stop|restart}"
+ exit 1
+esac
diff --git a/buildbot-slave.tac.template b/buildbot-slave.tac.template
new file mode 100644
index 0000000..063b99d
--- /dev/null
+++ b/buildbot-slave.tac.template
@@ -0,0 +1,70 @@
+'''
+This is a sample buildbot.tac file to initalize
+a buildbot worker complete with logging.
+'''
+
+import os.path
+import socket
+
+from twisted.application import service
+from twisted.python.logfile import LogFile
+from twisted.python.log import ILogObserver, FileLogObserver
+
+from buildbot_worker.bot import Worker
+
+################################
+# Set the following variables
+# to your desired values
+#################################
+
+# use the current directory or
+# set to an absolute value
+basedir = '.'
+
+# logging
+rotateLength = 10000000
+maxRotatedFiles = 10
+
+# buildbot communication port
+port = ${BUILDMASTER_PORT}
+
+# worker settings
+worker_name = '${WORKER_NAME}'
+passwd = '${PASSWORD}'
+buildmaster_host = '${BUILDMASTER_HOST}'
+keepalive = 600
+umask = None
+maxdelay = 300
+numcpus = None
+allow_shutdown = None
+
+
+# Begin starting up the worker
+# if this is a relocatable tac file, get the directory containing the TAC
+if basedir == '.':
+ basedir = os.path.abspath(os.path.dirname(__file__))
+
+# note: this line is matched against to check that this is
+# a buildbot-worker directory; do not edit it.
+application = service.Application('buildbot-worker')
+
+# set up logging
+logfile = LogFile.fromFullPath(os.path.join(basedir, "twistd.log"),
+ rotateLength=rotateLength,
+ maxRotatedFiles=maxRotatedFiles
+ )
+application.setComponent(ILogObserver, FileLogObserver(logfile).emit)
+
+worker = Worker(buildmaster_host,
+ port,
+ worker_name,
+ passwd,
+ basedir,
+ keepalive,
+ umask=umask,
+ maxdelay=maxdelay,
+ numcpus=numcpus,
+ allow_shutdown=allow_shutdown
+ )
+
+worker.setServiceParent(application)
diff --git a/control.template b/control.template
new file mode 100644
index 0000000..8e26d58
--- /dev/null
+++ b/control.template
@@ -0,0 +1,11 @@
+Package: buildbot-slaves-${TARGET}
+Version: ${VERSION}
+Description: buildbot workers
+Section: extras
+Priority: optional
+Maintainer: Michał Łyszczek
+License: bsd
+Architecture: all
+Homepage: kurwinet.pl
+Depends:
+Source: N/A
diff --git a/gen-packages.sh b/gen-packages.sh
new file mode 100755
index 0000000..a96bf96
--- /dev/null
+++ b/gen-packages.sh
@@ -0,0 +1,52 @@
+#!/bin/sh
+
+version="0.0.1"
+
+all_archs="armv5te926-builder-linux-gnueabihf
+armv6j1136-builder-linux-gnueabihf
+armv7a15-builder-linux-gnueabihf
+armv7a9-builder-linux-gnueabihf
+i686-builder-linux-gnu"
+
+rm -rf tmp
+
+for p in *.project.in
+do
+ source "./${p}"
+ name=`echo ${p} | cut -f1 -d.`
+
+ if [ "${arch}" = "all" ]
+ then
+ arch="${all_archs}"
+ fi
+
+ for a in ${arch}
+ do
+ mkdir -p tmp/${a}/var/lib/buildbot-${name}
+ mkdir -p tmp/${a}/etc/init.d
+ ln -fs /etc/init.d/S99-buildbot tmp/${a}/etc/init.d/S99-buildbot.${name}
+ cd tmp/${a}/var/lib/buildbot-${name}
+ cp ../../../../../buildbot-slave.tac.template buildbot.tac
+
+ sed -i "s/\${BUILDMASTER_PORT}/${buildmaster_port}/" buildbot.tac
+ sed -i "s/\${WORKER_NAME}/${a}/" buildbot.tac
+ sed -i "s/\${PASSWORD}/${password}/" buildbot.tac
+ sed -i "s/\${BUILDMASTER_HOST}/${buildmaster_host}/" buildbot.tac
+
+ cd -
+ done
+done
+
+for a in ${all_archs}
+do
+ mkdir -p tmp/${a}/CONTROL
+ cp control.template tmp/${a}/CONTROL/control
+ cp S99-buildbot.in tmp/${a}/etc/init.d/S99-buildbot
+ chmod 755 tmp/${a}/etc/init.d/S99-buildbot
+
+ sed -i "s/\${TARGET}/${a}/" tmp/${a}/etc/init.d/S99-buildbot
+ sed -i "s/\${TARGET}/${a}/" tmp/${a}/CONTROL/control
+ sed -i "s/\${VERSION}/${version}/" tmp/${a}/CONTROL/control
+
+ opkg-build -O -o root -g root tmp/${a} .
+done
diff --git a/test.project.in b/test.project.in
new file mode 100644
index 0000000..8e6e255
--- /dev/null
+++ b/test.project.in
@@ -0,0 +1,4 @@
+buildmaster_port=4000
+password="buildbot"
+buildmaster_host="kurwik"
+arch="all"