1
0
mirror of https://gitlab.com/fdroid/fdroidserver.git synced 2024-10-05 18:50:09 +02:00

More build capabilities - svn authentication, ndk location, custom ant target

This commit is contained in:
Ciaran Gultnieks 2011-01-08 21:07:58 +00:00
parent 06b7d44765
commit 9386d092e2
3 changed files with 50 additions and 16 deletions

6
README
View File

@ -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 version, with the subdir parameter in place of the *. This can be beneficial
when dealing with very large SVN repositories. 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== ==Build Version==
Any number of these fields can be present, each specifying a version to 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 is done. The path is relative to the base of the
build directory - i.e. the directory that contains build directory - i.e. the directory that contains
AndroidManifest.xml. AndroidManifest.xml.
antcommand=xxx - Specify an alternate ant command (target) instead of the
default 'release'.
Another example, using extra parameters: Another example, using extra parameters:

View File

@ -86,18 +86,37 @@ for app in apps:
if os.path.exists(build_dir): if os.path.exists(build_dir):
shutil.rmtree(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... # Get the source code...
if app['repotype'] == 'git': 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" print "Git clone failed"
sys.exit(1) sys.exit(1)
elif app['repotype'] == 'svn': elif app['repotype'] == 'svn':
if not app['repo'].endswith("*"): if not repo.endswith("*"):
if subprocess.call(['svn', 'checkout', app['repo'], build_dir]) != 0: if subprocess.call(['svn', 'checkout', repo, build_dir] +
repouserargs) != 0:
print "Svn checkout failed" print "Svn checkout failed"
sys.exit(1) sys.exit(1)
elif app['repotype'] == 'hg': 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" print "Hg clone failed"
sys.exit(1) sys.exit(1)
else: else:
@ -107,11 +126,11 @@ for app in apps:
# Optionally, the actual app source can be in a subdirectory... # Optionally, the actual app source can be in a subdirectory...
if thisbuild.has_key('subdir'): if thisbuild.has_key('subdir'):
if app['repotype'] == 'svn' and app['repo'].endswith("*"): if app['repotype'] == 'svn' and repo.endswith("*"):
root_dir = build_dir root_dir = build_dir
if subprocess.call(['svn', 'checkout', if subprocess.call(['svn', 'checkout',
app['repo'][:-1] + thisbuild['subdir'], repo[:-1] + thisbuild['subdir'],
build_dir]) != 0: build_dir] + repouserargs) != 0:
print "Svn checkout failed" print "Svn checkout failed"
sys.exit(1) sys.exit(1)
else: else:
@ -157,20 +176,23 @@ for app in apps:
print "Failed to amend build.properties" print "Failed to amend build.properties"
sys.exit(1) 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... # from sdk.dir, if necessary...
if (thisbuild.has_key('oldsdkloc') and if (thisbuild.has_key('oldsdkloc') and
thisbuild['oldsdkloc'] == "yes"): 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, sdkloc = re.match(r".*^sdk.dir=(\S+)$.*", props,
re.S|re.M).group(1) re.S|re.M).group(1)
props += "\nsdk-location=" + sdkloc + "\n" props += "\nsdk-location=" + sdkloc + "\n"
f = open(locprops, 'w') # Add ndk location...
f.write(props) props+= "\nndk.dir=" + ndk_path + "\n"
f.close() f = open(locprops, 'w')
f.write(props)
f.close()
#Delete unwanted file... #Delete unwanted file...
if thisbuild.has_key('rm'): if thisbuild.has_key('rm'):
@ -184,7 +206,11 @@ for app in apps:
tarball.close() tarball.close()
# Build the release... # 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) stdout=subprocess.PIPE)
output = p.communicate()[0] output = p.communicate()[0]
if p.returncode != 0: if p.returncode != 0:

View File

@ -4,6 +4,8 @@
aapt_path = "/path/to/android-sdk-linux_86/platforms/android-4/tools/aapt" 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_url = "http://f-droid.org/repo"
repo_name = "FDroid" repo_name = "FDroid"
repo_icon = "fdroid-icon.png" repo_icon = "fdroid-icon.png"