diff --git a/.cfg/verify_build b/.cfg/verify_build index 22d4926..7bcd725 100755 --- a/.cfg/verify_build +++ b/.cfg/verify_build @@ -38,10 +38,17 @@ verify_binaries() { return 1 fi - if ! upx --best --lzma --quiet "$full_path" 2>&1 | grep -q "AlreadyPackedException"; then + # NOTE: Sometimes production binaries are not writable, which is required by UPX + chmod +w "$full_path" + upx_output=$(upx --best --lzma --quiet "$full_path" 2>&1) + upx_exit_code=$? + if [ $upx_exit_code -eq 0 ]; then echo " [OK] Packing with UPX" + elif echo "$upx_output" | grep -q "AlreadyPackedException"; then + echo " [WARN] UPX detected, skipping UPX for $item" else - echo " [WARN] Packing detected, skipping UPX for $item" + printf " [FAIL] UPX failed for %s $item:\n\n%s", "$item", "$upx_output" + return 1 fi fi cp "$full_path" "${BINARIES_DIR}/${binary_name}" diff --git a/build.sh b/build.sh index 95a890b..6bc36ea 100755 --- a/build.sh +++ b/build.sh @@ -54,24 +54,20 @@ cleanup_docker() { docker image prune -f } -if [ -n "$1" ]; then - if [ -d "$1" ]; then - build_app "$1" - else - echo "Directory $1 does not exist" - exit 1 - fi +if [[ $# -eq 0 ]]; then + echo "Building all applications..." + for dir in */; do + build_app "$dir" + done +elif [[ $1 == "--cleanup" ]]; then + cleanup_docker else - if [ "$1" = "--cleanup" ]; then - cleanup_docker - exit 0 - else - echo "Building all applications..." - for dir in */; do - if [ -f "${dir}build.sh" ] && [ -f "${dir}Dockerfile" ]; then - build_app "$dir" - fi - done - fi + for arg in "$@"; do + if [[ -d $arg ]]; then + build_app "$arg" + else + echo "Application directory not found: $arg" >&2 + exit 1 + fi + done fi -rm -Rf "$TMP_LOG_DIR" diff --git a/toybox/build.sh b/toybox/build.sh index 172c5e0..2031a68 100755 --- a/toybox/build.sh +++ b/toybox/build.sh @@ -11,7 +11,7 @@ TOYBOX_REPO="https://github.com/landley/toybox.git" build_toybox() { . fetch_repo $TOYBOX_REPO - LDFLAGS="--static -s" make defconfig toybox + NOSTRIP="y" make LDFLAGS="--static -s" defconfig toybox } log "Building Toybox"