From e449d2f5839805071c0837dbd6ff401bebbe12c3 Mon Sep 17 00:00:00 2001 From: Hans-Christoph Steiner Date: Wed, 15 Jun 2016 13:09:57 +0200 Subject: [PATCH] buildserver: setup env vars using standard script bash provides a standard file location for a script to be run when the shell starts: /etc/profile.d/ This converts the scattered bits of code for making ~/.bsenv into a single provisioning script to generate /etc/profile.d/bsenv.sh, which gets automatically executed when bash starts --- .../fdroidbuild-general/recipes/default.rb | 6 ------ buildserver/cookbooks/gradle/recipes/default.rb | 6 ------ buildserver/setup-env-vars | 16 ++++++++++++++++ fdroidserver/build.py | 2 +- makebuildserver | 6 ++++++ 5 files changed, 23 insertions(+), 13 deletions(-) create mode 100644 buildserver/setup-env-vars diff --git a/buildserver/cookbooks/fdroidbuild-general/recipes/default.rb b/buildserver/cookbooks/fdroidbuild-general/recipes/default.rb index 6cde2f92..f9f81fe0 100644 --- a/buildserver/cookbooks/fdroidbuild-general/recipes/default.rb +++ b/buildserver/cookbooks/fdroidbuild-general/recipes/default.rb @@ -97,12 +97,6 @@ easy_install_package "compare-locales" do action :install end -execute "add-bsenv" do - user user - command "echo \". ./.bsenv \" >> /home/#{user}/.bashrc" - not_if "grep bsenv /home/#{user}/.bashrc" -end - execute "set-default-java" do command "update-java-alternatives --set java-1.7.0-openjdk-i386" end diff --git a/buildserver/cookbooks/gradle/recipes/default.rb b/buildserver/cookbooks/gradle/recipes/default.rb index 74dba2c4..2c2a4956 100644 --- a/buildserver/cookbooks/gradle/recipes/default.rb +++ b/buildserver/cookbooks/gradle/recipes/default.rb @@ -40,9 +40,3 @@ EOF chmod a+x /opt/gradle/bin/gradle " end - -execute "add-android-ndk-path" do - user user - command "echo \"export PATH=\\$PATH:/opt/gradle/bin #PATH-GRADLE\" >> /home/#{user}/.bsenv" - not_if "grep PATH-GRADLE /home/#{user}/.bsenv" -end diff --git a/buildserver/setup-env-vars b/buildserver/setup-env-vars new file mode 100644 index 00000000..83d433eb --- /dev/null +++ b/buildserver/setup-env-vars @@ -0,0 +1,16 @@ +#!/bin/sh +# +# sets up the environment vars needed by the build process + +set -e +set -x + +bsenv=/etc/profile.d/bsenv.sh + +echo "# generated on "`date` > $bsenv + +echo export ANDROID_HOME=$1 >> $bsenv +echo export ANDROID_NDK_HOME=$2 >> $bsenv +echo 'export PATH=$PATH:${ANDROID_HOME}/tools:${ANDROID_HOME}/platform-tools:/opt/gradle/bin' >> $bsenv + +chmod 0644 $bsenv diff --git a/fdroidserver/build.py b/fdroidserver/build.py index a387d13b..8376cadf 100644 --- a/fdroidserver/build.py +++ b/fdroidserver/build.py @@ -388,7 +388,7 @@ def build_server(app, build, vcs, build_dir, output_dir, force): if options.verbose: cmdline += ' --verbose' cmdline += " %s:%s" % (app.id, build.vercode) - chan.exec_command('bash -c ". ~/.bsenv && ' + cmdline + '"') + chan.exec_command('bash -c "' + cmdline + '"') output = bytes() while not chan.exit_status_ready(): while chan.recv_ready(): diff --git a/makebuildserver b/makebuildserver index cff8b64e..dbb51005 100755 --- a/makebuildserver +++ b/makebuildserver @@ -373,6 +373,12 @@ if config['apt_package_cache']: """.format(aptcachedir) vagrantfile += """ + + config.vm.provision "shell" do |shell| + shell.path = "setup-env-vars" + shell.args = ["/home/vagrant/android-sdk", "/home/vagrant/android-ndk"] + end + config.vm.provision :chef_solo do |chef| chef.cookbooks_path = "cookbooks" chef.log_level = :debug