chiark / gitweb /
Better build server creation script
authorCiaran Gultnieks <ciaran@ciarang.com>
Mon, 24 Sep 2012 13:04:58 +0000 (14:04 +0100)
committerCiaran Gultnieks <ciaran@ciarang.com>
Mon, 24 Sep 2012 13:04:58 +0000 (14:04 +0100)
docs/fdroid.texi
makebuildserver.py [new file with mode: 0755]
makebuildserver.sh [deleted file]

index 1e9b918213f4e1994a2c0fce87018a9a80515b94..719f38cdd209c8dabf23b2a16f6056e6e14c21f2 100644 (file)
@@ -1025,12 +1025,15 @@ With this base box installed, you can then go to the @code{fdroidserver}
 directory and run this:
 
 @example
-./makebuildserver.sh
+./makebuildserver.py
 @end example
 
-This will take a long time - most of it spent installing the necessary parts
-of the Android SDK for all the various platforms. Luckily you only need to
-do it occasionally.
+This will take a long time, and use a lot of bandwidth - most of it spent
+installing the necessary parts of the Android SDK for all the various
+platforms. Luckily you only need to do it occasionally. Once you have a
+working build server image, if the recipes change (e.g. when packages need
+to be added) you can just run that script again and the existing one will
+be updated in place.
 
 Once it's complete you'll have a new base box called 'buildserver' which is
 what's used for the actual builds. You can then build packages as normal,
diff --git a/makebuildserver.py b/makebuildserver.py
new file mode 100755 (executable)
index 0000000..adaebbc
--- /dev/null
@@ -0,0 +1,51 @@
+#!/usr/bin/python
+
+import os
+import sys
+import subprocess
+import time
+
+def vagrant(params, cwd=None):
+    p = subprocess.Popen(['vagrant'] + params, cwd=cwd,
+            stdout=subprocess.PIPE, stderr=subprocess.PIPE)
+    out, err = p.communicate()
+    return (p.returncode, out, err)
+
+boxfile = 'buildserver.box'
+serverdir = 'buildserver'
+
+if not os.path.exists('makebuildserver.py') or not os.path.exists(serverdir):
+    print 'This must be run from the correct directory!'
+    sys.exit(1)
+
+if os.path.exists(boxfile):
+    os.remove(boxfile)
+
+vagrant(['halt'], serverdir)
+print "Configuring build server VM"
+vagrant(['up'], serverdir)
+print "Stopping build server VM"
+vagrant(['halt'], serverdir)
+
+print "Waiting for build server VM to be finished"
+ready = False
+while not ready:
+    time.sleep(2)
+    returncode, out, err = vagrant(['status'], serverdir)
+    if returncode != 0:
+        print "Error while checking status"
+        sys.exit(1)
+    for line in out.splitlines():
+        if line.startswith("default"):
+            if line.find("poweroff") != -1:
+                ready = True
+            else:
+                print "Status: " + line
+
+print "Packaging"
+vagrant(['package', '--output', os.path.join('..', boxfile)], serverdir)
+print "Adding box"
+vagrant(['box', 'add', 'buildserver', boxfile, '-f'])
+
+os.remove(boxfile)
+
diff --git a/makebuildserver.sh b/makebuildserver.sh
deleted file mode 100755 (executable)
index b6865cb..0000000
+++ /dev/null
@@ -1,10 +0,0 @@
-#!/bin/bash
-set -e
-rm -f buildserver.box
-cd buildserver
-vagrant halt
-vagrant up
-vagrant halt
-vagrant package --base `VBoxManage list vms | grep buildserver | sed 's/"\(.*\)".*/\1/'` --output buildserver.box
-vagrant box add buildserver buildserver.box -f && rm buildserver.box
-