Gitea CI / Check code and tests (push) Successful in 7m38s
Gitea CI / Build Android APK (push) Successful in 6m20s
Gitea CI / Audit and package Windows x64 (push) Canceled after 0s
Gitea CI / Assemble and validate CI artifacts (push) Canceled after 0s
Gitea CI / Gitea CI passed (push) Canceled after 0s
Gitea CI / Build Windows x64 app (push) Canceled after 14m42s
53 lines
2.4 KiB
Python
53 lines
2.4 KiB
Python
"""Stage an audited portable Windows x64 app from a normal Flutter Release build.
|
|
|
|
Requires pefile on the build host. Models remain separate from the application.
|
|
"""
|
|
import argparse
|
|
import json
|
|
from pathlib import Path
|
|
import shutil
|
|
import sys
|
|
|
|
sys.path.insert(0, str(Path(__file__).resolve().parents[1]))
|
|
from common.files import file_sha256
|
|
from common.process import cli
|
|
|
|
from check_windows_release import audit
|
|
|
|
|
|
def main():
|
|
parser = argparse.ArgumentParser(description=__doc__)
|
|
parser.add_argument('--app', type=Path, required=True)
|
|
parser.add_argument('--processing', type=Path, required=True)
|
|
parser.add_argument('--output', type=Path, required=True)
|
|
args = parser.parse_args()
|
|
source, runtime, output = [p.resolve() for p in (args.app, args.processing, args.output)]
|
|
if output.exists() or output.is_relative_to(source) or output.is_relative_to(runtime):
|
|
raise ValueError('Output must be a new directory outside the source packages')
|
|
if not (source / 'cutdex.exe').is_file() or not (runtime / 'checksums.json').is_file():
|
|
raise ValueError('Provide a complete Release directory and processing package')
|
|
checksums = json.loads((runtime / 'checksums.json').read_text(encoding='utf-8-sig'))
|
|
for name, expected in checksums.items():
|
|
path = (runtime / name).resolve()
|
|
if not path.is_relative_to(runtime):
|
|
raise ValueError(f'Invalid processing manifest path: {name}')
|
|
actual = file_sha256(path)
|
|
if actual.lower() != expected.lower():
|
|
raise ValueError(f'Processing checksum mismatch: {name}')
|
|
# Older Flutter builds can retain the unused JNI plugin from Android's
|
|
# path_provider dependency. Windows has its own provider and needs no JVM.
|
|
shutil.copytree(source, output, ignore=shutil.ignore_patterns('processing', '*.pdb', '*.lib', '*.exp', 'dartjni.dll'))
|
|
shutil.copytree(runtime, output / 'processing')
|
|
result = audit(output)
|
|
(output / 'dependency-audit.json').write_text(json.dumps(result, indent=2) + '\n', encoding='utf-8')
|
|
manifest = {}
|
|
for path in sorted(output.rglob('*')):
|
|
if path.is_file():
|
|
manifest[path.relative_to(output).as_posix()] = file_sha256(path)
|
|
(output / 'checksums.json').write_text(json.dumps(manifest, indent=2) + '\n', encoding='utf-8')
|
|
print(f'Portable package staged: {output} ({len(manifest)} files)')
|
|
|
|
|
|
if __name__ == '__main__':
|
|
sys.exit(cli(main))
|