| 1 | #!/usr/bin/env bash |
| 2 | # Build script for creating fortress RPM package |
| 3 | set -euo pipefail |
| 4 | |
| 5 | SCRIPT_DIR="$(cd "$(dirname "${BASH_SOURCE[0]}")" && pwd)" |
| 6 | cd "$SCRIPT_DIR" |
| 7 | |
| 8 | # Get version from spec file |
| 9 | VERSION=$(grep "^Version:" fortress.spec | awk '{print $2}') |
| 10 | RELEASE=$(grep "^Release:" fortress.spec | awk '{print $2}' | cut -d'%' -f1) |
| 11 | NAME="fortress" |
| 12 | |
| 13 | echo "======================================================================" |
| 14 | echo " Building $NAME-$VERSION-$RELEASE RPM" |
| 15 | echo "======================================================================" |
| 16 | echo "" |
| 17 | |
| 18 | # Create rpmbuild directories |
| 19 | mkdir -p ~/rpmbuild/{BUILD,RPMS,SOURCES,SPECS,SRPMS} |
| 20 | |
| 21 | echo "▶ Creating source tarball..." |
| 22 | # Create source tarball (excluding build artifacts and git) |
| 23 | tar --exclude='.git' \ |
| 24 | --exclude='build' \ |
| 25 | --exclude='*.rpm' \ |
| 26 | --exclude='*.tar.gz' \ |
| 27 | --exclude='rpmbuild' \ |
| 28 | --transform "s,^.,$NAME-$VERSION," \ |
| 29 | -czf ~/rpmbuild/SOURCES/$NAME-$VERSION.tar.gz \ |
| 30 | . |
| 31 | |
| 32 | echo "✓ Tarball created: ~/rpmbuild/SOURCES/$NAME-$VERSION.tar.gz" |
| 33 | |
| 34 | echo "▶ Copying spec file..." |
| 35 | cp fortress.spec ~/rpmbuild/SPECS/ |
| 36 | |
| 37 | echo "▶ Building RPM package..." |
| 38 | rpmbuild -ba ~/rpmbuild/SPECS/fortress.spec |
| 39 | |
| 40 | echo "" |
| 41 | echo "======================================================================" |
| 42 | echo " Build Complete!" |
| 43 | echo "======================================================================" |
| 44 | echo "" |
| 45 | echo "RPMs created in:" |
| 46 | ls -lh ~/rpmbuild/RPMS/*/$NAME-*.rpm 2>/dev/null || echo " (No binary RPMs found)" |
| 47 | echo "" |
| 48 | echo "SRPMs created in:" |
| 49 | ls -lh ~/rpmbuild/SRPMS/$NAME-*.rpm 2>/dev/null || echo " (No source RPMs found)" |
| 50 | echo "" |