1
0
mirror of https://gitlab.com/fdroid/fdroidserver.git synced 2024-11-09 00:40:11 +01:00

Use ordered dicts for defaults in apps and builds

This commit is contained in:
Daniel Martí 2014-05-31 23:10:16 +02:00
parent c125ab9b7f
commit 3d72c30fe5
7 changed files with 141 additions and 125 deletions

View File

@ -326,7 +326,7 @@ def build_server(app, thisbuild, vcs, build_dir, output_dir, force):
ftp.mkdir('extlib') ftp.mkdir('extlib')
ftp.mkdir('srclib') ftp.mkdir('srclib')
# Copy any extlibs that are required... # Copy any extlibs that are required...
if 'extlibs' in thisbuild: if thisbuild['extlibs']:
ftp.chdir(homedir + '/build/extlib') ftp.chdir(homedir + '/build/extlib')
for lib in thisbuild['extlibs']: for lib in thisbuild['extlibs']:
lib = lib.strip() lib = lib.strip()
@ -343,7 +343,7 @@ def build_server(app, thisbuild, vcs, build_dir, output_dir, force):
ftp.chdir('..') ftp.chdir('..')
# Copy any srclibs that are required... # Copy any srclibs that are required...
srclibpaths = [] srclibpaths = []
if 'srclibs' in thisbuild: if thisbuild['srclibs']:
for lib in thisbuild['srclibs']: for lib in thisbuild['srclibs']:
srclibpaths.append( srclibpaths.append(
common.getsrclib(lib, 'build/srclib', srclibpaths, common.getsrclib(lib, 'build/srclib', srclibpaths,
@ -439,7 +439,7 @@ def adapt_gradle(build_dir):
def build_local(app, thisbuild, vcs, build_dir, output_dir, srclib_dir, extlib_dir, tmp_dir, force, onserver): def build_local(app, thisbuild, vcs, build_dir, output_dir, srclib_dir, extlib_dir, tmp_dir, force, onserver):
"""Do a build locally.""" """Do a build locally."""
if thisbuild.get('buildjni') not in (None, ['no']): if thisbuild['buildjni'] and thisbuild['buildjni'] != ['no']:
if not config['ndk_path']: if not config['ndk_path']:
logging.critical("$ANDROID_NDK is not set!") logging.critical("$ANDROID_NDK is not set!")
sys.exit(3) sys.exit(3)
@ -546,13 +546,14 @@ def build_local(app, thisbuild, vcs, build_dir, output_dir, srclib_dir, extlib_d
f.write(manifestcontent) f.write(manifestcontent)
# Run a build command if one is required... # Run a build command if one is required...
if 'build' in thisbuild: 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'])
# Substitute source library paths into commands... # Substitute source library paths into commands...
for name, number, libpath in srclibpaths: for name, number, libpath in srclibpaths:
libpath = os.path.relpath(libpath, root_dir) libpath = os.path.relpath(libpath, root_dir)
cmd = cmd.replace('$$' + name + '$$', libpath) cmd = cmd.replace('$$' + name + '$$', libpath)
logging.info("Running 'build' commands in %s" % root_dir)
p = FDroidPopen(['bash', '-x', '-c', cmd], cwd=root_dir) p = FDroidPopen(['bash', '-x', '-c', cmd], cwd=root_dir)
@ -561,9 +562,10 @@ def build_local(app, thisbuild, vcs, build_dir, output_dir, srclib_dir, extlib_d
(app['id'], thisbuild['version']), p.stdout) (app['id'], thisbuild['version']), p.stdout)
# Build native stuff if required... # Build native stuff if required...
if thisbuild.get('buildjni') not in (None, ['no']): if thisbuild['buildjni'] and thisbuild['buildjni'] != ['no']:
logging.info("Building native libraries...") logging.info("Building the native code")
jni_components = thisbuild.get('buildjni') jni_components = thisbuild['buildjni']
if jni_components == ['yes']: if jni_components == ['yes']:
jni_components = [''] jni_components = ['']
cmd = [os.path.join(config['ndk_path'], "ndk-build"), "-j1"] cmd = [os.path.join(config['ndk_path'], "ndk-build"), "-j1"]
@ -601,7 +603,7 @@ def build_local(app, thisbuild, vcs, build_dir, output_dir, srclib_dir, extlib_d
'-Dmaven.jar.sign.skip=true', '-Dmaven.test.skip=true', '-Dmaven.jar.sign.skip=true', '-Dmaven.test.skip=true',
'-Dandroid.sign.debug=false', '-Dandroid.release=true', '-Dandroid.sign.debug=false', '-Dandroid.release=true',
'package'] 'package']
if 'target' in thisbuild: if thisbuild['target']:
target = thisbuild["target"].split('-')[1] target = thisbuild["target"].split('-')[1]
FDroidPopen(['sed', '-i', FDroidPopen(['sed', '-i',
's@<platform>[0-9]*</platform>@<platform>' 's@<platform>[0-9]*</platform>@<platform>'
@ -615,7 +617,7 @@ def build_local(app, thisbuild, vcs, build_dir, output_dir, srclib_dir, extlib_d
'pom.xml'], 'pom.xml'],
cwd=maven_dir) cwd=maven_dir)
if 'mvnflags' in thisbuild: if thisbuild['mvnflags']:
mvncmd += thisbuild['mvnflags'] mvncmd += thisbuild['mvnflags']
p = FDroidPopen(mvncmd, cwd=maven_dir) p = FDroidPopen(mvncmd, cwd=maven_dir)
@ -697,7 +699,7 @@ def build_local(app, thisbuild, vcs, build_dir, output_dir, srclib_dir, extlib_d
flavours[0] = '' flavours[0] = ''
commands = [config['gradle']] commands = [config['gradle']]
if 'preassemble' in thisbuild: if thisbuild['preassemble']:
commands += thisbuild['preassemble'].split() commands += thisbuild['preassemble'].split()
flavours_cmd = ''.join(flavours) flavours_cmd = ''.join(flavours)
@ -711,7 +713,7 @@ def build_local(app, thisbuild, vcs, build_dir, output_dir, srclib_dir, extlib_d
elif thisbuild['type'] == 'ant': elif thisbuild['type'] == 'ant':
logging.info("Building Ant project...") logging.info("Building Ant project...")
cmd = ['ant'] cmd = ['ant']
if 'antcommand' in thisbuild: if thisbuild['antcommand']:
cmd += [thisbuild['antcommand']] cmd += [thisbuild['antcommand']]
else: else:
cmd += ['release'] cmd += ['release']
@ -744,7 +746,7 @@ def build_local(app, thisbuild, vcs, build_dir, output_dir, srclib_dir, extlib_d
elif thisbuild['type'] == 'gradle': elif thisbuild['type'] == 'gradle':
basename = app['id'] basename = app['id']
dd = build_dir dd = build_dir
if 'subdir' in thisbuild: if thisbuild['subdir']:
dd = os.path.join(dd, thisbuild['subdir']) dd = os.path.join(dd, thisbuild['subdir'])
basename = os.path.basename(thisbuild['subdir']) basename = os.path.basename(thisbuild['subdir'])
if '@' in thisbuild['gradle']: if '@' in thisbuild['gradle']:
@ -801,7 +803,7 @@ def build_local(app, thisbuild, vcs, build_dir, output_dir, srclib_dir, extlib_d
elif line.startswith("native-code:"): elif line.startswith("native-code:"):
nativecode = line[12:] nativecode = line[12:]
if thisbuild.get('buildjni') is not None: if thisbuild['buildjni']:
if nativecode is None or "'" not in nativecode: if nativecode is None or "'" not in nativecode:
raise BuildException("Native code should have been built but none was packaged") raise BuildException("Native code should have been built but none was packaged")
if thisbuild['novcheck']: if thisbuild['novcheck']:
@ -875,7 +877,7 @@ def trybuild(app, thisbuild, build_dir, output_dir, also_check_dir, srclib_dir,
if os.path.exists(dest_also): if os.path.exists(dest_also):
return False return False
if 'disable' in thisbuild: if thisbuild['disable']:
return False return False
logging.info("Building version " + thisbuild['version'] + ' of ' + app['id']) logging.info("Building version " + thisbuild['version'] + ' of ' + app['id'])
@ -997,7 +999,7 @@ def main():
if options.latest: if options.latest:
for app in apps: for app in apps:
for build in reversed(app['builds']): for build in reversed(app['builds']):
if 'disable' in build: if build['disable']:
continue continue
app['builds'] = [build] app['builds'] = [build]
break break

View File

@ -109,9 +109,9 @@ def check_tags(app, pattern):
flavour = None flavour = None
if len(app['builds']) > 0: if len(app['builds']) > 0:
if 'subdir' in app['builds'][-1]: if app['builds'][-1]['subdir']:
build_dir = os.path.join(build_dir, app['builds'][-1]['subdir']) build_dir = os.path.join(build_dir, app['builds'][-1]['subdir'])
if 'gradle' in app['builds'][-1]: if app['builds'][-1]['gradle']:
flavour = app['builds'][-1]['gradle'] flavour = app['builds'][-1]['gradle']
if flavour == 'yes': if flavour == 'yes':
flavour = None flavour = None
@ -198,9 +198,9 @@ def check_repomanifest(app, branch=None):
flavour = None flavour = None
if len(app['builds']) > 0: if len(app['builds']) > 0:
if 'subdir' in app['builds'][-1]: if app['builds'][-1]['subdir']:
build_dir = os.path.join(build_dir, app['builds'][-1]['subdir']) build_dir = os.path.join(build_dir, app['builds'][-1]['subdir'])
if 'gradle' in app['builds'][-1]: if app['builds'][-1]['gradle']:
flavour = app['builds'][-1]['gradle'] flavour = app['builds'][-1]['gradle']
if flavour == 'yes': if flavour == 'yes':
flavour = None flavour = None
@ -434,9 +434,9 @@ def main():
flavour = None flavour = None
if len(app['builds']) > 0: if len(app['builds']) > 0:
if 'subdir' in app['builds'][-1]: if app['builds'][-1]['subdir']:
app_dir = os.path.join(app_dir, app['builds'][-1]['subdir']) app_dir = os.path.join(app_dir, app['builds'][-1]['subdir'])
if 'gradle' in app['builds'][-1]: if app['builds'][-1]['gradle']:
flavour = app['builds'][-1]['gradle'] flavour = app['builds'][-1]['gradle']
if flavour == 'yes': if flavour == 'yes':
flavour = None flavour = None
@ -491,9 +491,8 @@ def main():
if not gotcur: if not gotcur:
newbuild = latest.copy() newbuild = latest.copy()
for k in ('origlines', 'disable'): del newbuild['origlines']
if k in newbuild: newbuild['disable'] = False
del newbuild[k]
newbuild['vercode'] = app['Current Version Code'] newbuild['vercode'] = app['Current Version Code']
newbuild['version'] = app['Current Version'] + suffix newbuild['version'] = app['Current Version'] + suffix
logging.info("...auto-generating build for " + newbuild['version']) logging.info("...auto-generating build for " + newbuild['version'])

View File

@ -1018,7 +1018,7 @@ def getsrclib(spec, srclib_dir, srclibpaths=[], subdir=None,
def prepare_source(vcs, app, build, build_dir, srclib_dir, extlib_dir, onserver=False): def prepare_source(vcs, app, build, build_dir, srclib_dir, extlib_dir, onserver=False):
# Optionally, the actual app source can be in a subdirectory # Optionally, the actual app source can be in a subdirectory
if 'subdir' in build: if build['subdir']:
root_dir = os.path.join(build_dir, build['subdir']) root_dir = os.path.join(build_dir, build['subdir'])
else: else:
root_dir = build_dir root_dir = build_dir
@ -1038,7 +1038,7 @@ def prepare_source(vcs, app, build, build_dir, srclib_dir, extlib_dir, onserver=
raise BuildException('Missing subdir ' + root_dir) raise BuildException('Missing subdir ' + root_dir)
# Run an init command if one is required # Run an init command if one is required
if 'init' in build: if build['init']:
cmd = replace_config_vars(build['init']) cmd = replace_config_vars(build['init'])
logging.info("Running 'init' commands in %s" % root_dir) logging.info("Running 'init' commands in %s" % root_dir)
@ -1048,7 +1048,8 @@ def prepare_source(vcs, app, build, build_dir, srclib_dir, extlib_dir, onserver=
(app['id'], build['version']), p.stdout) (app['id'], build['version']), p.stdout)
# Apply patches if any # Apply patches if any
if 'patch' in build: if build['patch']:
logging.info("Applying patches")
for patch in build['patch']: for patch in build['patch']:
patch = patch.strip() patch = patch.strip()
logging.info("Applying " + patch) logging.info("Applying " + patch)
@ -1059,7 +1060,7 @@ def prepare_source(vcs, app, build, build_dir, srclib_dir, extlib_dir, onserver=
# Get required source libraries # Get required source libraries
srclibpaths = [] srclibpaths = []
if 'srclibs' in build: if build['srclibs']:
logging.info("Collecting source libraries") logging.info("Collecting source libraries")
for lib in build['srclibs']: for lib in build['srclibs']:
srclibpaths.append(getsrclib(lib, srclib_dir, srclibpaths, srclibpaths.append(getsrclib(lib, srclib_dir, srclibpaths,
@ -1075,7 +1076,7 @@ def prepare_source(vcs, app, build, build_dir, srclib_dir, extlib_dir, onserver=
# Update the local.properties file # Update the local.properties file
localprops = [os.path.join(build_dir, 'local.properties')] localprops = [os.path.join(build_dir, 'local.properties')]
if 'subdir' in build: if build['subdir']:
localprops += [os.path.join(root_dir, 'local.properties')] localprops += [os.path.join(root_dir, 'local.properties')]
for path in localprops: for path in localprops:
if not os.path.isfile(path): if not os.path.isfile(path):
@ -1099,7 +1100,7 @@ def prepare_source(vcs, app, build, build_dir, srclib_dir, extlib_dir, onserver=
props += "ndk.dir=%s\n" % config['ndk_path'] props += "ndk.dir=%s\n" % config['ndk_path']
props += "ndk-location=%s\n" % config['ndk_path'] props += "ndk-location=%s\n" % config['ndk_path']
# Add java.encoding if necessary # Add java.encoding if necessary
if 'encoding' in build: if build['encoding']:
props += "java.encoding=%s\n" % build['encoding'] props += "java.encoding=%s\n" % build['encoding']
f = open(path, 'w') f = open(path, 'w')
f.write(props) f.write(props)
@ -1111,7 +1112,7 @@ def prepare_source(vcs, app, build, build_dir, srclib_dir, extlib_dir, onserver=
if flavour in ['main', 'yes', '']: if flavour in ['main', 'yes', '']:
flavour = None flavour = None
if 'target' in build: if build['target']:
n = build["target"].split('-')[1] n = build["target"].split('-')[1]
FDroidPopen(['sed', '-i', FDroidPopen(['sed', '-i',
's@compileSdkVersion *[0-9]*@compileSdkVersion ' + n + '@g', 's@compileSdkVersion *[0-9]*@compileSdkVersion ' + n + '@g',
@ -1169,7 +1170,8 @@ def prepare_source(vcs, app, build, build_dir, srclib_dir, extlib_dir, onserver=
raise BuildException("Failed to amend build.gradle") raise BuildException("Failed to amend build.gradle")
# Delete unwanted files # Delete unwanted files
if 'rm' in build: if build['rm']:
logging.info("Removing specified files")
for part in getpaths(build_dir, build, 'rm'): for part in getpaths(build_dir, build, 'rm'):
dest = os.path.join(build_dir, part) dest = os.path.join(build_dir, part)
logging.info("Removing {0}".format(part)) logging.info("Removing {0}".format(part))
@ -1184,7 +1186,7 @@ def prepare_source(vcs, app, build, build_dir, srclib_dir, extlib_dir, onserver=
remove_signing_keys(build_dir) remove_signing_keys(build_dir)
# Add required external libraries # Add required external libraries
if 'extlibs' in build: if build['extlibs']:
logging.info("Collecting prebuilt libraries") logging.info("Collecting prebuilt libraries")
libsdir = os.path.join(root_dir, 'libs') libsdir = os.path.join(root_dir, 'libs')
if not os.path.exists(libsdir): if not os.path.exists(libsdir):
@ -1199,7 +1201,9 @@ def prepare_source(vcs, app, build, build_dir, srclib_dir, extlib_dir, onserver=
shutil.copyfile(libsrc, os.path.join(libsdir, libf)) shutil.copyfile(libsrc, os.path.join(libsdir, libf))
# Run a pre-build command if one is required # Run a pre-build command if one is required
if 'prebuild' in build: if build['prebuild']:
logging.info("Running 'prebuild' commands in %s" % root_dir)
cmd = replace_config_vars(build['prebuild']) cmd = replace_config_vars(build['prebuild'])
# Substitute source library paths into prebuild commands # Substitute source library paths into prebuild commands
@ -1207,27 +1211,24 @@ def prepare_source(vcs, app, build, build_dir, srclib_dir, extlib_dir, onserver=
libpath = os.path.relpath(libpath, root_dir) libpath = os.path.relpath(libpath, root_dir)
cmd = cmd.replace('$$' + name + '$$', libpath) cmd = cmd.replace('$$' + name + '$$', libpath)
logging.info("Running 'prebuild' commands in %s" % root_dir)
p = FDroidPopen(['bash', '-x', '-c', cmd], cwd=root_dir) p = FDroidPopen(['bash', '-x', '-c', cmd], cwd=root_dir)
if p.returncode != 0: if p.returncode != 0:
raise BuildException("Error running prebuild command for %s:%s" % raise BuildException("Error running prebuild command for %s:%s" %
(app['id'], build['version']), p.stdout) (app['id'], build['version']), p.stdout)
updatemode = build.get('update', ['auto'])
# Generate (or update) the ant build file, build.xml... # Generate (or update) the ant build file, build.xml...
if updatemode != ['no'] and build['type'] == 'ant': if build['update'] and build['update'] != ['no'] and build['type'] == 'ant':
parms = [os.path.join(config['sdk_path'], 'tools', 'android'), 'update'] parms = [os.path.join(config['sdk_path'], 'tools', 'android'), 'update']
lparms = parms + ['lib-project'] lparms = parms + ['lib-project']
parms = parms + ['project'] parms = parms + ['project']
if 'target' in build and build['target']: if build['target']:
parms += ['-t', build['target']] parms += ['-t', build['target']]
lparms += ['-t', build['target']] lparms += ['-t', build['target']]
if updatemode == ['auto']: if build['update'] == ['auto']:
update_dirs = ant_subprojects(root_dir) + ['.'] update_dirs = ant_subprojects(root_dir) + ['.']
else: else:
update_dirs = updatemode update_dirs = build['update']
for d in update_dirs: for d in update_dirs:
subdir = os.path.join(root_dir, d) subdir = os.path.join(root_dir, d)
@ -1254,8 +1255,6 @@ def prepare_source(vcs, app, build, build_dir, srclib_dir, extlib_dir, onserver=
# Split and extend via globbing the paths from a field # Split and extend via globbing the paths from a field
def getpaths(build_dir, build, field): def getpaths(build_dir, build, field):
paths = [] paths = []
if field not in build:
return paths
for p in build[field]: for p in build[field]:
p = p.strip() p = p.strip()
full_path = os.path.join(build_dir, p) full_path = os.path.join(build_dir, p)
@ -1394,7 +1393,7 @@ def scan_source(build_dir, root_dir, thisbuild):
# indicate a problem (if it's not a problem, explicitly use # indicate a problem (if it's not a problem, explicitly use
# buildjni=no to bypass this check) # buildjni=no to bypass this check)
if (os.path.exists(os.path.join(root_dir, 'jni')) and if (os.path.exists(os.path.join(root_dir, 'jni')) and
thisbuild.get('buildjni') is None): not thisbuild['buildjni']):
logging.warn('Found jni directory, but buildjni is not enabled') logging.warn('Found jni directory, but buildjni is not enabled')
count += 1 count += 1

View File

@ -170,7 +170,7 @@ def main():
continue continue
for build in app['builds']: for build in app['builds']:
if 'commit' in build and 'disable' not in build: if build['commit'] and not build['disable']:
lastcommit = build['commit'] lastcommit = build['commit']
# Potentially incorrect UCM # Potentially incorrect UCM
@ -225,16 +225,14 @@ def main():
# Build warnings # Build warnings
for build in app['builds']: for build in app['builds']:
for n in ['master', 'origin/', 'default', 'trunk']: for n in ['master', 'origin/', 'default', 'trunk']:
if 'commit' in build: if build['commit'] and build['commit'].startswith(n):
if build['commit'].startswith(n): warn("Branch '%s' used as commit in build '%s'" % (
warn("Branch '%s' used as commit in build '%s'" % ( n, build['version']))
n, build['version'])) for srclib in build['srclibs']:
if 'srclibs' in build: ref = srclib.split('@')[1].split('/')[0]
for srclib in build['srclibs']: if ref.startswith(n):
ref = srclib.split('@')[1].split('/')[0] warn("Branch '%s' used as commit in srclib '%s'" % (
if ref.startswith(n): n, srclib))
warn("Branch '%s' used as commit in srclib '%s'" % (
n, srclib))
if not appid: if not appid:
print print

View File

@ -23,6 +23,8 @@ import glob
import cgi import cgi
import logging import logging
from collections import OrderedDict
srclibs = {} srclibs = {}
@ -33,51 +35,73 @@ class MetaDataException(Exception):
def __str__(self): def __str__(self):
return self.value return self.value
app_defaults = { # In the order in which they are laid out on files
'Disabled': None, app_defaults = OrderedDict([
'AntiFeatures': None, ('Disabled', None),
'Provides': None, ('AntiFeatures', None),
'Categories': ['None'], ('Provides', None),
'License': 'Unknown', ('Categories', ['None']),
'Web Site': '', ('License', 'Unknown'),
'Source Code': '', ('Web Site', ''),
'Issue Tracker': '', ('Source Code', ''),
'Donate': None, ('Issue Tracker', ''),
'FlattrID': None, ('Donate', None),
'Bitcoin': None, ('FlattrID', None),
'Litecoin': None, ('Bitcoin', None),
'Dogecoin': None, ('Litecoin', None),
'Name': None, ('Dogecoin', None),
'Auto Name': '', ('Name', None),
'Summary': '', ('Auto Name', ''),
'Description': [], ('Summary', ''),
'Requires Root': False, ('Description', []),
'Repo Type': '', ('Requires Root', False),
'Repo': '', ('Repo Type', ''),
'Maintainer Notes': [], ('Repo', ''),
'Archive Policy': None, ('Maintainer Notes', []),
'Auto Update Mode': 'None', ('Archive Policy', None),
'Update Check Mode': 'None', ('Auto Update Mode', 'None'),
'Update Check Ignore': None, ('Update Check Mode', 'None'),
'Vercode Operation': None, ('Update Check Ignore', None),
'Update Check Name': None, ('Vercode Operation', None),
'Update Check Data': None, ('Update Check Name', None),
'Current Version': '', ('Update Check Data', None),
'Current Version Code': '0', ('Current Version', ''),
'No Source Since': '' ('Current Version Code', '0'),
} ('No Source Since', ''),
])
# This defines the preferred order for the build items - as in the # In the order in which they are laid out on files
# manual, they're roughly in order of application. # Sorted by their action and their place in the build timeline
ordered_flags = [ flag_defaults = OrderedDict([
'disable', 'commit', 'subdir', 'submodules', 'init', ('disable', False),
'gradle', 'maven', 'kivy', 'output', 'oldsdkloc', 'target', ('commit', None),
'update', 'encoding', 'forceversion', 'forcevercode', 'rm', ('subdir', None),
'extlibs', 'srclibs', 'patch', 'prebuild', 'scanignore', ('submodules', False),
'scandelete', 'build', 'buildjni', 'preassemble', 'bindir', ('init', None),
'antcommand', 'novcheck' ('patch', []),
] ('gradle', False),
('maven', False),
('kivy', False),
('output', None),
('srclibs', []),
('oldsdkloc', False),
('encoding', None),
('forceversion', False),
('forcevercode', False),
('rm', []),
('extlibs', []),
('prebuild', []),
('update', ['auto']),
('target', None),
('scanignore', []),
('scandelete', []),
('build', []),
('buildjni', []),
('preassemble', []),
('antcommand', None),
('novcheck', False),
])
# Designates a metadata field type and checks that it matches # Designates a metadata field type and checks that it matches
@ -198,7 +222,7 @@ def check_metadata(info):
v.check(info[field], info['id']) v.check(info[field], info['id'])
for build in info['builds']: for build in info['builds']:
for attr in v.attrs: for attr in v.attrs:
if attr in build: if build[attr]:
v.check(build[attr], info['id']) v.check(build[attr], info['id'])
@ -496,7 +520,7 @@ def flagtype(name):
if name in ['init', 'prebuild', 'build']: if name in ['init', 'prebuild', 'build']:
return 'script' return 'script'
if name in ['submodules', 'oldsdkloc', 'forceversion', 'forcevercode', if name in ['submodules', 'oldsdkloc', 'forceversion', 'forcevercode',
'novcheck']: 'novcheck']:
return 'bool' return 'bool'
return 'string' return 'string'
@ -541,7 +565,7 @@ def parse_metadata(metafile):
.format(pk, thisbuild['version'], linedesc)) .format(pk, thisbuild['version'], linedesc))
pk = pk.lstrip() pk = pk.lstrip()
if pk not in ordered_flags: if pk not in flag_defaults:
raise MetaDataException("Unrecognised build flag at {0} in {1}" raise MetaDataException("Unrecognised build flag at {0} in {1}"
.format(p, linedesc)) .format(p, linedesc))
t = flagtype(pk) t = flagtype(pk)
@ -598,9 +622,9 @@ def parse_metadata(metafile):
def get_build_type(build): def get_build_type(build):
for t in ['maven', 'gradle', 'kivy']: for t in ['maven', 'gradle', 'kivy']:
if build.get(t, 'no') != 'no': if build[t]:
return t return t
if 'output' in build: if build['output']:
return 'raw' return 'raw'
return 'ant' return 'ant'
@ -626,16 +650,6 @@ def parse_metadata(metafile):
curcomments = [] curcomments = []
curbuild = None curbuild = None
def fill_bool_defaults(build):
# TODO: quick fix to make bool flags default to False
# Should provide defaults for all flags instead of using
# build.get(flagname, default) each time
for f in ordered_flags:
if f in build:
continue
if flagtype(f) == 'bool':
build[f] = False
c = 0 c = 0
for line in metafile: for line in metafile:
c += 1 c += 1
@ -647,7 +661,6 @@ def parse_metadata(metafile):
raise MetaDataException("No commit specified for {0} in {1}" raise MetaDataException("No commit specified for {0} in {1}"
.format(curbuild['version'], linedesc)) .format(curbuild['version'], linedesc))
fill_bool_defaults(curbuild)
thisinfo['builds'].append(curbuild) thisinfo['builds'].append(curbuild)
add_comments('build:' + curbuild['version']) add_comments('build:' + curbuild['version'])
mode = 0 mode = 0
@ -696,7 +709,7 @@ def parse_metadata(metafile):
mode = 2 mode = 2
buildlines = [value[:-1]] buildlines = [value[:-1]]
else: else:
thisinfo['builds'].append(parse_buildline([value])) curbuild = parse_buildline([value])
add_comments('build:' + thisinfo['builds'][-1]['version']) add_comments('build:' + thisinfo['builds'][-1]['version'])
elif fieldtype == 'buildv2': elif fieldtype == 'buildv2':
curbuild = {} curbuild = {}
@ -723,7 +736,6 @@ def parse_metadata(metafile):
else: else:
buildlines.append(line) buildlines.append(line)
curbuild = parse_buildline(buildlines) curbuild = parse_buildline(buildlines)
fill_bool_defaults(curbuild)
thisinfo['builds'].append(curbuild) thisinfo['builds'].append(curbuild)
add_comments('build:' + thisinfo['builds'][-1]['version']) add_comments('build:' + thisinfo['builds'][-1]['version'])
mode = 0 mode = 0
@ -741,6 +753,10 @@ def parse_metadata(metafile):
thisinfo['Description'].append('No description available') thisinfo['Description'].append('No description available')
for build in thisinfo['builds']: for build in thisinfo['builds']:
for flag, value in flag_defaults.iteritems():
if flag in build:
continue
build[flag] = value
build['type'] = get_build_type(build) build['type'] = get_build_type(build)
return thisinfo return thisinfo
@ -819,10 +835,11 @@ def write_metadata(dest, app):
if key in ['version', 'vercode', 'origlines', 'type']: if key in ['version', 'vercode', 'origlines', 'type']:
return return
t = flagtype(key) if value == flag_defaults[key]:
if t == 'bool' and value == False:
return return
t = flagtype(key)
logging.debug("...writing {0} : {1}".format(key, value)) logging.debug("...writing {0} : {1}".format(key, value))
outline = ' %s=' % key outline = ' %s=' % key
@ -838,9 +855,10 @@ def write_metadata(dest, app):
outline += '\n' outline += '\n'
mf.write(outline) mf.write(outline)
for key in ordered_flags: for flag in flag_defaults:
if key in build: value = build[flag]
write_builditem(key, build[key]) if value:
write_builditem(flag, value)
mf.write('\n') mf.write('\n')
if app['Maintainer Notes']: if app['Maintainer Notes']:

View File

@ -83,7 +83,7 @@ def main():
for thisbuild in app['builds']: for thisbuild in app['builds']:
if 'disable' in thisbuild: if thisbuild['disable']:
logging.info("...skipping version %s - %s" % ( logging.info("...skipping version %s - %s" % (
thisbuild['version'], thisbuild.get('disable', thisbuild['commit'][1:]))) thisbuild['version'], thisbuild.get('disable', thisbuild['commit'][1:])))
else: else:

View File

@ -126,7 +126,7 @@ def update_wiki(apps, apks):
apklist.append(apk) apklist.append(apk)
# Include ones we can't build, as a special case... # Include ones we can't build, as a special case...
for thisbuild in app['builds']: for thisbuild in app['builds']:
if 'disable' in thisbuild: if thisbuild['disable']:
if thisbuild['vercode'] == app['Current Version Code']: if thisbuild['vercode'] == app['Current Version Code']:
cantupdate = True cantupdate = True
# TODO: Nasty: vercode is a string in the build, and an int elsewhere # TODO: Nasty: vercode is a string in the build, and an int elsewhere
@ -272,7 +272,7 @@ def delete_disabled_builds(apps, apkcache, repodirs):
""" """
for app in apps: for app in apps:
for build in app['builds']: for build in app['builds']:
if 'disable' in build: if build['disable']:
apkfilename = app['id'] + '_' + str(build['vercode']) + '.apk' apkfilename = app['id'] + '_' + str(build['vercode']) + '.apk'
for repodir in repodirs: for repodir in repodirs:
apkpath = os.path.join(repodir, apkfilename) apkpath = os.path.join(repodir, apkfilename)