ci: resolve missing Windows ARM64 runtime DLLs and add pipeline inputs

The Windows ARM64 release package failed to launch on startup due to missing
runtime DLLs (libdbus-1-3.dll, libmd4c.dll, zlib1.dll, libzstd.dll).

This failure stemmed from several architectural and CI pipeline issues:
1. CMake unconditionally linked Qt6::DBus whenever available in the sysroot,
   introducing an unnecessary dependency on Qt6DBus.dll and libdbus-1-3.dll
   on Windows, even though D-Bus portal dialogs are only used on Linux.
2. The Docker build environment installed MSYS2 ARM64 Qt packages via an
   unchecked shell loop against a hardcoded package list. This missed crucial
   transitive runtime dependencies (such as md4c, zlib-ng-compat, libb2, and
   ICU) and failed silently when downloads or extractions broke.
3. Windows packaging lacked PE import verification, allowing broken packages
   with unresolved dynamic links to be produced and published without warning.

To fix these issues and make image management more accessible:
- Restrict Qt6::DBus detection and linking in CMakeLists.txt to Linux only,
  eliminating the D-Bus dependency from Windows builds.
- Introduce scripts/download-mingw-arm64-qt.py to parse the MSYS2 clangarm64
  database, resolve the complete transitive dependency graph, and verify
  essential runtime DLLs during the Docker image build.
- Introduce scripts/verify-windows-dlls.py and integrate it into
  packaging/package-windows.sh to validate PE imports across the executable
  and bundled Qt plugins, failing packaging if any non-system DLL is missing.
- Expose FORCE_REBUILD_IMAGE as a typed GitLab CI pipeline input (spec: inputs)
  to provide an interactive dropdown when triggering manual pipelines in the UI,
  and trigger container rebuilds when the download script changes.
- Update AGENTS.md documentation to reflect the new dependency and packaging
  verification workflows.
This commit is contained in:
Agel committed 2026-11-13 08:37:05 +01:00
1 parent 154880f4e4
commit 5940d86ed2
7 files changed
+467 -32

No files matched your search

+214
View File
@@ -0,0 +1,214 @@
#!/usr/bin/env python3
"""
Verifies that all PE DLL dependencies of an executable and its bundled plugins
are satisfied within the target distribution directory.
Usage:
verify-windows-dlls.py /path/to/dist_dir
"""
import os
import struct
import sys
# Standard Windows system and runtime libraries (case-insensitive)
SYSTEM_DLLS = {
# Core OS & NT subsystems
"ntdll.dll",
"kernel32.dll",
"kernelbase.dll",
"user32.dll",
"gdi32.dll",
"gdiplus.dll",
"shell32.dll",
"shlwapi.dll",
"ole32.dll",
"oleaut32.dll",
"comdlg32.dll",
"comctl32.dll",
"advapi32.dll",
"version.dll",
"ws2_32.dll",
"wsock32.dll",
"netapi32.dll",
"userenv.dll",
"winmm.dll",
"uxtheme.dll",
"dwmapi.dll",
"imm32.dll",
"crypt32.dll",
"bcrypt.dll",
"ncrypt.dll",
"secur32.dll",
"sspicli.dll",
"setupapi.dll",
"cfgmgr32.dll",
"iphlpapi.dll",
"dnsapi.dll",
"rpcrt4.dll",
"mpr.dll",
"authz.dll",
"wtsapi32.dll",
"propsys.dll",
"powrprof.dll",
"winspool.drv",
"shcore.dll",
"hid.dll",
# Graphics & DirectX
"d3d9.dll",
"d3d11.dll",
"d3d12.dll",
"dxgi.dll",
"d2d1.dll",
"dwrite.dll",
"opengl32.dll",
"glu32.dll",
# CRT / UCRT
"msvcrt.dll",
"ucrtbase.dll",
}
def is_system_dll(name):
lower = name.lower()
if lower in SYSTEM_DLLS:
return True
if lower.startswith("api-ms-win-") or lower.startswith("ext-ms-win-"):
return True
return False
def get_pe_imports(file_path):
try:
with open(file_path, "rb") as f:
data = f.read()
except Exception as e:
print(f"Warning: could not read {file_path}: {e}", file=sys.stderr)
return []
if len(data) < 0x40 or data[:2] != b"MZ":
return []
pe_offset = struct.unpack_from("<I", data, 0x3c)[0]
if pe_offset + 24 > len(data) or data[pe_offset:pe_offset+4] != b"PE\x00\x00":
return []
magic = struct.unpack_from("<H", data, pe_offset + 24)[0]
if magic == 0x20b: # PE32+ (64-bit)
import_rva_offset = pe_offset + 24 + 120
elif magic == 0x10b: # PE32 (32-bit)
import_rva_offset = pe_offset + 24 + 104
else:
return []
if import_rva_offset + 8 > len(data):
return []
import_rva, import_size = struct.unpack_from("<II", data, import_rva_offset)
if import_rva == 0 or import_size == 0:
return []
num_sections = struct.unpack_from("<H", data, pe_offset + 6)[0]
size_of_opt_header = struct.unpack_from("<H", data, pe_offset + 20)[0]
sec_offset = pe_offset + 24 + size_of_opt_header
sections = []
for i in range(num_sections):
sec = data[sec_offset + i * 40 : sec_offset + (i + 1) * 40]
if len(sec) < 40:
break
vsize, vrva, rsize, roffset = struct.unpack_from("<IIII", sec, 8)
sections.append((vrva, vsize, roffset, rsize))
def rva_to_off(rva):
for vrva, vsize, roffset, rsize in sections:
if vrva <= rva < vrva + max(vsize, rsize):
return roffset + (rva - vrva)
return None
import_off = rva_to_off(import_rva)
if not import_off:
return []
imports = []
while import_off + 20 <= len(data):
desc = data[import_off : import_off + 20]
if desc == b"\x00" * 20:
break
name_rva = struct.unpack_from("<I", desc, 12)[0]
name_off = rva_to_off(name_rva)
if name_off and name_off < len(data):
name = data[name_off:].split(b"\x00", 1)[0].decode("latin1", errors="ignore")
if name:
imports.append(name)
import_off += 20
return imports
def verify_dist_directory(dist_dir):
if not os.path.isdir(dist_dir):
print(f"Error: directory does not exist: {dist_dir}", file=sys.stderr)
return False
# Collect all available DLLs in the dist directory (case-insensitive)
available_dlls = {}
binaries = []
for root, _, files in os.walk(dist_dir):
for f in files:
lower = f.lower()
rel_path = os.path.relpath(os.path.join(root, f), dist_dir)
if lower.endswith(".dll"):
available_dlls[lower] = rel_path
binaries.append(os.path.join(root, f))
elif lower.endswith(".exe"):
binaries.append(os.path.join(root, f))
if not binaries:
print(f"Error: no .exe or .dll binaries found in {dist_dir}", file=sys.stderr)
return False
missing_deps = []
checked_count = len(binaries)
for bin_path in binaries:
rel_bin = os.path.relpath(bin_path, dist_dir)
imports = get_pe_imports(bin_path)
for imp in imports:
if is_system_dll(imp):
continue
if imp.lower() not in available_dlls:
missing_deps.append((rel_bin, imp))
if missing_deps:
print(f"FAILED: Found {len(missing_deps)} missing DLL dependencies in {dist_dir}:", file=sys.stderr)
# Deduplicate and group by missing DLL
missing_by_dll = {}
for rel_bin, imp in missing_deps:
missing_by_dll.setdefault(imp, []).append(rel_bin)
for imp, users in sorted(missing_by_dll.items()):
print(f" [MISSING] {imp} needed by:", file=sys.stderr)
for u in users[:5]:
print(f" - {u}", file=sys.stderr)
if len(users) > 5:
print(f" ... and {len(users) - 5} more", file=sys.stderr)
return False
print(f"OK: Verified {checked_count} binaries. All external DLL imports satisfied ({len(available_dlls)} DLLs bundled).")
return True
def main():
if len(sys.argv) < 2:
print("Usage: verify-windows-dlls.py <dist-dir>", file=sys.stderr)
sys.exit(2)
dist_dir = sys.argv[1]
if not verify_dist_directory(dist_dir):
sys.exit(1)
if __name__ == "__main__":
main()