From: Hans-Christoph Steiner Date: Thu, 30 Nov 2017 20:12:34 +0000 (+0100) Subject: nightly: resign APKs with provided debug.keystore X-Git-Tag: 1.0.0~46^2~3 X-Git-Url: http://www.chiark.greenend.org.uk/ucgi/~ianmdlvl/git?a=commitdiff_plain;h=8a61b0b94553fc26010807bf94664b81617ea55f;p=fdroidserver.git nightly: resign APKs with provided debug.keystore Rather than needing to run a command before and after the build, in order to first install the debug.keystore, then after to fetch and publish the APK, this makes `fdroid nightly` just resign the APK with the provided debug.keystore. Then `fdroid nightly` can be run as the final step in a CI build, and still ensure that the APKs are always signed by the provided debug.keystore. --- diff --git a/fdroidserver/nightly.py b/fdroidserver/nightly.py index 454616e4..20c55e96 100644 --- a/fdroidserver/nightly.py +++ b/fdroidserver/nightly.py @@ -235,6 +235,8 @@ Last updated: {date}'''.format(repo_git_base=repo_git_base, with open('config.py', 'w') as fp: fp.write(config) os.chmod('config.py', 0o600) + config = common.read_config(options) + common.assert_config_keystore(config) for root, dirs, files in os.walk(cibase): for d in ('fdroid', '.git', '.gradle'): @@ -243,12 +245,14 @@ Last updated: {date}'''.format(repo_git_base=repo_git_base, for f in files: if f.endswith('-debug.apk'): apkfilename = os.path.join(root, f) - logging.debug(_('copying {apkfilename} into {path}') - .format(apkfilename=apkfilename, path=repodir)) + logging.debug(_('Striping mystery signature from {apkfilename}') + .format(apkfilename=apkfilename)) destapk = os.path.join(repodir, os.path.basename(f)) - shutil.copyfile(apkfilename, destapk) - shutil.copystat(apkfilename, destapk) - os.chmod(destapk, 0o644) + os.chmod(apkfilename, 0o644) + logging.debug(_('Resigning {apkfilename} with provided debug.keystore') + .format(apkfilename=os.path.basename(apkfilename))) + common.apk_strip_signatures(apkfilename, strip_manifest=True) + common.sign_apk(apkfilename, destapk, KEY_ALIAS) if options.verbose: logging.debug(_('attempting bare ssh connection to test deploy key:'))