name: Solaris Multi-Build on: push: branches: - master workflow_dispatch: jobs: build: runs-on: ubuntu-latest strategy: matrix: include: - host: 172.16.11.20 # Solaris 2.6 i386 osver: "2.6" arch: "i386" # - host: 172.16.11.21 # Solaris 2.6 sparc # osver: "2.6" # arch: "sparc" # - host: 172.16.11.22 # Solaris 7 i386 # osver: "7" # arch: "i386" # - host: 172.16.11.23 # Solaris 7 sparc # osver: "7" # arch: "sparc" # Add more hosts for each Solaris version / architecture steps: - name: Checkout repository uses: actions/checkout@v3 - name: Build binutils on Solaris ${{ matrix.osver }} ${{ matrix.arch }} uses: appleboy/ssh-action@master with: host: ${{ matrix.host }} username: root key: ${{ secrets.BUILD_SSH_KEY }} script: | set -e # --- Solaris-compatible host-level lock --- LOCKDIR="/tmp/build-host.lock" while ! mkdir "$LOCKDIR" 2>/dev/null; do echo "Another build is running on this host. Waiting..." sleep 10 done echo "Acquired host lock, starting build..." # Ensure lock is removed on exit trap "rmdir '$LOCKDIR'" EXIT echo "=== Updating sources on Solaris ${{ matrix.osver }} ===" cd /usr/src/buildpkg && git pull cd /usr/src/dbpware-for-solaris && git pull export BUILDPKG_SCRIPTS=/usr/src/buildpkg/ export BUILDPKG_BASE=/usr/src/dbpware-for-solaris/ # Define build order (other packages commented out) BUILD_ORDER=( binutils # gcc # gmake # coreutils # add more packages in build order ) for pkg in "${BUILD_ORDER[@]}"; do echo "=== Checking $pkg ===" cd "$BUILDPKG_BASE/$pkg" # Parse basic fields from build.sh using GNU grep topdir=$(ggrep -E '^topdir=' build.sh | cut -d= -f2) version=$(ggrep -E '^version=' build.sh | cut -d= -f2) pkgver=$(ggrep -E '^pkgver=' build.sh | cut -d= -f2) secname="$topdir" # Skip build if package already exists PKGFILE=$(ls -1 ${secname}-${version}-${pkgver}.dbp*.gz 2>/dev/null | head -n1 || true) if [ -n "$PKGFILE" ]; then echo "Package already built: $PKGFILE. Skipping." continue fi echo "=== Building $pkg on Solaris ${{ matrix.osver }} ${{ matrix.arch }} ===" LOGFILE=$(bash build.sh all 2>&1 | tee /tmp/build-$pkg.log | ggrep -oE '[^ ]+\.log' | gtail -n1) if [ -n "$LOGFILE" ] && [ -f "$LOGFILE" ]; then echo "Tailing logfile: $LOGFILE" gtail -f "$LOGFILE" & TAIL_PID=$! else echo "ERROR: No logfile detected for $pkg" exit 1 fi wait -n EXIT_CODE=$? kill $TAIL_PID || true if [ $EXIT_CODE -eq 0 ]; then echo "Build succeeded for $pkg, deleting logfile." rm -f "$LOGFILE" || true else echo "Build FAILED for $pkg, keeping logfile: $LOGFILE" exit $EXIT_CODE fi echo "=== Finished $pkg ===" done