Add postbuild

This commit is contained in:
linsui 2023-02-16 12:11:26 +00:00 committed by Jochen Sprickerhof
parent 2ffb70168a
commit 33def096f5
7 changed files with 128 additions and 0 deletions

View file

@ -33,6 +33,7 @@ import argparse
from configparser import ConfigParser
import logging
from gettext import ngettext
from pathlib import Path
from . import _
from . import common
@ -790,6 +791,23 @@ def build_local(app, build, vcs, build_dir, output_dir, log_dir, srclib_dir, ext
raise BuildException('No apks match %s' % globpath)
src = os.path.normpath(apks[0])
# Run a postbuild command if one is required...
if build.postbuild:
logging.info(f"Running 'postbuild' commands in {root_dir}")
cmd = common.replace_config_vars("; ".join(build.postbuild), build)
# Substitute source library paths into commands...
for name, number, libpath in srclibpaths:
cmd = cmd.replace(f"$${name}$$", str(Path.cwd() / libpath))
cmd = cmd.replace('$$OUT$$', str(Path(src).resolve()))
p = FDroidPopen(['bash', '-e', '-u', '-o', 'pipefail', '-x', '-c', cmd], cwd=root_dir)
if p.returncode != 0:
raise BuildException("Error running postbuild command for "
f"{app.id}:{build.versionName}", p.output)
# Make sure it's not debuggable...
if common.is_apk_and_debuggable(src):
raise BuildException("APK is debuggable")

View file

@ -245,6 +245,7 @@ build_flags = [
'preassemble',
'gradleprops',
'antcommands',
'postbuild',
'novcheck',
'antifeatures',
]
@ -284,6 +285,7 @@ class Build(dict):
self.preassemble = []
self.gradleprops = []
self.antcommands = []
self.postbuild = ''
self.novcheck = False
self.antifeatures = []
if copydict:
@ -348,6 +350,7 @@ flagtypes = {
'init': TYPE_SCRIPT,
'prebuild': TYPE_SCRIPT,
'build': TYPE_SCRIPT,
'postbuild': TYPE_SCRIPT,
'submodules': TYPE_BOOL,
'oldsdkloc': TYPE_BOOL,
'forceversion': TYPE_BOOL,