chiark / gitweb /
Set up SDK and NDK env vars from python
authorDaniel Martí <mvdan@mvdan.cc>
Tue, 1 Jul 2014 19:03:50 +0000 (21:03 +0200)
committerDaniel Martí <mvdan@mvdan.cc>
Tue, 1 Jul 2014 19:03:50 +0000 (21:03 +0200)
No need to make the buildserver do it

buildserver/cookbooks/android-ndk/recipes/default.rb
buildserver/cookbooks/android-sdk/recipes/default.rb
fdroidserver/common.py

index 13e64d489d9c709c2a8a34fbc748384d28274005..460b4fc4b666a5c18a5f884b679146e3e07d2985 100644 (file)
@@ -8,12 +8,6 @@ execute "add-android-ndk-path" do
   not_if "grep PATH-NDK /home/#{user}/.bsenv"
 end
 
-execute "add-android-ndk-var" do
-  user user
-  command "echo \"export ANDROID_NDK=#{ndk_loc}\" >> /home/#{user}/.bsenv"
-  not_if "grep ANDROID_NDK /home/#{user}/.bsenv"
-end
-
 script "setup-android-ndk" do
   timeout 14400
   interpreter "bash"
index 0c925c2cf0bf859f5b8f7a6bcf62d09c9d8e724d..3d6ff562d8ffa8882b5cd47e93b0603e101763ef 100644 (file)
@@ -23,12 +23,6 @@ execute "add-android-sdk-path" do
   not_if "grep PATH-SDK /home/#{user}/.bsenv"
 end
 
-execute "add-android-home" do
-  user user
-  command "echo \"export ANDROID_HOME=#{sdk_loc}\" >> /home/#{user}/.bsenv"
-  not_if "grep ANDROID_HOME /home/#{user}/.bsenv"
-end
-
 script "add_build_tools" do
   interpreter "bash"
   user user
index e80613d1cede3f3ac6e1d7057d79ab846c64e259..a0aeb982a5eeb3632557642597865aed3cb6ae65 100644 (file)
@@ -36,6 +36,7 @@ import metadata
 
 config = None
 options = None
+env = None
 
 
 def get_default_config():
@@ -76,7 +77,7 @@ def read_config(opts, config_file='config.py'):
     The config is read from config_file, which is in the current directory when
     any of the repo management commands are used.
     """
-    global config, options
+    global config, options, env
 
     if config is not None:
         return config
@@ -124,6 +125,15 @@ def read_config(opts, config_file='config.py'):
     if not test_build_tools_exists(config):
         sys.exit(3)
 
+    env = os.environ
+
+    # There is no standard, so just set up the most common environment
+    # variables
+    for n in ['ANDROID_HOME', 'ANDROID_SDK', 'SDK']:
+        env[n] = config['sdk_path']
+    for n in ['ANDROID_NDK', 'NDK']:
+        env[n] = config['ndk_path']
+
     for k in ["keystorepass", "keypass"]:
         if k in config:
             write_password_file(k)
@@ -1594,13 +1604,15 @@ def FDroidPopen(commands, cwd=None, shell=False, output=True):
     :returns: A PopenResult.
     """
 
+    global env
+
     if cwd:
         cwd = os.path.normpath(cwd)
         logging.debug("Directory: %s" % cwd)
     logging.debug("> %s" % ' '.join(commands))
 
     result = PopenResult()
-    p = subprocess.Popen(commands, cwd=cwd, shell=shell,
+    p = subprocess.Popen(commands, cwd=cwd, shell=shell, env=env,
                          stdout=subprocess.PIPE, stderr=subprocess.STDOUT)
 
     stdout_queue = Queue.Queue()