mirror of
https://github.com/f-droid/fdroidserver.git
synced 2025-11-04 22:40:29 +03:00
publish: write status JSON
This commit is contained in:
parent
e8a6d0f813
commit
4bb590b6e5
2 changed files with 30 additions and 1 deletions
|
|
@ -28,6 +28,7 @@ from collections import OrderedDict
|
||||||
import logging
|
import logging
|
||||||
from gettext import ngettext
|
from gettext import ngettext
|
||||||
import json
|
import json
|
||||||
|
import time
|
||||||
import zipfile
|
import zipfile
|
||||||
|
|
||||||
from . import _
|
from . import _
|
||||||
|
|
@ -38,6 +39,7 @@ from .exception import BuildException, FDroidException
|
||||||
|
|
||||||
config = None
|
config = None
|
||||||
options = None
|
options = None
|
||||||
|
start_timestamp = time.gmtime()
|
||||||
|
|
||||||
|
|
||||||
def publish_source_tarball(apkfilename, unsigned_dir, output_dir):
|
def publish_source_tarball(apkfilename, unsigned_dir, output_dir):
|
||||||
|
|
@ -138,6 +140,20 @@ def store_stats_fdroid_signing_key_fingerprints(appids, indent=None):
|
||||||
sign_sig_key_fingerprint_list(jar_file)
|
sign_sig_key_fingerprint_list(jar_file)
|
||||||
|
|
||||||
|
|
||||||
|
def status_update_json(newKeyAliases, generatedKeys, signedApks):
|
||||||
|
"""Output a JSON file with metadata about this run"""
|
||||||
|
|
||||||
|
logging.debug(_('Outputting JSON'))
|
||||||
|
output = common.setup_status_output(start_timestamp)
|
||||||
|
if newKeyAliases:
|
||||||
|
output['newKeyAliases'] = newKeyAliases
|
||||||
|
if generatedKeys:
|
||||||
|
output['generatedKeys'] = generatedKeys
|
||||||
|
if signedApks:
|
||||||
|
output['signedApks'] = signedApks
|
||||||
|
common.write_status_json(output)
|
||||||
|
|
||||||
|
|
||||||
def main():
|
def main():
|
||||||
|
|
||||||
global config, options
|
global config, options
|
||||||
|
|
@ -195,6 +211,9 @@ def main():
|
||||||
# collisions, and refuse to do any publishing if that's the case...
|
# collisions, and refuse to do any publishing if that's the case...
|
||||||
allapps = metadata.read_metadata()
|
allapps = metadata.read_metadata()
|
||||||
vercodes = common.read_pkg_args(options.appid, True)
|
vercodes = common.read_pkg_args(options.appid, True)
|
||||||
|
signed_apks = dict()
|
||||||
|
new_key_aliases = []
|
||||||
|
generated_keys = dict()
|
||||||
allaliases = []
|
allaliases = []
|
||||||
for appid in allapps:
|
for appid in allapps:
|
||||||
m = hashlib.md5() # nosec just used to generate a keyalias
|
m = hashlib.md5() # nosec just used to generate a keyalias
|
||||||
|
|
@ -314,6 +333,7 @@ def main():
|
||||||
m = hashlib.md5() # nosec just used to generate a keyalias
|
m = hashlib.md5() # nosec just used to generate a keyalias
|
||||||
m.update(appid.encode('utf-8'))
|
m.update(appid.encode('utf-8'))
|
||||||
keyalias = m.hexdigest()[:8]
|
keyalias = m.hexdigest()[:8]
|
||||||
|
new_key_aliases.append(keyalias)
|
||||||
logging.info("Key alias: " + keyalias)
|
logging.info("Key alias: " + keyalias)
|
||||||
|
|
||||||
# See if we already have a key for this application, and
|
# See if we already have a key for this application, and
|
||||||
|
|
@ -336,6 +356,9 @@ def main():
|
||||||
'-dname', config['keydname']], envs=env_vars)
|
'-dname', config['keydname']], envs=env_vars)
|
||||||
if p.returncode != 0:
|
if p.returncode != 0:
|
||||||
raise BuildException("Failed to generate key", p.output)
|
raise BuildException("Failed to generate key", p.output)
|
||||||
|
if appid not in generated_keys:
|
||||||
|
generated_keys[appid] = set()
|
||||||
|
generated_keys[appid].add(appid)
|
||||||
|
|
||||||
signed_apk_path = os.path.join(output_dir, apkfilename)
|
signed_apk_path = os.path.join(output_dir, apkfilename)
|
||||||
if os.path.exists(signed_apk_path):
|
if os.path.exists(signed_apk_path):
|
||||||
|
|
@ -353,6 +376,9 @@ def main():
|
||||||
apkfile, keyalias], envs=env_vars)
|
apkfile, keyalias], envs=env_vars)
|
||||||
if p.returncode != 0:
|
if p.returncode != 0:
|
||||||
raise BuildException(_("Failed to sign application"), p.output)
|
raise BuildException(_("Failed to sign application"), p.output)
|
||||||
|
if appid not in signed_apks:
|
||||||
|
signed_apks[appid] = []
|
||||||
|
signed_apks[appid].append(apkfile)
|
||||||
|
|
||||||
# Zipalign it...
|
# Zipalign it...
|
||||||
common._zipalign(apkfile, os.path.join(output_dir, apkfilename))
|
common._zipalign(apkfile, os.path.join(output_dir, apkfilename))
|
||||||
|
|
@ -362,6 +388,7 @@ def main():
|
||||||
logging.info('Published ' + apkfilename)
|
logging.info('Published ' + apkfilename)
|
||||||
|
|
||||||
store_stats_fdroid_signing_key_fingerprints(allapps.keys())
|
store_stats_fdroid_signing_key_fingerprints(allapps.keys())
|
||||||
|
status_update_json(new_key_aliases, generated_keys, signed_apks)
|
||||||
logging.info('published list signing-key fingerprints')
|
logging.info('published list signing-key fingerprints')
|
||||||
|
|
||||||
|
|
||||||
|
|
|
||||||
|
|
@ -19,6 +19,7 @@ import sys
|
||||||
import unittest
|
import unittest
|
||||||
import tempfile
|
import tempfile
|
||||||
import textwrap
|
import textwrap
|
||||||
|
from unittest import mock
|
||||||
|
|
||||||
localmodule = os.path.realpath(
|
localmodule = os.path.realpath(
|
||||||
os.path.join(os.path.dirname(inspect.getfile(inspect.currentframe())), '..'))
|
os.path.join(os.path.dirname(inspect.getfile(inspect.currentframe())), '..'))
|
||||||
|
|
@ -158,7 +159,8 @@ class PublishTest(unittest.TestCase):
|
||||||
os.path.join(testdir, 'unsigned', 'binaries', 'com.politedroid_6.binary.apk'))
|
os.path.join(testdir, 'unsigned', 'binaries', 'com.politedroid_6.binary.apk'))
|
||||||
|
|
||||||
os.chdir(testdir)
|
os.chdir(testdir)
|
||||||
publish.main()
|
with mock.patch.object(sys, 'argv', ['fdroid fakesubcommand']):
|
||||||
|
publish.main()
|
||||||
|
|
||||||
|
|
||||||
if __name__ == "__main__":
|
if __name__ == "__main__":
|
||||||
|
|
|
||||||
Loading…
Add table
Add a link
Reference in a new issue