| 1234567891011121314151617181920212223242526272829303132333435363738394041424344 |
- #!/bin/bash
- # WaouW — PyArmor obfuscation script
- # Obfuscates all Python source files in app/ for source code protection.
- # Run inside Docker build stage.
- set -e
- echo "WaouW PyArmor Obfuscation"
- echo "========================="
- # Fix CRLF
- find /build -name "*.py" -exec sed -i 's/\r$//' {} +
- # Register license if key file exists
- if [ -f /build/pyarmor-regkey.txt ]; then
- echo "Registering PyArmor license..."
- pyarmor reg /build/pyarmor-regkey.txt 2>&1 || echo "License registration failed, continuing with trial"
- fi
- # Obfuscate all app/ files
- echo "Obfuscating app/..."
- cd /build
- pyarmor gen --recursive --output /tmp/pyarmor-out app/ 2>&1
- # Replace original files with obfuscated ones
- if [ -d /tmp/pyarmor-out/app ]; then
- echo "Replacing source with obfuscated files..."
- # Copy obfuscated files over originals
- cp -rf /tmp/pyarmor-out/app/* /build/app/
- # Copy runtime library
- if [ -d /tmp/pyarmor-out/pyarmor_runtime_* ]; then
- cp -rf /tmp/pyarmor-out/pyarmor_runtime_* /build/app/
- fi
- echo "Obfuscation complete."
- # Count
- TOTAL=$(find /build/app -name "*.py" ! -name "__init__.py" | wc -l)
- echo "Total Python files: $TOTAL"
- else
- echo "ERROR: Obfuscation output not found"
- exit 1
- fi
- # Cleanup
- rm -rf /tmp/pyarmor-out
- echo "Done."
|