#!/bin/bash echo "Building img2pdf..." ROOT_DIR="$(cd "$(dirname "${BASH_SOURCE[0]}")/.." && pwd)" # Ensure Go modules are downloaded (override readonly modules if set) (cd "$ROOT_DIR" && GOFLAGS=-mod=mod go mod download) # Create bin directory if it doesn't exist mkdir -p "$ROOT_DIR/bin" # Try to build with a reasonable timeout (cd "$ROOT_DIR" && GOFLAGS=-mod=mod timeout 60 go build -o bin/img2pdf main.go) if [ $? -eq 0 ]; then echo "Built successfully to bin/img2pdf" else echo "Build failed or timed out. This may be due to OpenGL dependencies." echo "Try installing development packages:" echo " sudo dnf install mesa-libGL-devel libX11-devel libXcursor-devel" echo "" echo "Or try building with CGO disabled (limited functionality):" echo " CGO_ENABLED=0 go build -o bin/img2pdf main.go" fi