Skip to content

Commit

Permalink
fix: upx packing, allow multiple projects to be specified for building (
Browse files Browse the repository at this point in the history
  • Loading branch information
cktii authored Aug 27, 2024
1 parent b403fa8 commit 7954637
Show file tree
Hide file tree
Showing 3 changed files with 25 additions and 22 deletions.
11 changes: 9 additions & 2 deletions .cfg/verify_build
Original file line number Diff line number Diff line change
Expand Up @@ -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}"
Expand Down
34 changes: 15 additions & 19 deletions build.sh
Original file line number Diff line number Diff line change
Expand Up @@ -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"
2 changes: 1 addition & 1 deletion toybox/build.sh
Original file line number Diff line number Diff line change
Expand Up @@ -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"
Expand Down

0 comments on commit 7954637

Please sign in to comment.