#!/bin/bash # Post-Build Hook: Inject custom libcore into all packages # This script must run AFTER flutter_distributor builds packages set -e PROJECT_DIR="$HOME/dorod/hiddify-umbrix-v1.7.0" LIBCORE_CUSTOM="$PROJECT_DIR/libcore/bin/lib/libcore.so" DIST_DIR="$PROJECT_DIR/dist" echo "🔧 Post-build: Injecting custom libcore into packages..." # For DEB packages if ls "$DIST_DIR"/*/*.deb 2>/dev/null; then echo " Processing DEB packages..." for deb in "$DIST_DIR"/*/*.deb; do echo " • $(basename $deb)" # Extract, replace libcore, repack TEMP_DIR=$(mktemp -d) dpkg-deb -R "$deb" "$TEMP_DIR" # Find and replace libcore.so find "$TEMP_DIR" -name "libcore.so" -exec cp -f "$LIBCORE_CUSTOM" {} \; # Repack dpkg-deb -b "$TEMP_DIR" "$deb" rm -rf "$TEMP_DIR" echo " ✓ libcore injected" done fi # For AppImage if ls "$DIST_DIR"/*/*.AppImage 2>/dev/null; then echo " Processing AppImage packages..." for appimage in "$DIST_DIR"/*/*.AppImage; do echo " • $(basename $appimage)" # Extract AppImage TEMP_DIR=$(mktemp -d) cd "$TEMP_DIR" "$appimage" --appimage-extract >/dev/null 2>&1 # Replace libcore find squashfs-root -name "libcore.so" -exec cp -f "$LIBCORE_CUSTOM" {} \; # Repack AppImage if command -v appimagetool >/dev/null 2>&1; then ARCH=x86_64 appimagetool squashfs-root "$appimage" >/dev/null 2>&1 echo " ✓ libcore injected" else echo " ⚠ appimagetool not found, skipping repack" fi cd - >/dev/null rm -rf "$TEMP_DIR" done fi echo "✓ Post-build complete"