rename Build fields: version -> versionName, vercode -> versionCode

Since the YAML/JSON/etc. field names are now exactly the same as the field
names used in the internal dict in the Build class, this is a global rename

This keeps with the standard names used in Android:
https://developer.android.com/guide/topics/manifest/manifest-element.html
This commit is contained in:
Hans-Christoph Steiner 2016-11-23 17:52:04 +01:00
parent c0bc3afda9
commit e0f39a7e7b
13 changed files with 301 additions and 300 deletions

View file

@ -393,7 +393,7 @@ def build_server(app, build, vcs, build_dir, output_dir, force):
cmdline += ' --force --test'
if options.verbose:
cmdline += ' --verbose'
cmdline += " %s:%s" % (app.id, build.vercode)
cmdline += " %s:%s" % (app.id, build.versionCode)
chan.exec_command('bash --login -c "' + cmdline + '"')
output = bytes()
@ -413,7 +413,7 @@ def build_server(app, build, vcs, build_dir, output_dir, force):
if returncode != 0:
raise BuildException(
"Build.py failed on server for {0}:{1}".format(
app.id, build.version), str(output, 'utf-8'))
app.id, build.versionName), str(output, 'utf-8'))
# Retrieve the built files...
logging.info("Retrieving build output...")
@ -430,7 +430,7 @@ def build_server(app, build, vcs, build_dir, output_dir, force):
except:
raise BuildException(
"Build failed for %s:%s - missing output files".format(
app.id, build.version), output)
app.id, build.versionName), output)
ftp.close()
finally:
@ -499,8 +499,8 @@ def get_metadata_from_apk(app, build, apkfile):
if nativecode is None:
raise BuildException("Native code should have been built but none was packaged")
if build.novcheck:
vercode = build.vercode
version = build.version
vercode = build.versionCode
version = build.versionName
if not version or not vercode:
raise BuildException("Could not find version information in build in output")
if not foundid:
@ -589,7 +589,7 @@ def build_local(app, build, vcs, build_dir, output_dir, srclib_dir, extlib_dir,
if p is not None and p.returncode != 0:
raise BuildException("Error cleaning %s:%s" %
(app.id, build.version), p.output)
(app.id, build.versionName), p.output)
for root, dirs, files in os.walk(build_dir):
@ -658,7 +658,7 @@ def build_local(app, build, vcs, build_dir, output_dir, srclib_dir, extlib_dir,
if p.returncode != 0:
raise BuildException("Error running build command for %s:%s" %
(app.id, build.version), p.output)
(app.id, build.versionName), p.output)
# Build native stuff if required...
if build.buildjni and build.buildjni != ['no']:
@ -686,7 +686,7 @@ def build_local(app, build, vcs, build_dir, output_dir, srclib_dir, extlib_dir,
del manifest_text
p = FDroidPopen(cmd, cwd=os.path.join(root_dir, d))
if p.returncode != 0:
raise BuildException("NDK build failed for %s:%s" % (app.id, build.version), p.output)
raise BuildException("NDK build failed for %s:%s" % (app.id, build.versionName), p.output)
p = None
# Build the release...
@ -800,8 +800,8 @@ def build_local(app, build, vcs, build_dir, output_dir, srclib_dir, extlib_dir,
bindir = os.path.join(root_dir, 'bin')
if p is not None and p.returncode != 0:
raise BuildException("Build failed for %s:%s" % (app.id, build.version), p.output)
logging.info("Successfully built version " + build.version + ' of ' + app.id)
raise BuildException("Build failed for %s:%s" % (app.id, build.versionName), p.output)
logging.info("Successfully built version " + build.versionName + ' of ' + app.id)
omethod = build.output_method()
if omethod == 'maven':
@ -877,15 +877,15 @@ def build_local(app, build, vcs, build_dir, output_dir, srclib_dir, extlib_dir,
if common.get_file_extension(src) == 'apk':
vercode, version = get_metadata_from_apk(app, build, src)
if (version != build.version or vercode != build.vercode):
if (version != build.versionName or vercode != build.versionCode):
raise BuildException(("Unexpected version/version code in output;"
" APK: '%s' / '%s', "
" Expected: '%s' / '%s'")
% (version, str(vercode), build.version,
str(build.vercode)))
% (version, str(vercode), build.versionName,
str(build.versionCode)))
else:
vercode = build.vercode
version = build.version
vercode = build.versionCode
version = build.versionName
# Add information for 'fdroid verify' to be able to reproduce the build
# environment.
@ -948,7 +948,7 @@ def trybuild(app, build, build_dir, output_dir, also_check_dir, srclib_dir, extl
return False
logging.info("Building version %s (%s) of %s" % (
build.version, build.vercode, app.id))
build.versionName, build.versionCode, app.id))
if server:
# When using server mode, still keep a local cache of the repo, by
@ -1159,7 +1159,7 @@ def main():
vcs, build_dir = common.setup_vcs(app)
first = False
logging.debug("Checking " + build.version)
logging.debug("Checking " + build.versionName)
if trybuild(app, build, build_dir, output_dir,
also_check_dir, srclib_dir, extlib_dir,
tmp_dir, repo_dir, vcs, options.test,
@ -1173,10 +1173,10 @@ def main():
# alongside our built one in the 'unsigend'
# directory.
url = app.Binaries
url = url.replace('%v', build.version)
url = url.replace('%c', str(build.vercode))
url = url.replace('%v', build.versionName)
url = url.replace('%c', str(build.versionCode))
logging.info("...retrieving " + url)
of = "{0}_{1}.apk.binary".format(app.id, build.vercode)
of = "{0}_{1}.apk.binary".format(app.id, build.versionCode)
of = os.path.join(output_dir, of)
net.download_file(url, local_filename=of)
@ -1194,7 +1194,7 @@ def main():
with open(os.path.join(log_dir, appid + '.log'), 'a+') as f:
f.write('\n\n============================================================\n')
f.write('versionCode: %s\nversionName: %s\ncommit: %s\n' %
(build.vercode, build.version, build.commit))
(build.versionCode, build.versionName, build.commit))
f.write('Build completed at '
+ time.strftime("%Y-%m-%d %H:%M:%SZ", time.gmtime()) + '\n')
f.write('\n' + tools_version_log + '\n')
@ -1215,7 +1215,7 @@ def main():
if options.wiki and wikilog:
try:
# Write a page with the last build log for this version code
lastbuildpage = appid + '/lastbuild_' + build.vercode
lastbuildpage = appid + '/lastbuild_' + build.versionCode
newpage = site.Pages[lastbuildpage]
with open(os.path.join('tmp', 'fdroidserverid')) as fp:
fdroidserverid = fp.read().rstrip()

View file

@ -462,22 +462,22 @@ def checkupdates_app(app, first=True):
gotcur = False
latest = None
for build in app.builds:
if int(build.vercode) >= int(app.CurrentVersionCode):
if int(build.versionCode) >= int(app.CurrentVersionCode):
gotcur = True
if not latest or int(build.vercode) > int(latest.vercode):
if not latest or int(build.versionCode) > int(latest.versionCode):
latest = build
if int(latest.vercode) > int(app.CurrentVersionCode):
if int(latest.versionCode) > int(app.CurrentVersionCode):
logging.info("Refusing to auto update, since the latest build is newer")
if not gotcur:
newbuild = copy.deepcopy(latest)
newbuild.disable = False
newbuild.vercode = app.CurrentVersionCode
newbuild.version = app.CurrentVersion + suffix
logging.info("...auto-generating build for " + newbuild.version)
commit = pattern.replace('%v', newbuild.version)
commit = commit.replace('%c', newbuild.vercode)
newbuild.versionCode = app.CurrentVersionCode
newbuild.versionName = app.CurrentVersion + suffix
logging.info("...auto-generating build for " + newbuild.versionName)
commit = pattern.replace('%v', newbuild.versionName)
commit = commit.replace('%c', newbuild.versionCode)
newbuild.commit = commit
app.builds.append(newbuild)
name = common.getappname(app)

View file

@ -443,10 +443,10 @@ def read_app_args(args, allapps, allow_vercodes=False):
vc = vercodes[appid]
if not vc:
continue
app.builds = [b for b in app.builds if b.vercode in vc]
app.builds = [b for b in app.builds if b.versionCode in vc]
if len(app.builds) != len(vercodes[appid]):
error = True
allvcs = [b.vercode for b in app.builds]
allvcs = [b.versionCode for b in app.builds]
for v in vercodes[appid]:
if v not in allvcs:
logging.critical("No such vercode %s for app %s" % (v, appid))
@ -497,13 +497,13 @@ def publishednameinfo(filename):
def get_release_filename(app, build):
if build.output:
return "%s_%s.%s" % (app.id, build.vercode, get_file_extension(build.output))
return "%s_%s.%s" % (app.id, build.versionCode, get_file_extension(build.output))
else:
return "%s_%s.apk" % (app.id, build.vercode)
return "%s_%s.apk" % (app.id, build.versionCode)
def getsrcname(app, build):
return "%s_%s_src.tar.gz" % (app.id, build.vercode)
return "%s_%s_src.tar.gz" % (app.id, build.versionCode)
def getappname(app):
@ -1384,7 +1384,7 @@ def prepare_source(vcs, app, build, build_dir, srclib_dir, extlib_dir, onserver=
p = FDroidPopen(['bash', '-x', '-c', cmd], cwd=root_dir)
if p.returncode != 0:
raise BuildException("Error running init command for %s:%s" %
(app.id, build.version), p.output)
(app.id, build.versionName), p.output)
# Apply patches if any
if build.patch:
@ -1475,11 +1475,11 @@ def prepare_source(vcs, app, build, build_dir, srclib_dir, extlib_dir, onserver=
continue
if has_extension(path, 'xml'):
regsub_file(r'android:versionName="[^"]*"',
r'android:versionName="%s"' % build.version,
r'android:versionName="%s"' % build.versionName,
path)
elif has_extension(path, 'gradle'):
regsub_file(r"""(\s*)versionName[\s'"=]+.*""",
r"""\1versionName '%s'""" % build.version,
r"""\1versionName '%s'""" % build.versionName,
path)
if build.forcevercode:
@ -1489,11 +1489,11 @@ def prepare_source(vcs, app, build, build_dir, srclib_dir, extlib_dir, onserver=
continue
if has_extension(path, 'xml'):
regsub_file(r'android:versionCode="[^"]*"',
r'android:versionCode="%s"' % build.vercode,
r'android:versionCode="%s"' % build.versionCode,
path)
elif has_extension(path, 'gradle'):
regsub_file(r'versionCode[ =]+[0-9]+',
r'versionCode %s' % build.vercode,
r'versionCode %s' % build.versionCode,
path)
# Delete unwanted files
@ -1541,7 +1541,7 @@ def prepare_source(vcs, app, build, build_dir, srclib_dir, extlib_dir, onserver=
p = FDroidPopen(['bash', '-x', '-c', cmd], cwd=root_dir)
if p.returncode != 0:
raise BuildException("Error running prebuild command for %s:%s" %
(app.id, build.version), p.output)
(app.id, build.versionName), p.output)
# Generate (or update) the ant build file, build.xml...
if build.build_method() == 'ant' and build.androidupdate != ['no']:
@ -1918,8 +1918,8 @@ def replace_config_vars(cmd, build):
cmd = cmd.replace('$$QT$$', config['qt_sdk_path'] or '')
if build is not None:
cmd = cmd.replace('$$COMMIT$$', build.commit)
cmd = cmd.replace('$$VERSION$$', build.version)
cmd = cmd.replace('$$VERCODE$$', build.vercode)
cmd = cmd.replace('$$VERSION$$', build.versionName)
cmd = cmd.replace('$$VERCODE$$', build.versionCode)
return cmd

View file

@ -457,7 +457,7 @@ def main():
for build in reversed(app.builds):
if build.disable:
continue
if options.latest or vercode == 0 or build.vercode == vercode:
if options.latest or vercode == 0 or build.versionCode == vercode:
app.builds = [build]
break
continue
@ -467,7 +467,7 @@ def main():
for build in app.builds:
apks = []
for f in os.listdir(options.repo_path):
n = "%v_%v.apk".format(app_id, build.vercode)
n = "%v_%v.apk".format(app_id, build.versionCode)
if f == n:
apks.append(f)
for apk in sorted(apks):

View file

@ -230,13 +230,13 @@ def main():
paths = common.manifest_paths(root_dir, [])
if paths:
version, vercode, package = common.parse_androidmanifests(paths, app)
versionName, versionCode, package = common.parse_androidmanifests(paths, app)
if not package:
logging.error("Couldn't find package ID")
sys.exit(1)
if not version:
if not versionName:
logging.warn("Couldn't find latest version name")
if not vercode:
if not versionCode:
logging.warn("Couldn't find latest version code")
else:
spec = os.path.join(root_dir, 'buildozer.spec')
@ -246,8 +246,8 @@ def main():
bconfig = ConfigParser(defaults, allow_no_value=True)
bconfig.read(spec)
package = bconfig.get('app', 'package.domain') + '.' + bconfig.get('app', 'package.name')
version = bconfig.get('app', 'version')
vercode = None
versionName = bconfig.get('app', 'version')
versionCode = None
else:
logging.error("No android or kivy project could be found. Specify --subdir?")
sys.exit(1)
@ -258,8 +258,8 @@ def main():
sys.exit(1)
# Create a build line...
build.version = version or '?'
build.vercode = vercode or '?'
build.versionName = versionName or '?'
build.versionCode = versionCode or '?'
if options.subdir:
build.subdir = options.subdir
if os.path.exists(os.path.join(root_dir, 'jni')):

View file

@ -139,10 +139,10 @@ def get_lastbuild(builds):
lastbuild = None
for build in builds:
if not build.disable:
vercode = int(build.vercode)
vercode = int(build.versionCode)
if lowest_vercode == -1 or vercode < lowest_vercode:
lowest_vercode = vercode
if not lastbuild or int(build.vercode) > int(lastbuild.vercode):
if not lastbuild or int(build.versionCode) > int(lastbuild.versionCode):
lastbuild = build
return lastbuild
@ -153,7 +153,7 @@ def check_ucm_tags(app):
and lastbuild.commit
and app.UpdateCheckMode == 'RepoManifest'
and not lastbuild.commit.startswith('unknown')
and lastbuild.vercode == app.CurrentVersionCode
and lastbuild.versionCode == app.CurrentVersionCode
and not lastbuild.forcevercode
and any(s in lastbuild.commit for s in '.,_-/')):
yield "Last used commit '%s' looks like a tag, but Update Check Mode is '%s'" % (
@ -307,7 +307,7 @@ def check_builds(app):
continue
for s in ['master', 'origin', 'HEAD', 'default', 'trunk']:
if build.commit and build.commit.startswith(s):
yield "Branch '%s' used as commit in build '%s'" % (s, build.version)
yield "Branch '%s' used as commit in build '%s'" % (s, build.versionName)
for srclib in build.srclibs:
ref = srclib.split('@')[1].split('/')[0]
if ref.startswith(s):
@ -330,7 +330,7 @@ def check_files_dir(app):
for build in app.builds:
for fname in build.patch:
if fname not in files:
yield "Unknown file %s in build '%s'" % (fname, build.version)
yield "Unknown file %s in build '%s'" % (fname, build.versionName)
else:
used.add(fname)
@ -355,7 +355,7 @@ def check_extlib_dir(apps):
for build in app.builds:
for path in build.extlibs:
if path not in files:
yield "%s: Unknown extlib %s in build '%s'" % (app.id, path, build.version)
yield "%s: Unknown extlib %s in build '%s'" % (app.id, path, build.versionName)
else:
used.add(path)

View file

@ -238,7 +238,7 @@ build_flags_order = [
]
build_flags = set(build_flags_order + ['version', 'vercode'])
build_flags = set(build_flags_order + ['versionName', 'versionCode'])
class Build(dict):
@ -801,7 +801,7 @@ def get_default_app_info(metadatapath=None):
def sorted_builds(builds):
return sorted(builds, key=lambda build: int(build.vercode))
return sorted(builds, key=lambda build: int(build.versionCode))
esc_newlines = re.compile(r'\\( |\n)')
@ -978,9 +978,9 @@ def parse_txt_metadata(mf, app):
if len(parts) < 3:
warn_or_exception("Invalid build format: " + v + " in " + mf.name)
build = Build()
build.version = parts[0]
build.vercode = parts[1]
check_versionCode(build.vercode)
build.versionName = parts[0]
build.versionCode = parts[1]
check_versionCode(build.versionCode)
if parts[2].startswith('!'):
# For backwards compatibility, handle old-style disabling,
@ -1038,10 +1038,10 @@ def parse_txt_metadata(mf, app):
else:
if not build.commit and not build.disable:
warn_or_exception("No commit specified for {0} in {1}"
.format(build.version, linedesc))
.format(build.versionName, linedesc))
app.builds.append(build)
add_comments('build:' + build.vercode)
add_comments('build:' + build.versionCode)
mode = 0
if mode == 0:
@ -1086,21 +1086,22 @@ def parse_txt_metadata(mf, app):
else:
build = parse_buildline([v])
app.builds.append(build)
add_comments('build:' + app.builds[-1].vercode)
add_comments('build:' + app.builds[-1].versionCode)
elif ftype == TYPE_BUILD_V2:
vv = v.split(',')
if len(vv) != 2:
warn_or_exception('Build should have comma-separated',
'version and vercode,',
'versionName and versionCode,',
'not "{0}", in {1}'.format(v, linedesc))
build = Build()
build.version = vv[0]
build.vercode = vv[1]
check_versionCode(build.vercode)
if build.vercode in vc_seen:
warn_or_exception('Duplicate build recipe found for vercode %s in %s'
% (build.vercode, linedesc))
vc_seen.add(build.vercode)
build.versionName = vv[0]
build.versionCode = vv[1]
check_versionCode(build.versionCode)
if build.versionCode in vc_seen:
warn_or_exception('Duplicate build recipe found for versionCode %s in %s'
% (build.versionCode, linedesc))
vc_seen.add(build.versionCode)
del buildlines[:]
mode = 3
elif ftype == TYPE_OBSOLETE:
@ -1121,7 +1122,7 @@ def parse_txt_metadata(mf, app):
buildlines.append(line)
build = parse_buildline(buildlines)
app.builds.append(build)
add_comments('build:' + app.builds[-1].vercode)
add_comments('build:' + app.builds[-1].versionCode)
mode = 0
add_comments(None)
@ -1209,10 +1210,10 @@ def write_plaintext_metadata(mf, app, w_comment, w_field, w_build):
for build in app.builds:
if build.version == "Ignore":
if build.versionName == "Ignore":
continue
w_comments('build:%s' % build.vercode)
w_comments('build:%s' % build.versionCode)
w_build(build)
mf.write('\n')
@ -1254,7 +1255,7 @@ def write_txt(mf, app):
mf.write("%s:%s\n" % (f, v))
def w_build(build):
mf.write("Build:%s,%s\n" % (build.version, build.vercode))
mf.write("Build:%s,%s\n" % (build.versionName, build.versionCode))
for f in build_flags_order:
v = build.get(f)
@ -1337,8 +1338,8 @@ def write_yaml(mf, app):
mf.write("builds:\n")
first_build = False
w_field('versionName', build.version, ' - ', TYPE_STRING)
w_field('versionCode', build.vercode, ' ', TYPE_STRING)
w_field('versionName', build.versionName, ' - ', TYPE_STRING)
w_field('versionCode', build.versionCode, ' ', TYPE_STRING)
for f in build_flags_order:
v = build.get(f)
if not v:

View file

@ -296,9 +296,9 @@ def main():
if build.disable:
logging.info("...skipping version %s - %s" % (
build.version, build.get('disable', build.commit[1:])))
build.versionName, build.get('disable', build.commit[1:])))
else:
logging.info("...scanning version " + build.version)
logging.info("...scanning version " + build.versionName)
# Prepare the source code...
root_dir, _ = common.prepare_source(vcs, app, build,
@ -309,7 +309,7 @@ def main():
count = scan_source(build_dir, root_dir, build)
if count > 0:
logging.warn('Scanner found %d problems in %s (%s)' % (
count, appid, build.vercode))
count, appid, build.versionCode))
probcount += count
except BuildException as be:

View file

@ -156,24 +156,24 @@ def update_wiki(apps, sortedids, apks):
# Include ones we can't build, as a special case...
for build in app.builds:
if build.disable:
if build.vercode == app.CurrentVersionCode:
if build.versionCode == app.CurrentVersionCode:
cantupdate = True
# TODO: Nasty: vercode is a string in the build, and an int elsewhere
apklist.append({'versioncode': int(build.vercode),
'version': build.version,
apklist.append({'versioncode': int(build.versionCode),
'version': build.versionName,
'buildproblem': "The build for this version was manually disabled. Reason: {0}".format(build.disable),
})
else:
builtit = False
for apk in apklist:
if apk['versioncode'] == int(build.vercode):
if apk['versioncode'] == int(build.versionCode):
builtit = True
break
if not builtit:
buildfails = True
apklist.append({'versioncode': int(build.vercode),
'version': build.version,
'buildproblem': "The build for this version appears to have failed. Check the [[{0}/lastbuild_{1}|build log]].".format(appid, build.vercode),
apklist.append({'versioncode': int(build.versionCode),
'version': build.versionName,
'buildproblem': "The build for this version appears to have failed. Check the [[{0}/lastbuild_{1}|build log]].".format(appid, build.versionCode),
})
if app.CurrentVersionCode == '0':
cantupdate = True
@ -305,10 +305,10 @@ def delete_disabled_builds(apps, apkcache, repodirs):
for build in app['builds']:
if not build.disable:
continue
apkfilename = appid + '_' + str(build.vercode) + '.apk'
apkfilename = appid + '_' + str(build.versionCode) + '.apk'
iconfilename = "%s.%s.png" % (
appid,
build.vercode)
build.versionCode)
for repodir in repodirs:
files = [
os.path.join(repodir, apkfilename),