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

Some more build capabilities, and an optimisation for SVN when doing tag checkouts

This commit is contained in:
Ciaran Gultnieks 2011-01-08 22:31:55 +00:00
parent ed8f0ca147
commit a855e38fff
2 changed files with 54 additions and 21 deletions

4
README
View File

@ -118,6 +118,10 @@ configuration to the build. These are:
AndroidManifest.xml. AndroidManifest.xml.
antcommand=xxx - Specify an alternate ant command (target) instead of the antcommand=xxx - Specify an alternate ant command (target) instead of the
default 'release'. default 'release'.
insertversion=x - If specified, the pattern 'x' in the AndroidManifest.xml is
replaced with the version number for the build.
insertvercode=x - If specified, the pattern 'x' in the AndroidManifest.xml is
replaced with the version code for the build.
Another example, using extra parameters: Another example, using extra parameters:

View File

@ -25,6 +25,7 @@ import re
import zipfile import zipfile
import tarfile import tarfile
import md5 import md5
import shlex
from xml.dom.minidom import Document from xml.dom.minidom import Document
from optparse import OptionParser from optparse import OptionParser
@ -125,38 +126,45 @@ for app in apps:
# Optionally, the actual app source can be in a subdirectory... # Optionally, the actual app source can be in a subdirectory...
doupdate = True
if thisbuild.has_key('subdir'): if thisbuild.has_key('subdir'):
if app['repotype'] == 'svn' and 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',
repo[:-1] + thisbuild['subdir'], repo[:-1] + thisbuild['subdir'],
'-r', thisbuild['commit'],
build_dir] + repouserargs) != 0: build_dir] + repouserargs) != 0:
print "Svn checkout failed" print "Svn checkout failed"
sys.exit(1) sys.exit(1)
# Because we're checking out for every version we build,
# we've already checked out the repo at the correct revision
# and don't need to update to it...
doupdate = False
else: else:
root_dir = os.path.join(build_dir, thisbuild['subdir']) root_dir = os.path.join(build_dir, thisbuild['subdir'])
else: else:
root_dir = build_dir root_dir = build_dir
if app['repotype'] == 'git': if doupdate:
if subprocess.call(['git', 'checkout', thisbuild['commit']], if app['repotype'] == 'git':
cwd=build_dir) != 0: if subprocess.call(['git', 'checkout', thisbuild['commit']],
print "Git checkout failed" cwd=build_dir) != 0:
sys.exit(1) print "Git checkout failed"
elif app['repotype'] == 'svn': sys.exit(1)
if subprocess.call(['svn', 'update', '-r', thisbuild['commit']], elif app['repotype'] == 'svn':
cwd=build_dir) != 0: if subprocess.call(['svn', 'update', '-r', thisbuild['commit']],
print "Svn update failed" cwd=build_dir) != 0:
sys.exit(1) print "Svn update failed"
elif app['repotype'] == 'hg': sys.exit(1)
if subprocess.call(['hg', 'checkout', thisbuild['commit']], elif app['repotype'] == 'hg':
cwd=build_dir) != 0: if subprocess.call(['hg', 'checkout', thisbuild['commit']],
print "Hg checkout failed" cwd=build_dir) != 0:
sys.exit(1) print "Hg checkout failed"
sys.exit(1)
else: else:
print "Invalid repo type " + app['repotype'] print "Invalid repo type " + app['repotype']
sys.exit(1) sys.exit(1)
# Generate (or update) the ant build file, build.xml... # Generate (or update) the ant build file, build.xml...
parms = ['android','update','project','-p','.'] parms = ['android','update','project','-p','.']
@ -176,7 +184,7 @@ for app in apps:
print "Failed to amend build.properties" print "Failed to amend build.properties"
sys.exit(1) sys.exit(1)
#Update the local.properties file... # Update the local.properties file...
locprops = os.path.join(root_dir, 'local.properties') locprops = os.path.join(root_dir, 'local.properties')
f = open(locprops, 'r') f = open(locprops, 'r')
props = f.read() props = f.read()
@ -194,11 +202,32 @@ for app in apps:
f.write(props) f.write(props)
f.close() f.close()
#Delete unwanted file... # Insert version code and number into the manifest if necessary...
if thisbuild.has_key('insertversion'):
if subprocess.call(['sed','-i','s/' + thisbuild['insertversion'] +
'/' + thisbuild['version'] +'/g',
'AndroidManifest.xml'], cwd=root_dir) !=0:
print "Failed to amend manifest"
sys.exit(1)
if thisbuild.has_key('insertvercode'):
if subprocess.call(['sed','-i','s/' + thisbuild['insertvercode'] +
'/' + thisbuild['vercode'] +'/g',
'AndroidManifest.xml'], cwd=root_dir) !=0:
print "Failed to amend manifest"
sys.exit(1)
# Delete unwanted file...
if thisbuild.has_key('rm'): if thisbuild.has_key('rm'):
os.remove(os.path.join(build_dir, thisbuild['rm'])) os.remove(os.path.join(build_dir, thisbuild['rm']))
#Build the source tarball right before we build the relase... # Run a pre-build command if one is required...
if thisbuild.has_key('prebuild'):
if subprocess.call(shlex.split(thisbuild['prebuild']),
cwd=root_dir) != 0:
print "Error running pre-build command"
sys.exit(1)
# Build the source tarball right before we build the release...
tarname = app['id'] + '_' + thisbuild['vercode'] + '_src' tarname = app['id'] + '_' + thisbuild['vercode'] + '_src'
tarball = tarfile.open(os.path.join(built_dir, tarball = tarfile.open(os.path.join(built_dir,
tarname + '.tar.gz'), "w:gz") tarname + '.tar.gz'), "w:gz")