Simplify macOS .app lib trimming workflow

Replace complex multi-dir detection with a single find+while loop to identify library dirs and verify Python lib layout (asyncio/PySide6/ytsage). Consolidate cleanup steps: recursively remove PySide6 translations, normalize plugin path detection and remove specific plugin folders/files via find, and simplify removal of unwanted Qt modules using broader find patterns. Remove some verbose checks and add a final sanity listing of remaining lib contents. These changes make the trimming more robust to different .app layouts and reduce duplicate logic.
This commit is contained in:
oop7
2026-02-03 16:14:59 +02:00
parent c11a4a0280
commit ac11cbd7bb
+47 -63
View File
@@ -205,75 +205,59 @@ jobs:
if [ -n "$app_path" ]; then if [ -n "$app_path" ]; then
echo "Processing App Bundle at: $app_path" echo "Processing App Bundle at: $app_path"
# Determine Lib directory (standard location vs customized) # Simplified discovery of library directories
# We look for all 'lib' directories that contain 'PySide6' or 'ytsage' to be thorough # We search for 'lib' folders and then verify if they look like the python library folder
# resulting in potentially multiple lib dirs to clean (e.g. MacOS/lib and Resources/lib) find "$app_path/Contents" -type d -name "lib" | while read -r lib_dir; do
lib_dirs=$(find "$app_path/Contents" -type d -name "lib" | while read -r d; do if [ -d "$d/ytsage" ] || [ -d "$d/PySide6" ]; then echo "$d"; fi; done) # Check if this lib dir is a python library dir (contains asyncio or PySide6 or ytsage)
if [ -d "$lib_dir/asyncio" ] || [ -d "$lib_dir/PySide6" ] || [ -d "$lib_dir/ytsage" ]; then
if [ -z "$lib_dirs" ]; then echo "Cleaning Library Directory: $lib_dir"
echo "Warning: No valid Library directory found. Skipping deep trim."
fi # 1. Remove screenshots
rm -rf "$lib_dir/assets/branding/screenshots"
for lib_dir in $lib_dirs; do
echo "Processing Lib Directory: $lib_dir" # 2. Remove unused Qt translations (Recursively find 'translations' folder inside PySide6)
find "$lib_dir" -type d -path "*/PySide6/*/translations" -exec rm -rf {} + 2>/dev/null || true
# 1. Remove screenshots find "$lib_dir" -type d -path "*/PySide6/translations" -exec rm -rf {} + 2>/dev/null || true
rm -rf "$lib_dir/assets/branding/screenshots"
echo "Removed screenshots folder" # 3. Remove unused Qt plugins
# Determine plugins path
# 2. Remove unused Qt translations (Path varies: PySide6/translations or PySide6/Qt/translations) plugins_path=""
rm -rf "$lib_dir/PySide6/translations" if [ -d "$lib_dir/PySide6/plugins" ]; then plugins_path="$lib_dir/PySide6/plugins"; fi
rm -rf "$lib_dir/PySide6/Qt/translations" if [ -d "$lib_dir/PySide6/Qt/plugins" ]; then plugins_path="$lib_dir/PySide6/Qt/plugins"; fi
echo "Removed Qt translations"
if [ -n "$plugins_path" ]; then
# 3. Remove unused Qt plugins echo "Found plugins at: $plugins_path"
# Path varies: PySide6/plugins or PySide6/Qt/plugins
for plugins_base in "$lib_dir/PySide6/plugins" "$lib_dir/PySide6/Qt/plugins"; do
if [ -d "$plugins_base" ]; then
for plugin in designer pdf svg sql help qml quick webengine bluetooth opengl printsupport test xml; do for plugin in designer pdf svg sql help qml quick webengine bluetooth opengl printsupport test xml; do
if [ -d "$plugins_base/$plugin" ]; then rm -rf "$plugins_path/$plugin"
rm -rf "$plugins_base/$plugin"
echo "Removed plugin folder: $plugin from $plugins_base"
fi
done done
# 3.1. Explicitly remove specific input contexts and image formats # Specific cleanups
rm -rf "$plugins_base/platforminputcontexts" rm -rf "$plugins_path/platforminputcontexts"
rm -f "$plugins_base/imageformats/libqpdf.dylib" "$plugins_base/imageformats/libqsvg.dylib" find "$plugins_path" -name "libqpdf.*" -delete
rm -f "$plugins_base/imageformats/libqpdf.so" "$plugins_base/imageformats/libqsvg.so" # just in case find "$plugins_path" -name "libqsvg.*" -delete
rm -f "$plugins_base/iconengines/libqsvgicon.dylib" find "$plugins_path" -name "libqsvgicon.*" -delete
fi fi
done
# 4. Remove bloat Qt libraries / Frameworks
# 4. Remove any duplicate or unnecessary Qt Libraries (DLLs/dylibs/frameworks) # Iterate specifically over unwanted Qt modules
# On macOS, these often appear as files with no extension (e.g. 'QtQml') or .dylib # Matches both 'QtQml' (file) and 'QtQml.abi3.so' etc
# We remove both variants and also the 'Qt6' prefixed ones just in case for bloat in QtQml QtQmlMeta QtQmlModels QtQmlWorkerScript QtQuick QtQuickControls2 QtQuickTemplates2 QtWebEngine QtWebEngineCore QtVirtualKeyboard QtVirtualKeyboardQml QtOpenGL QtOpenGLWidgets QtPdf QtPdfWidgets QtDBus; do
echo "Removing bloat Qt libraries..." find "$lib_dir" -maxdepth 2 -name "$bloat" -delete
find "$lib_dir" -maxdepth 2 -name "${bloat}.*" -delete
# Standard patterns (Linux/Windows style) find "$lib_dir" -maxdepth 2 -name "*$bloat*" -delete
find "$lib_dir" -name "*Qt6Web*" -delete done
find "$lib_dir" -name "*Qt6Pdf*" -delete
find "$lib_dir" -name "*Qt6Qml*" -delete # 5. Remove build tools and unused python modules
find "$lib_dir" -name "*Qt6Quick*" -delete for tool in setuptools wheel pkg_resources _distutils_hack curses _pyrepl; do
find "$lib_dir" -name "*Qt6VirtualKeyboard*" -delete rm -rf "$lib_dir/$tool"
find "$lib_dir" -name "*Qt6OpenGL*" -delete done
find "$lib_dir" -name "*Qt6DBus*" -delete fi
# macOS Framework style (No '6' in name usually, e.g. QtQml, QtQuick)
# Be careful not to delete QtQuickWidgets if used (though usually safe if Quick is gone)
# We use known specific lists to avoid over-deleting
for bloat in QtQml QtQmlMeta QtQmlModels QtQmlWorkerScript QtQuick QtQuickControls2 QtQuickTemplates2 QtWebEngine QtWebEngineCore QtVirtualKeyboard QtVirtualKeyboardQml QtOpenGL QtOpenGLWidgets QtPdf QtPdfWidgets QtDBus; do
find "$lib_dir" -maxdepth 1 -name "$bloat" -delete
find "$lib_dir" -maxdepth 1 -name "${bloat}.*" -delete # Matches versions or extensions
done
# 5. Remove build tools and unused python modules
for tool in setuptools wheel pkg_resources _distutils_hack curses _pyrepl; do
rm -rf "$lib_dir/$tool"
echo "Removed build tool/module: $tool"
done
done done
# Final sanity verification
echo "Trim complete. Remaining contents of lib (first 2 levels):"
find "$app_path/Contents" -type d -name "lib" -exec ls -R {} \; | head -n 50 || true
else else
echo "Error: Could not find .app bundle to trim!" echo "Error: Could not find .app bundle to trim!"
exit 1 exit 1