From e4ba6dbc3f1e76890b22773807ea37fe8fa2b1bc Mon Sep 17 00:00:00 2001 From: Daniel Baumann Date: Wed, 10 Apr 2024 22:34:10 +0200 Subject: Adding upstream version 4.2.2. Signed-off-by: Daniel Baumann --- packaging/nsis/windeployqt-to-nsis.py | 91 +++++++++++++++++++++++++++++++++++ 1 file changed, 91 insertions(+) create mode 100644 packaging/nsis/windeployqt-to-nsis.py (limited to 'packaging/nsis/windeployqt-to-nsis.py') diff --git a/packaging/nsis/windeployqt-to-nsis.py b/packaging/nsis/windeployqt-to-nsis.py new file mode 100644 index 00000000..2881f315 --- /dev/null +++ b/packaging/nsis/windeployqt-to-nsis.py @@ -0,0 +1,91 @@ +#!/bin/env python3 + +# windeployqt-to-nsh +# +# Windeployqt-to-nsh - Convert the output of windeployqt to an equivalent set of +# NSIS "File" function calls. +# +# Rewritten in python from windeployqt-to-nsis.ps1, that has the following copyright: +# +# Copyright 2014 Gerald Combs +# +# Wireshark - Network traffic analyzer +# By Gerald Combs +# Copyright 1998 Gerald Combs +# +# SPDX-License-Identifier: GPL-2.0-or-later + +import sys +import os +import argparse +import subprocess + +parser = argparse.ArgumentParser() +group = parser.add_mutually_exclusive_group(required=True) +group.add_argument('--mapping') +group.add_argument('--executable') +parser.add_argument('--sysroot') +parser.add_argument('outfile') +args = parser.parse_args() + +if args.mapping: + if not args.sysroot: + sys.exit('Option --sysroot is required with option --mapping') + qt_version = None + with open(args.mapping, 'r', encoding='utf-8') as f: + out = f.read() +else: + # Qt version + qmake_command = [ + 'qmake6.exe', + '-query', 'QT_VERSION' + ] + qmake_out = subprocess.run(qmake_command, check=True, capture_output=True, encoding="utf-8") + qt_version = qmake_out.stdout.strip() + + # XXX The powershell script asserts that the Qt version is greater than 5.3. We already require Qt6 to build the + # installer using MSYS2 (currently not enforced). + + # Windeployqt output + windeploy_command = [ + "windeployqt6.exe", + "--no-compiler-runtime", + "--no-translations", + "--list", "mapping", + args.executable + ] + out = subprocess.run(windeploy_command, check=True, capture_output=True, encoding="utf-8").stdout + +with open(args.outfile, 'w') as f: + header = """\ +# +# Automatically generated by {} +#""".format(parser.prog) + + if qt_version: + header += """\ +# Qt version {} +#""".format(qt_version) + + print(header, file=f) + + current_dir = "" + for line in out.splitlines(): + line = line.strip() + if not line or line.startswith('#'): + continue + path, relative = line.split(" ") + rel_path = os.path.split(relative) + if len(rel_path) > 1: + base_dir = rel_path[0].strip('"') + if base_dir != current_dir: + set_out_path = 'SetOutPath "$INSTDIR\{}"'.format(base_dir) + print(set_out_path, file=f) + current_dir = base_dir + + path = path.strip('"') + if args.sysroot: + path = os.path.join(args.sysroot, path) + file_path = 'File "{}"'.format(path) + print(file_path, file=f) + -- cgit v1.2.3