From e916e5df4e7ecb605b04d7614bc9762f514413bd Mon Sep 17 00:00:00 2001 From: =?UTF-8?q?Daniel=20Mart=C3=AD?= Date: Sun, 10 May 2015 13:53:06 +0200 Subject: [PATCH] Add COMMIT, VERSION and VERCODE recipe vars. Fixes #69 --- fdroidserver/build.py | 2 +- fdroidserver/common.py | 12 ++++++++---- 2 files changed, 9 insertions(+), 5 deletions(-) diff --git a/fdroidserver/build.py b/fdroidserver/build.py index e44dd5bb..ffff08e4 100644 --- a/fdroidserver/build.py +++ b/fdroidserver/build.py @@ -575,7 +575,7 @@ def build_local(app, thisbuild, vcs, build_dir, output_dir, srclib_dir, extlib_d # Run a build command if one is required... if thisbuild['build']: logging.info("Running 'build' commands in %s" % root_dir) - cmd = common.replace_config_vars(thisbuild['build']) + cmd = common.replace_config_vars(thisbuild['build'], thisbuild) # Substitute source library paths into commands... for name, number, libpath in srclibpaths: diff --git a/fdroidserver/common.py b/fdroidserver/common.py index 928f1d6d..9618727a 100644 --- a/fdroidserver/common.py +++ b/fdroidserver/common.py @@ -1169,7 +1169,7 @@ def getsrclib(spec, srclib_dir, srclibpaths=[], subdir=None, if prepare: if srclib["Prepare"]: - cmd = replace_config_vars(srclib["Prepare"]) + cmd = replace_config_vars(srclib["Prepare"], None) p = FDroidPopen(['bash', '-x', '-c', cmd], cwd=libdir) if p.returncode != 0: @@ -1220,7 +1220,7 @@ def prepare_source(vcs, app, build, build_dir, srclib_dir, extlib_dir, onserver= # Run an init command if one is required if build['init']: - cmd = replace_config_vars(build['init']) + cmd = replace_config_vars(build['init'], build) logging.info("Running 'init' commands in %s" % root_dir) p = FDroidPopen(['bash', '-x', '-c', cmd], cwd=root_dir) @@ -1406,7 +1406,7 @@ def prepare_source(vcs, app, build, build_dir, srclib_dir, extlib_dir, onserver= if build['prebuild']: logging.info("Running 'prebuild' commands in %s" % root_dir) - cmd = replace_config_vars(build['prebuild']) + cmd = replace_config_vars(build['prebuild'], build) # Substitute source library paths into prebuild commands for name, number, libpath in srclibpaths: @@ -1874,12 +1874,16 @@ def add_to_env_path(path): env['PATH'] = os.pathsep.join(paths) -def replace_config_vars(cmd): +def replace_config_vars(cmd, build): global env cmd = cmd.replace('$$SDK$$', config['sdk_path']) # env['ANDROID_NDK'] is set in build_local right before prepare_source cmd = cmd.replace('$$NDK$$', env['ANDROID_NDK']) cmd = cmd.replace('$$MVN3$$', config['mvn3']) + if build is not None: + cmd = cmd.replace('$$COMMIT$$', build['commit']) + cmd = cmd.replace('$$VERSION$$', build['version']) + cmd = cmd.replace('$$VERCODE$$', build['vercode']) return cmd