diff --git a/.github/workflows/ci.yml b/.github/workflows/ci.yml index 54fce76..a21dd3a 100644 --- a/.github/workflows/ci.yml +++ b/.github/workflows/ci.yml @@ -137,27 +137,10 @@ jobs: if: matrix.target != 'x86_64-unknown-linux-gnu' && matrix.target != 'x86_64-apple-darwin' && matrix.target != 'aarch64-apple-darwin' run: cross build --release --target ${{ matrix.target }} - - name: Install UPX - run: | - if [ "${{ runner.os }}" = "Linux" ]; then - # Download and install UPX for Linux - curl -L https://github.com/upx/upx/releases/download/v4.2.1/upx-4.2.1-amd64_linux.tar.xz | tar xJ - sudo mv upx-4.2.1-amd64_linux/upx /usr/local/bin/ - elif [ "${{ runner.os }}" = "macOS" ]; then - # Install UPX via Homebrew on macOS - brew install upx - fi - shell: bash - - - name: Rename and compress binary + - name: Rename binary run: | if [ -f "target/${{ matrix.target }}/release/fls" ]; then cp "target/${{ matrix.target }}/release/fls" "${{ matrix.artifact_name }}" - echo "Original size:" - ls -lh "${{ matrix.artifact_name }}" - # Compress with UPX - upx --best --lzma "${{ matrix.artifact_name }}" || echo "UPX compression failed, using uncompressed binary" - echo "Compressed size:" ls -lh "${{ matrix.artifact_name }}" fi shell: bash diff --git a/.github/workflows/release.yml b/.github/workflows/release.yml index 59a090f..2cd053e 100644 --- a/.github/workflows/release.yml +++ b/.github/workflows/release.yml @@ -78,41 +78,12 @@ jobs: if: matrix.target != 'x86_64-unknown-linux-gnu' && matrix.target != 'x86_64-apple-darwin' && matrix.target != 'aarch64-apple-darwin' run: cross build --release --target ${{ matrix.target }} - - name: Install UPX - run: | - if [ "${{ runner.os }}" = "Linux" ]; then - # Download and install UPX for Linux - curl -L https://github.com/upx/upx/releases/download/v4.2.1/upx-4.2.1-amd64_linux.tar.xz | tar xJ - sudo mv upx-4.2.1-amd64_linux/upx /usr/local/bin/ - elif [ "${{ runner.os }}" = "macOS" ]; then - # Install UPX via Homebrew on macOS - brew install upx - fi - upx --version - shell: bash - - - name: Prepare and compress binary + - name: Prepare binary run: | if [ -f "target/${{ matrix.target }}/release/fls" ]; then cp "target/${{ matrix.target }}/release/fls" "${{ matrix.artifact_name }}" - - echo "📦 Original binary size:" ls -lh "${{ matrix.artifact_name }}" - original_size=$(stat -f%z "${{ matrix.artifact_name }}" 2>/dev/null || stat -c%s "${{ matrix.artifact_name }}") - - # Compress with UPX - echo "🗜️ Compressing with UPX --best --lzma..." - if upx --best --lzma "${{ matrix.artifact_name }}"; then - echo "✅ Compression successful!" - ls -lh "${{ matrix.artifact_name }}" - compressed_size=$(stat -f%z "${{ matrix.artifact_name }}" 2>/dev/null || stat -c%s "${{ matrix.artifact_name }}") - ratio=$(awk "BEGIN {printf \"%.1f\", ($original_size - $compressed_size) * 100 / $original_size}") - echo "📉 Size reduction: ${ratio}%" - else - echo "⚠️ UPX compression failed, using uncompressed binary" - fi - - # Create checksum + if command -v sha256sum &> /dev/null; then sha256sum "${{ matrix.artifact_name }}" > "${{ matrix.artifact_name }}.sha256" else diff --git a/Containerfile b/Containerfile index a153120..c9a8325 100644 --- a/Containerfile +++ b/Containerfile @@ -10,7 +10,6 @@ RUN apt-get update && apt-get install -y \ make \ perl \ file \ - upx-ucl \ && rm -rf /var/lib/apt/lists/* # Add ARM64 glibc target @@ -50,12 +49,5 @@ COPY src src # Build the actual project (dependencies are already cached) RUN cargo build --release --target aarch64-unknown-linux-gnu -# Compress the binary with UPX for smaller size -# Using --best for maximum compression, --lzma for best algorithm -# UPX compresses in-place, so the original binary will be compressed -RUN cd target/aarch64-unknown-linux-gnu/release && \ - upx --best --lzma fls || \ - echo "UPX compression failed, using uncompressed binary" - -# The compressed binary will be in target/aarch64-unknown-linux-gnu/release/fls +# The binary will be in target/aarch64-unknown-linux-gnu/release/fls diff --git a/Makefile b/Makefile index 48c571b..a2a344f 100644 --- a/Makefile +++ b/Makefile @@ -1,6 +1,6 @@ # Makefile for fls - ARM64 static builds -.PHONY: all build clean test arm64-static lint fmt clippy check help compress-upx +.PHONY: all build clean test arm64-static lint fmt clippy check help # Default target all: build @@ -9,10 +9,6 @@ all: build build: cargo build --release -# Build and compress for native target -build-compressed: build - @$(MAKE) compress-upx BINARY=target/release/fls OUTPUT=fls-native - # Build for ARM64 static (musl) using cross arm64-static: rustup target add aarch64-unknown-linux-musl @@ -24,10 +20,6 @@ arm64-static: ls -lh fls-arm64-static; \ fi -# Build ARM64 static and compress with UPX -arm64-static-compressed: arm64-static - @$(MAKE) compress-upx BINARY=fls-arm64-static OUTPUT=fls-arm64-static - # Build for all targets (native + ARM64 static) all-targets: ./build.sh @@ -59,39 +51,6 @@ check: @echo "Running cargo check..." cargo check --all-targets -# Compress a binary with UPX -# Usage: make compress-upx BINARY=path/to/binary OUTPUT=output-name -compress-upx: - @if [ -z "$(BINARY)" ] || [ -z "$(OUTPUT)" ]; then \ - echo "Error: BINARY and OUTPUT must be specified"; \ - echo "Usage: make compress-upx BINARY=path/to/binary OUTPUT=output-name"; \ - exit 1; \ - fi - @if ! command -v upx >/dev/null 2>&1; then \ - echo "Error: UPX not found. Install it first:"; \ - echo " macOS: brew install upx"; \ - echo " Linux: apt-get install upx-ucl or download from https://github.com/upx/upx/releases"; \ - exit 1; \ - fi - @if [ -f "$(BINARY)" ]; then \ - if [ "$(BINARY)" != "$(OUTPUT)" ]; then \ - cp "$(BINARY)" "$(OUTPUT)"; \ - fi; \ - echo "📦 Original size:"; \ - ls -lh "$(OUTPUT)"; \ - echo "🗜️ Compressing with UPX --best --lzma..."; \ - if upx --best --lzma "$(OUTPUT)"; then \ - echo "✅ Compression successful!"; \ - ls -lh "$(OUTPUT)"; \ - else \ - echo "⚠️ UPX compression failed"; \ - exit 1; \ - fi; \ - else \ - echo "Error: Binary $(BINARY) not found"; \ - exit 1; \ - fi - # Clean build artifacts clean: cargo clean @@ -111,14 +70,9 @@ help: @echo "" @echo "Build targets:" @echo " build - Build for native target" - @echo " build-compressed - Build for native target and compress with UPX" @echo " arm64-static - Build for ARM64 static (musl)" - @echo " arm64-static-compressed - Build for ARM64 static and compress with UPX" @echo " all-targets - Build for native + ARM64 static" @echo "" - @echo "Compression:" - @echo " compress-upx - Compress a binary with UPX (requires BINARY and OUTPUT args)" - @echo "" @echo "Testing and Quality:" @echo " test - Run tests" @echo " lint - Run all lints (format check + clippy)"