From cb16a6340925a7bc4bdbec906c8f3a6971f1a598 Mon Sep 17 00:00:00 2001 From: Ciaran Gultnieks Date: Fri, 31 May 2013 07:48:39 +0100 Subject: [PATCH] Much better build server provisioning Including selection of correct ndk architecture, caching and performance improvements, better configurability, etc. --- buildserver/.gitignore | 2 + buildserver/Vagrantfile | 26 ---- .../cookbooks/android-ndk/recipes/default.rb | 7 +- .../cookbooks/android-sdk/recipes/default.rb | 16 ++- makebuildserver.py | 126 ++++++++++++++---- 5 files changed, 124 insertions(+), 53 deletions(-) delete mode 100644 buildserver/Vagrantfile diff --git a/buildserver/.gitignore b/buildserver/.gitignore index 4de7cdb2..4a3901ed 100644 --- a/buildserver/.gitignore +++ b/buildserver/.gitignore @@ -1,2 +1,4 @@ .vagrant up.log +cache/ +Vagrantfile diff --git a/buildserver/Vagrantfile b/buildserver/Vagrantfile deleted file mode 100644 index 49e9b5b7..00000000 --- a/buildserver/Vagrantfile +++ /dev/null @@ -1,26 +0,0 @@ -Vagrant::Config.run do |config| - - config.vm.box = "raring64" - config.vm.box_url = "/shares/software/OS and Boot/raring64.box" - - config.vm.customize ["modifyvm", :id, "--memory", "3584"] - - config.vm.provision :shell, :path => "fixpaths.sh" - # Set apt proxy - remove, or adjust this, accordingly! - config.vm.provision :shell, :inline => 'sudo echo "Acquire::http { Proxy \"http://192.168.0.19:8000\"; };" > /etc/apt/apt.conf.d/02proxy && sudo apt-get update' - - config.vm.provision :chef_solo do |chef| - chef.cookbooks_path = "cookbooks" - chef.log_level = :debug - chef.json = { - :settings => { - :sdk_loc => "/home/vagrant/android-sdk", - :ndk_loc => "/home/vagrant/android-ndk", - :user => "vagrant" - } - } - chef.add_recipe "fdroidbuild-general" - chef.add_recipe "android-sdk" - chef.add_recipe "android-ndk" - end -end diff --git a/buildserver/cookbooks/android-ndk/recipes/default.rb b/buildserver/cookbooks/android-ndk/recipes/default.rb index 42f1de1d..315491d3 100644 --- a/buildserver/cookbooks/android-ndk/recipes/default.rb +++ b/buildserver/cookbooks/android-ndk/recipes/default.rb @@ -7,7 +7,12 @@ script "setup-android-ndk" do user node[:settings][:user] cwd "/tmp" code " - tar jxvf /vagrant/cache/android-ndk-r8e-linux-x64.tar.bz2 + if [ `uname -m` == 'x86_64' ] ; then + SUFFIX = '_64' + else + SUFFIX = '' + fi + tar jxvf /vagrant/cache/android-ndk-r8e-linux-x86$SUFFIX.tar.bz2 mv android-ndk-r8e #{ndk_loc} " not_if do diff --git a/buildserver/cookbooks/android-sdk/recipes/default.rb b/buildserver/cookbooks/android-sdk/recipes/default.rb index 5fabdb56..f01459d7 100644 --- a/buildserver/cookbooks/android-sdk/recipes/default.rb +++ b/buildserver/cookbooks/android-sdk/recipes/default.rb @@ -37,10 +37,16 @@ end user user cwd "/tmp" code " - #{sdk_loc}/tools/android update sdk --no-ui -a -t #{sdk} < "fixpaths.sh" +""".format(basebox, baseboxurl, memory) +if aptproxy: + vagrantfile += """ + config.vm.provision :shell, :inline => 'sudo echo "Acquire::http {{ Proxy \\"{0}\\"; }};" > /etc/apt/apt.conf.d/02proxy && sudo apt-get update' +""".format(aptproxy) +vagrantfile += """ + config.vm.provision :chef_solo do |chef| + chef.cookbooks_path = "cookbooks" + chef.log_level = :debug + chef.json = { + :settings => { + :sdk_loc => "/home/vagrant/android-sdk", + :ndk_loc => "/home/vagrant/android-ndk", + :user => "vagrant" + } + } + chef.add_recipe "fdroidbuild-general" + chef.add_recipe "android-sdk" + chef.add_recipe "android-ndk" + end +end +""" + +# Check against the existing Vagrantfile, and if they differ, we need to +# create a new box: +vf = os.path.join(serverdir, 'Vagrantfile') +writevf = True +if os.path.exists(vf): + vagrant(['halt'], serverdir) + with open(vf, 'r') as f: + oldvf = f.read() + if oldvf != vagrantfile: + print "Server configuration has changed, rebuild from scratch is required" + vagrant(['destroy', '-f'], serverdir) + else: + print "Re-provisioning existing server" + writevf = False +else: + print "No existing server - building from scratch" +if writevf: + with open(vf, 'w') as f: + f.write(vagrantfile) + + print "Configuring build server VM" -returncode, out, err = vagrant(['up'], serverdir) +returncode, out = vagrant(['up'], serverdir, printout=True) with open(os.path.join(serverdir, 'up.log'), 'w') as log: - log.write('==stdout==\n' + out + '\n\n') - log.write('==stderr==\n' + err + '\n\n') + log.write(out) if returncode != 0: print "Failed to configure server" sys.exit(1) @@ -67,7 +145,7 @@ print "Waiting for build server VM to be finished" ready = False while not ready: time.sleep(2) - returncode, out, err = vagrant(['status'], serverdir) + returncode, out = vagrant(['status'], serverdir) if returncode != 0: print "Error while checking status" sys.exit(1)