chiark / gitweb /
buildserver: setup env vars using standard script
authorHans-Christoph Steiner <hans@eds.org>
Wed, 15 Jun 2016 11:09:57 +0000 (13:09 +0200)
committerHans-Christoph Steiner <hans@eds.org>
Wed, 15 Jun 2016 13:26:35 +0000 (15:26 +0200)
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

buildserver/cookbooks/fdroidbuild-general/recipes/default.rb
buildserver/cookbooks/gradle/recipes/default.rb
buildserver/setup-env-vars [new file with mode: 0644]
fdroidserver/build.py
makebuildserver

index 6cde2f92bc525cf63cf06b966e38c124865c0fbf..f9f81fe08aca96c5744ff4f17e6dda8db8e86592 100644 (file)
@@ -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
index 74dba2c41f68303701a601310d26145f90446e22..2c2a49562e1319b972ccb40d6eabebdeb51ea2a4 100644 (file)
@@ -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 (file)
index 0000000..83d433e
--- /dev/null
@@ -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
index a387d13bca321b14145ade0a910a3e4fce47a11d..8376cadffe2d82259083e4b72700005416553d33 100644 (file)
@@ -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():
index cff8b64e8063553cb352b140b1b7ca0098aff08b..dbb51005f16fd83f36f2d793e33893f511e77b55 100755 (executable)
@@ -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