add keep_when_not_allowed config/option

This commit is contained in:
Hans-Christoph Steiner 2023-05-05 09:27:46 +02:00
parent 386fb55b99
commit 1e4e2489aa
No known key found for this signature in database
GPG key ID: 3E177817BA1B9BFA
3 changed files with 64 additions and 2 deletions

View file

@ -826,6 +826,15 @@ def force_halt_build(timeout):
vm.destroy()
def keep_when_not_allowed():
"""Control if APKs signed by keys not in AllowedAPKSigningKeys are removed."""
return (
(options is not None and options.keep_when_not_allowed)
or (config is not None and config.get('keep_when_not_allowed'))
or common.default_config['keep_when_not_allowed']
)
def parse_commandline():
"""Parse the command line.
@ -863,6 +872,8 @@ def parse_commandline():
help=_("Force build of disabled apps, and carries on regardless of scan problems. Only allowed in test mode."))
parser.add_argument("-a", "--all", action="store_true", default=False,
help=_("Build all applications available"))
parser.add_argument("--keep-when-not-allowed", default=False, action="store_true",
help=argparse.SUPPRESS)
parser.add_argument("-w", "--wiki", default=False, action="store_true",
help=argparse.SUPPRESS)
metadata.add_metadata_arguments(parser)
@ -1121,7 +1132,7 @@ def main():
logging.warn(_('AllowedAPKSigningKeys missing '
'but reference binary supplied'))
elif used_key not in expected_keys:
if options.test:
if options.test or keep_when_not_allowed():
logging.warning(_('Keeping failed build "{apkfilename}"')
.format(apkfilename=unsigned_apk))
else: