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:
7 files changed
+467
-32
No files matched your search
+14
-9
@@ -1,15 +1,27 @@
|
|||||||
|
spec:
|
||||||
|
inputs:
|
||||||
|
FORCE_REBUILD_IMAGE:
|
||||||
|
description: "Force (true) or skip (false) building the runner image, even if files changed"
|
||||||
|
type: string
|
||||||
|
options:
|
||||||
|
- "auto"
|
||||||
|
- "true"
|
||||||
|
- "false"
|
||||||
|
default: "auto"
|
||||||
|
---
|
||||||
workflow:
|
workflow:
|
||||||
auto_cancel:
|
auto_cancel:
|
||||||
on_new_commit: interruptible
|
on_new_commit: interruptible
|
||||||
rules:
|
rules:
|
||||||
- if: $FORCE_REBUILD_IMAGE == "true"
|
- if: '"$[[ inputs.FORCE_REBUILD_IMAGE ]]" == "true" || $FORCE_REBUILD_IMAGE == "true"'
|
||||||
variables:
|
variables:
|
||||||
CI_PIPELINE_TYPE: image-rebuild
|
CI_PIPELINE_TYPE: image-rebuild
|
||||||
- if: $FORCE_REBUILD_IMAGE == "false"
|
- if: '"$[[ inputs.FORCE_REBUILD_IMAGE ]]" == "false" || $FORCE_REBUILD_IMAGE == "false"'
|
||||||
variables:
|
variables:
|
||||||
CI_PIPELINE_TYPE: normal
|
CI_PIPELINE_TYPE: normal
|
||||||
- changes:
|
- changes:
|
||||||
- docker/Dockerfile.build
|
- docker/Dockerfile.build
|
||||||
|
- scripts/download-mingw-arm64-qt.py
|
||||||
- scripts/install-deps-ubuntu.sh
|
- scripts/install-deps-ubuntu.sh
|
||||||
- scripts/mingw-w64-toolchain.cmake
|
- scripts/mingw-w64-toolchain.cmake
|
||||||
- scripts/mingw-w64-arm64-toolchain.cmake
|
- scripts/mingw-w64-arm64-toolchain.cmake
|
||||||
@@ -26,13 +38,6 @@ stages:
|
|||||||
|
|
||||||
variables:
|
variables:
|
||||||
GIT_CLEAN_FLAGS: -fdx
|
GIT_CLEAN_FLAGS: -fdx
|
||||||
FORCE_REBUILD_IMAGE:
|
|
||||||
value: "auto"
|
|
||||||
options:
|
|
||||||
- "auto"
|
|
||||||
- "true"
|
|
||||||
- "false"
|
|
||||||
description: "Force (true) or skip (false) building the runner image, even if files changed"
|
|
||||||
|
|
||||||
# ── Build the runner image and push to registry ────────────────────────────────
|
# ── Build the runner image and push to registry ────────────────────────────────
|
||||||
build-docker:
|
build-docker:
|
||||||
|
|||||||
@@ -70,7 +70,7 @@ PATH="/c/msys64/opt/qt/6.10.3/mingw_64/bin:/c/msys64/mingw64/bin:$PATH" "C:/msys
|
|||||||
```
|
```
|
||||||
|
|
||||||
### Windows ARM64 Cross-Compilation Environment (Linux host / CI)
|
### Windows ARM64 Cross-Compilation Environment (Linux host / CI)
|
||||||
Cross-compiled using `llvm-mingw` (`aarch64-w64-mingw32`) and MSYS2 `clangarm64` Qt 6 / sysroot packages:
|
Cross-compiled using `llvm-mingw` (`aarch64-w64-mingw32`) and MSYS2 `clangarm64` Qt 6 / sysroot packages (transitive runtime dependencies resolved automatically via `scripts/download-mingw-arm64-qt.py`):
|
||||||
```bash
|
```bash
|
||||||
PKG_CONFIG_PATH="/opt/mingw-arm64-sysroot/lib/pkgconfig" cmake -B build-windows-arm64 -G Ninja \
|
PKG_CONFIG_PATH="/opt/mingw-arm64-sysroot/lib/pkgconfig" cmake -B build-windows-arm64 -G Ninja \
|
||||||
-DCMAKE_BUILD_TYPE=Release \
|
-DCMAKE_BUILD_TYPE=Release \
|
||||||
@@ -80,7 +80,7 @@ PKG_CONFIG_PATH="/opt/mingw-arm64-sysroot/lib/pkgconfig" cmake -B build-windows-
|
|||||||
-DQT_HOST_PATH="/opt/qt/6.10.3/gcc_64"
|
-DQT_HOST_PATH="/opt/qt/6.10.3/gcc_64"
|
||||||
cmake --build build-windows-arm64 --target asteria-qt
|
cmake --build build-windows-arm64 --target asteria-qt
|
||||||
```
|
```
|
||||||
Packaging:
|
Packaging (includes automated PE binary DLL dependency verification via `scripts/verify-windows-dlls.py`):
|
||||||
```bash
|
```bash
|
||||||
packaging/package-windows.sh build-windows-arm64 /opt/qt/6.10.3/mingw_arm64 /opt/mingw-arm64-sysroot dist arm64
|
packaging/package-windows.sh build-windows-arm64 /opt/qt/6.10.3/mingw_arm64 /opt/mingw-arm64-sysroot dist arm64
|
||||||
```
|
```
|
||||||
|
|||||||
+4
-2
@@ -19,7 +19,9 @@ find_package(Qt6 6.8 REQUIRED COMPONENTS
|
|||||||
Network
|
Network
|
||||||
)
|
)
|
||||||
qt_standard_project_setup(REQUIRES 6.8)
|
qt_standard_project_setup(REQUIRES 6.8)
|
||||||
find_package(Qt6 OPTIONAL_COMPONENTS DBus)
|
if(UNIX AND NOT APPLE)
|
||||||
|
find_package(Qt6 OPTIONAL_COMPONENTS DBus)
|
||||||
|
endif()
|
||||||
|
|
||||||
# Third-party libraries
|
# Third-party libraries
|
||||||
find_package(PkgConfig REQUIRED)
|
find_package(PkgConfig REQUIRED)
|
||||||
@@ -180,7 +182,7 @@ target_link_libraries(asteria-qt PRIVATE
|
|||||||
${UCHARDET_LIB}
|
${UCHARDET_LIB}
|
||||||
)
|
)
|
||||||
|
|
||||||
if(Qt6DBus_FOUND)
|
if(UNIX AND NOT APPLE AND Qt6DBus_FOUND)
|
||||||
target_link_libraries(asteria-qt PRIVATE Qt6::DBus)
|
target_link_libraries(asteria-qt PRIVATE Qt6::DBus)
|
||||||
target_compile_definitions(asteria-qt PRIVATE HAS_QT_DBUS)
|
target_compile_definitions(asteria-qt PRIVATE HAS_QT_DBUS)
|
||||||
target_sources(asteria-qt PRIVATE
|
target_sources(asteria-qt PRIVATE
|
||||||
|
|||||||
+4
-18
@@ -49,24 +49,10 @@ RUN wget -q https://github.com/mstorsjo/llvm-mingw/releases/download/${LLVM_MING
|
|||||||
ENV PATH="${PATH}:/opt/llvm-mingw/bin"
|
ENV PATH="${PATH}:/opt/llvm-mingw/bin"
|
||||||
|
|
||||||
# ── Qt 6 for Windows ARM64 (MinGW cross-compile target) ────────────────────────
|
# ── Qt 6 for Windows ARM64 (MinGW cross-compile target) ────────────────────────
|
||||||
RUN mkdir -p ${QT_INSTALL_DIR}/${QT_VERSION}/mingw_arm64 && \
|
COPY scripts/download-mingw-arm64-qt.py /tmp/download-mingw-arm64-qt.py
|
||||||
for pkg in \
|
RUN chmod +x /tmp/download-mingw-arm64-qt.py && \
|
||||||
mingw-w64-clang-aarch64-qt6-base \
|
python3 /tmp/download-mingw-arm64-qt.py --dest "${QT_INSTALL_DIR}/${QT_VERSION}/mingw_arm64" && \
|
||||||
mingw-w64-clang-aarch64-qt6-declarative \
|
rm /tmp/download-mingw-arm64-qt.py
|
||||||
mingw-w64-clang-aarch64-qt6-svg \
|
|
||||||
mingw-w64-clang-aarch64-qt6-5compat \
|
|
||||||
mingw-w64-clang-aarch64-pcre2 \
|
|
||||||
mingw-w64-clang-aarch64-double-conversion \
|
|
||||||
mingw-w64-clang-aarch64-zstd \
|
|
||||||
mingw-w64-clang-aarch64-brotli \
|
|
||||||
mingw-w64-clang-aarch64-harfbuzz \
|
|
||||||
mingw-w64-clang-aarch64-freetype \
|
|
||||||
mingw-w64-clang-aarch64-libpng; do \
|
|
||||||
file=$(curl -sL https://mirror.msys2.org/mingw/clangarm64/ | grep -o "${pkg}-[0-9][^\"]*pkg\.tar\.zst" | head -n 1) && \
|
|
||||||
wget -q "https://mirror.msys2.org/mingw/clangarm64/${file}" -O /tmp/pkg.tar.zst && \
|
|
||||||
tar -I zstd -xf /tmp/pkg.tar.zst --strip-components=1 -C "${QT_INSTALL_DIR}/${QT_VERSION}/mingw_arm64" && \
|
|
||||||
rm /tmp/pkg.tar.zst; \
|
|
||||||
done
|
|
||||||
|
|
||||||
# ── Toolchain files ────────────────────────────────────────────────────────────
|
# ── Toolchain files ────────────────────────────────────────────────────────────
|
||||||
COPY scripts/mingw-w64-toolchain.cmake /opt/mingw-w64-toolchain.cmake
|
COPY scripts/mingw-w64-toolchain.cmake /opt/mingw-w64-toolchain.cmake
|
||||||
|
|||||||
Regular → Executable
+7
-1
@@ -72,7 +72,9 @@ if [ "$ARCH" = "arm64" ] || [ "$ARCH" = "aarch64" ]; then
|
|||||||
libwinpthread-1.dll
|
libwinpthread-1.dll
|
||||||
)
|
)
|
||||||
for dll in "${ARM64_DLLS[@]}"; do
|
for dll in "${ARM64_DLLS[@]}"; do
|
||||||
find /opt/llvm-mingw/aarch64-w64-mingw32/ -name "$dll" -exec cp {} "$DIST_DIR/" \; 2>/dev/null || true
|
if [ ! -f "$DIST_DIR/$dll" ]; then
|
||||||
|
find /opt/llvm-mingw/aarch64-w64-mingw32/ -name "$dll" -exec cp {} "$DIST_DIR/" \; 2>/dev/null || true
|
||||||
|
fi
|
||||||
if [ ! -f "$DIST_DIR/$dll" ] && [ -f "$MINGW_SYSROOT/bin/$dll" ]; then
|
if [ ! -f "$DIST_DIR/$dll" ] && [ -f "$MINGW_SYSROOT/bin/$dll" ]; then
|
||||||
cp "$MINGW_SYSROOT/bin/$dll" "$DIST_DIR/"
|
cp "$MINGW_SYSROOT/bin/$dll" "$DIST_DIR/"
|
||||||
fi
|
fi
|
||||||
@@ -108,6 +110,10 @@ Plugins = .
|
|||||||
Qml2Imports = qml
|
Qml2Imports = qml
|
||||||
EOF
|
EOF
|
||||||
|
|
||||||
|
# Verify all PE binary dependencies in DIST_DIR
|
||||||
|
echo "==> Verifying bundled DLL dependencies in $DIST_DIR..."
|
||||||
|
python3 "$PROJECT_DIR/scripts/verify-windows-dlls.py" "$DIST_DIR"
|
||||||
|
|
||||||
# Output flat directory — GitLab zips the artifact directory on download
|
# Output flat directory — GitLab zips the artifact directory on download
|
||||||
mkdir -p "$OUTPUT_DIR/$PKG_NAME"
|
mkdir -p "$OUTPUT_DIR/$PKG_NAME"
|
||||||
cp -r "$DIST_DIR/"* "$OUTPUT_DIR/$PKG_NAME/"
|
cp -r "$DIST_DIR/"* "$OUTPUT_DIR/$PKG_NAME/"
|
||||||
Executable
+222
@@ -0,0 +1,222 @@
|
|||||||
|
#!/usr/bin/env python3
|
||||||
|
"""
|
||||||
|
Downloads and extracts MSYS2 clangarm64 Qt6 packages and all transitive
|
||||||
|
runtime dependencies into the destination directory.
|
||||||
|
|
||||||
|
Usage:
|
||||||
|
download-mingw-arm64-qt.py --dest /path/to/qt_arm64 [--dry-run]
|
||||||
|
"""
|
||||||
|
|
||||||
|
import argparse
|
||||||
|
import io
|
||||||
|
import os
|
||||||
|
import re
|
||||||
|
import subprocess
|
||||||
|
import sys
|
||||||
|
import tarfile
|
||||||
|
import urllib.error
|
||||||
|
import urllib.request
|
||||||
|
|
||||||
|
MIRROR_URLS = [
|
||||||
|
"https://mirror.msys2.org/mingw/clangarm64",
|
||||||
|
"https://repo.msys2.org/mingw/clangarm64",
|
||||||
|
]
|
||||||
|
|
||||||
|
SEEDS = [
|
||||||
|
"mingw-w64-clang-aarch64-qt6-base",
|
||||||
|
"mingw-w64-clang-aarch64-qt6-declarative",
|
||||||
|
"mingw-w64-clang-aarch64-qt6-svg",
|
||||||
|
"mingw-w64-clang-aarch64-qt6-5compat",
|
||||||
|
]
|
||||||
|
|
||||||
|
# Non-runtime / scripting packages not required by Qt6 C++ / QML applications
|
||||||
|
SKIP_SUBSTRINGS = (
|
||||||
|
"python",
|
||||||
|
"tcl",
|
||||||
|
"tk",
|
||||||
|
"mpdecimal",
|
||||||
|
)
|
||||||
|
|
||||||
|
EXPECTED_DLLS = [
|
||||||
|
"Qt6Core.dll",
|
||||||
|
"Qt6Gui.dll",
|
||||||
|
"Qt6Qml.dll",
|
||||||
|
"Qt6Quick.dll",
|
||||||
|
"zlib1.dll",
|
||||||
|
"libzstd.dll",
|
||||||
|
"libmd4c.dll",
|
||||||
|
"libb2-1.dll",
|
||||||
|
"libfreetype-6.dll",
|
||||||
|
"libharfbuzz-0.dll",
|
||||||
|
"libpng16-16.dll",
|
||||||
|
"libglib-2.0-0.dll",
|
||||||
|
]
|
||||||
|
|
||||||
|
|
||||||
|
def fetch_url(url, timeout=30):
|
||||||
|
req = urllib.request.Request(url, headers={"User-Agent": "Mozilla/5.0 (Asteria-CI)"})
|
||||||
|
with urllib.request.urlopen(req, timeout=timeout) as resp:
|
||||||
|
return resp.read()
|
||||||
|
|
||||||
|
|
||||||
|
def download_db():
|
||||||
|
for mirror in MIRROR_URLS:
|
||||||
|
db_url = f"{mirror}/clangarm64.db.tar.zst"
|
||||||
|
print(f"==> Downloading package database from {db_url}...")
|
||||||
|
try:
|
||||||
|
data = fetch_url(db_url, timeout=30)
|
||||||
|
print(f"==> Downloaded database ({len(data)} bytes)")
|
||||||
|
return data, mirror
|
||||||
|
except Exception as e:
|
||||||
|
print(f" Failed ({e}), trying next mirror...", file=sys.stderr)
|
||||||
|
raise RuntimeError("Failed to download clangarm64.db.tar.zst from all mirrors")
|
||||||
|
|
||||||
|
|
||||||
|
def parse_database(db_bytes):
|
||||||
|
# Decompress zstd
|
||||||
|
res = subprocess.run(["zstd", "-d", "-c"], input=db_bytes, capture_output=True)
|
||||||
|
if res.returncode != 0:
|
||||||
|
raise RuntimeError(f"zstd decompression failed: {res.stderr.decode('utf-8', errors='replace')}")
|
||||||
|
|
||||||
|
tar = tarfile.open(fileobj=io.BytesIO(res.stdout))
|
||||||
|
packages = {}
|
||||||
|
provides_map = {}
|
||||||
|
|
||||||
|
for member in tar.getmembers():
|
||||||
|
if member.isfile() and member.name.endswith("/desc"):
|
||||||
|
f = tar.extractfile(member)
|
||||||
|
if not f:
|
||||||
|
continue
|
||||||
|
content = f.read().decode("utf-8", errors="replace")
|
||||||
|
pkg_name = None
|
||||||
|
filename = None
|
||||||
|
depends = []
|
||||||
|
current_section = None
|
||||||
|
for line in content.splitlines():
|
||||||
|
line = line.strip()
|
||||||
|
if line.startswith("%") and line.endswith("%"):
|
||||||
|
current_section = line[1:-1]
|
||||||
|
elif current_section == "NAME" and line:
|
||||||
|
pkg_name = line
|
||||||
|
elif current_section == "FILENAME" and line:
|
||||||
|
filename = line
|
||||||
|
elif current_section == "DEPENDS" and line:
|
||||||
|
dep = re.split(r"[<>=]", line)[0]
|
||||||
|
depends.append(dep)
|
||||||
|
elif current_section == "PROVIDES" and line:
|
||||||
|
prov = re.split(r"[<>=]", line)[0]
|
||||||
|
provides_map[prov] = pkg_name
|
||||||
|
|
||||||
|
if pkg_name:
|
||||||
|
packages[pkg_name] = {"filename": filename, "depends": depends}
|
||||||
|
provides_map[pkg_name] = pkg_name
|
||||||
|
|
||||||
|
return packages, provides_map
|
||||||
|
|
||||||
|
|
||||||
|
def resolve_dependencies(packages, provides_map):
|
||||||
|
queue = list(SEEDS)
|
||||||
|
visited = set(SEEDS)
|
||||||
|
resolved = []
|
||||||
|
|
||||||
|
while queue:
|
||||||
|
curr = queue.pop(0)
|
||||||
|
real_pkg = provides_map.get(curr, curr)
|
||||||
|
if any(skip in real_pkg for skip in SKIP_SUBSTRINGS):
|
||||||
|
continue
|
||||||
|
if real_pkg in packages:
|
||||||
|
visited.add(real_pkg)
|
||||||
|
resolved.append((real_pkg, packages[real_pkg]["filename"]))
|
||||||
|
for dep in packages[real_pkg]["depends"]:
|
||||||
|
dep_real = provides_map.get(dep, dep)
|
||||||
|
if any(skip in dep_real for skip in SKIP_SUBSTRINGS):
|
||||||
|
continue
|
||||||
|
if dep_real not in visited:
|
||||||
|
visited.add(dep_real)
|
||||||
|
queue.append(dep_real)
|
||||||
|
else:
|
||||||
|
print(f"Warning: dependency '{curr}' not found in database", file=sys.stderr)
|
||||||
|
|
||||||
|
return sorted(resolved)
|
||||||
|
|
||||||
|
|
||||||
|
def download_and_extract_packages(resolved, base_mirror, dest_dir):
|
||||||
|
os.makedirs(dest_dir, exist_ok=True)
|
||||||
|
temp_pkg = "/tmp/arm64_pkg.tar.zst"
|
||||||
|
|
||||||
|
for i, (pkg_name, filename) in enumerate(resolved, 1):
|
||||||
|
print(f"[{i}/{len(resolved)}] Downloading {filename}...")
|
||||||
|
downloaded = False
|
||||||
|
last_err = None
|
||||||
|
|
||||||
|
for mirror in MIRROR_URLS:
|
||||||
|
pkg_url = f"{mirror}/{filename}"
|
||||||
|
try:
|
||||||
|
data = fetch_url(pkg_url, timeout=60)
|
||||||
|
with open(temp_pkg, "wb") as f:
|
||||||
|
f.write(data)
|
||||||
|
downloaded = True
|
||||||
|
break
|
||||||
|
except Exception as e:
|
||||||
|
last_err = e
|
||||||
|
print(f" Failed from {mirror} ({e}), trying next mirror...", file=sys.stderr)
|
||||||
|
|
||||||
|
if not downloaded:
|
||||||
|
raise RuntimeError(f"Failed to download {filename}: {last_err}")
|
||||||
|
|
||||||
|
# Extract stripping top-level directory (clangarm64)
|
||||||
|
tar_res = subprocess.run(
|
||||||
|
["tar", "-I", "zstd", "-xf", temp_pkg, "--strip-components=1", "-C", dest_dir],
|
||||||
|
capture_output=True,
|
||||||
|
)
|
||||||
|
if os.path.exists(temp_pkg):
|
||||||
|
os.remove(temp_pkg)
|
||||||
|
|
||||||
|
if tar_res.returncode != 0:
|
||||||
|
err = tar_res.stderr.decode("utf-8", errors="replace")
|
||||||
|
raise RuntimeError(f"Failed to extract {filename}: {err}")
|
||||||
|
|
||||||
|
|
||||||
|
def verify_installation(dest_dir):
|
||||||
|
bin_dir = os.path.join(dest_dir, "bin")
|
||||||
|
if not os.path.isdir(bin_dir):
|
||||||
|
raise RuntimeError(f"Expected bin directory missing: {bin_dir}")
|
||||||
|
|
||||||
|
missing = []
|
||||||
|
for dll in EXPECTED_DLLS:
|
||||||
|
dll_path = os.path.join(bin_dir, dll)
|
||||||
|
if not os.path.isfile(dll_path):
|
||||||
|
missing.append(dll)
|
||||||
|
|
||||||
|
if missing:
|
||||||
|
raise RuntimeError(f"Missing expected DLLs in {bin_dir}: {', '.join(missing)}")
|
||||||
|
|
||||||
|
print(f"==> Verification passed: all {len(EXPECTED_DLLS)} required core DLLs present in {bin_dir}")
|
||||||
|
|
||||||
|
|
||||||
|
def main():
|
||||||
|
parser = argparse.ArgumentParser(description="Download MSYS2 clangarm64 Qt6 packages and dependencies")
|
||||||
|
parser.add_argument("--dest", required=True, help="Destination directory to extract packages into")
|
||||||
|
parser.add_argument("--dry-run", action="store_true", help="Resolve packages without downloading or extracting")
|
||||||
|
args = parser.parse_args()
|
||||||
|
|
||||||
|
db_bytes, mirror = download_db()
|
||||||
|
packages, provides_map = parse_database(db_bytes)
|
||||||
|
print(f"==> Parsed {len(packages)} packages from MSYS2 database")
|
||||||
|
|
||||||
|
resolved = resolve_dependencies(packages, provides_map)
|
||||||
|
print(f"==> Resolved {len(resolved)} packages to install:")
|
||||||
|
for pkg_name, filename in resolved:
|
||||||
|
print(f" - {pkg_name} ({filename})")
|
||||||
|
|
||||||
|
if args.dry_run:
|
||||||
|
print("==> Dry run complete.")
|
||||||
|
return
|
||||||
|
|
||||||
|
download_and_extract_packages(resolved, mirror, args.dest)
|
||||||
|
verify_installation(args.dest)
|
||||||
|
print(f"==> Successfully installed Qt6 Windows ARM64 into {args.dest}")
|
||||||
|
|
||||||
|
|
||||||
|
if __name__ == "__main__":
|
||||||
|
main()
|
||||||
Executable
+214
@@ -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()
|
||||||
Reference in new issue
Block a user