From 9386d092e22eab22997a5c1e6d25f24682a53209 Mon Sep 17 00:00:00 2001 From: Ciaran Gultnieks Date: Sat, 8 Jan 2011 21:07:58 +0000 Subject: [PATCH] More build capabilities - svn authentication, ndk location, custom ant target --- README | 6 +++++ build.py | 58 +++++++++++++++++++++++++++++++++++------------- config.sample.py | 2 ++ 3 files changed, 50 insertions(+), 16 deletions(-) diff --git a/README b/README index 812311aa..ef6fb9b1 100644 --- a/README +++ b/README @@ -81,6 +81,10 @@ repository URL - in this case the repository is checked out once per build version, with the subdir parameter in place of the *. This can be beneficial when dealing with very large SVN repositories. +For a Subversion repo that requires authentication, you can precede the repo +URL with username:password@ and those parameters will be passed as --username +and --password to the SVN checkout command. + ==Build Version== Any number of these fields can be present, each specifying a version to @@ -112,6 +116,8 @@ configuration to the build. These are: build is done. The path is relative to the base of the build directory - i.e. the directory that contains AndroidManifest.xml. + antcommand=xxx - Specify an alternate ant command (target) instead of the + default 'release'. Another example, using extra parameters: diff --git a/build.py b/build.py index 62c6a4c4..2acbf48e 100644 --- a/build.py +++ b/build.py @@ -86,18 +86,37 @@ for app in apps: if os.path.exists(build_dir): shutil.rmtree(build_dir) + # Strip username/password out of repo address if specified (relevant + # only for SVN) and store for use later. + repo = app['repo'] + index = repo.find('@') + if index != -1: + username = repo[:index] + repo = repo[index+1:] + index = username.find(':') + if index == -1: + print "Password required with username" + sys.exit(1) + password = username[index+1:] + username = username[:index] + repouserargs = ['--username', username, + '--password', password, '--non-interactive'] + else: + repouserargs = [] + # Get the source code... if app['repotype'] == 'git': - if subprocess.call(['git', 'clone', app['repo'], build_dir]) != 0: + if subprocess.call(['git', 'clone', repo, build_dir]) != 0: print "Git clone failed" sys.exit(1) elif app['repotype'] == 'svn': - if not app['repo'].endswith("*"): - if subprocess.call(['svn', 'checkout', app['repo'], build_dir]) != 0: + if not repo.endswith("*"): + if subprocess.call(['svn', 'checkout', repo, build_dir] + + repouserargs) != 0: print "Svn checkout failed" sys.exit(1) elif app['repotype'] == 'hg': - if subprocess.call(['hg', 'clone', app['repo'], build_dir]) !=0: + if subprocess.call(['hg', 'clone', repo, build_dir]) !=0: print "Hg clone failed" sys.exit(1) else: @@ -107,11 +126,11 @@ for app in apps: # Optionally, the actual app source can be in a subdirectory... if thisbuild.has_key('subdir'): - if app['repotype'] == 'svn' and app['repo'].endswith("*"): + if app['repotype'] == 'svn' and repo.endswith("*"): root_dir = build_dir if subprocess.call(['svn', 'checkout', - app['repo'][:-1] + thisbuild['subdir'], - build_dir]) != 0: + repo[:-1] + thisbuild['subdir'], + build_dir] + repouserargs) != 0: print "Svn checkout failed" sys.exit(1) else: @@ -157,20 +176,23 @@ for app in apps: print "Failed to amend build.properties" sys.exit(1) - # Fix old-fashioned 'sdk-location' in local.properties by copying + #Update the local.properties file... + locprops = os.path.join(root_dir, 'local.properties') + f = open(locprops, 'r') + props = f.read() + f.close() + # Fix old-fashioned 'sdk-location' by copying # from sdk.dir, if necessary... if (thisbuild.has_key('oldsdkloc') and thisbuild['oldsdkloc'] == "yes"): - locprops = os.path.join(root_dir, 'local.properties') - f = open(locprops, 'r') - props = f.read() - f.close() sdkloc = re.match(r".*^sdk.dir=(\S+)$.*", props, re.S|re.M).group(1) props += "\nsdk-location=" + sdkloc + "\n" - f = open(locprops, 'w') - f.write(props) - f.close() + # Add ndk location... + props+= "\nndk.dir=" + ndk_path + "\n" + f = open(locprops, 'w') + f.write(props) + f.close() #Delete unwanted file... if thisbuild.has_key('rm'): @@ -184,7 +206,11 @@ for app in apps: tarball.close() # Build the release... - p = subprocess.Popen(['ant','release'], cwd=root_dir, + if thisbuild.has_key('antcommand'): + antcommand = thisbuild['antcommand'] + else: + antcommand = 'release' + p = subprocess.Popen(['ant', antcommand], cwd=root_dir, stdout=subprocess.PIPE) output = p.communicate()[0] if p.returncode != 0: diff --git a/config.sample.py b/config.sample.py index 50cfb2ef..ac6b2b09 100644 --- a/config.sample.py +++ b/config.sample.py @@ -4,6 +4,8 @@ aapt_path = "/path/to/android-sdk-linux_86/platforms/android-4/tools/aapt" +ndk_path = "/path/to/android-ndk-r5" + repo_url = "http://f-droid.org/repo" repo_name = "FDroid" repo_icon = "fdroid-icon.png" -- 2.30.2