Some checks failed
CI/CD Pipeline / Code Format (push) Failing after 2s
CI/CD Pipeline / Clippy Lints (push) Successful in 44s
CI/CD Pipeline / Enrollment Tests (push) Has been skipped
CI/CD Pipeline / All Unit Tests (push) Successful in 1m13s
CI/CD Pipeline / Build Debian Package (push) Has been skipped
CI/CD Pipeline / Build Debian Package (Ubuntu 22.04) (push) Has been skipped
CI/CD Pipeline / Build RPM Package (push) Has been skipped
CI/CD Pipeline / Build Alpine Package (push) Has been skipped
CI/CD Pipeline / Build Arch Package (push) Has been skipped
CI/CD Pipeline / Security Audit (push) Successful in 4s
CI/CD Pipeline / Verify Enrollment CLI Flag (push) Successful in 55s
Bug fixes: - get_fqdn() now prioritizes 'hostname -f' (returns full FQDN) over /etc/hostname (returns short hostname) - Added get_hostname() for short hostname extraction - Added hostname field to EnrollmentRequest for manager display_name population - Updated SPEC.md and API_DOCUMENTATION.md Package fixes: - Arch: Added linux-patch-api.install with post_install/upgrade/remove hooks, user creation, directory creation, config handling - Alpine: Added linux-patch-api.apk-install with pre/post install/deinstall hooks, user creation, directory creation, config handling, missing config.yaml.example - RPM: Dynamic version from Cargo.toml, %ghost %config(noreplace) for live configs, tarball exclusions, /var/log in %files
75 lines
2.4 KiB
Bash
75 lines
2.4 KiB
Bash
#!/bin/bash
|
|
# Build RPM Package for RHEL/CentOS/Fedora
|
|
# Run on: RHEL 8/9, CentOS 8/9, Fedora 38+
|
|
# Designed for native Gitea Actions runner execution
|
|
|
|
set -e
|
|
|
|
echo "=== Linux Patch API - RPM Build Script ==="
|
|
echo ""
|
|
|
|
# Check if running on RPM-based system
|
|
if ! command -v rpmbuild &> /dev/null; then
|
|
echo "Installing RPM build tools..."
|
|
if command -v dnf &> /dev/null; then
|
|
dnf install -y rpm-build cargo rust gcc systemd-devel
|
|
elif command -v yum &> /dev/null; then
|
|
yum install -y rpm-build cargo rust gcc systemd-devel
|
|
else
|
|
echo "Error: Cannot install rpm-build. Please install manually."
|
|
exit 1
|
|
fi
|
|
fi
|
|
|
|
# Get version from Cargo.toml
|
|
VERSION=$(grep '^version' Cargo.toml | head -1 | sed 's/.*=.*"\([^"]*\)".*/\1/')
|
|
echo "Building version: $VERSION"
|
|
|
|
# Setup RPM build directory structure
|
|
mkdir -p ~/rpmbuild/{BUILD,BUILDROOT,RPMS,SOURCES,SPECS,SRPMS}
|
|
|
|
# Create source tarball (required by %autosetup in spec file)
|
|
echo "Creating source tarball..."
|
|
TMPDIR=$(mktemp -d)
|
|
mkdir -p "$TMPDIR/linux-patch-api-${VERSION}"
|
|
|
|
# Copy files excluding unnecessary directories
|
|
cp -r . "$TMPDIR/linux-patch-api-${VERSION}/"
|
|
|
|
# Remove unnecessary directories from tarball
|
|
rm -rf "$TMPDIR/linux-patch-api-${VERSION}/target"
|
|
rm -rf "$TMPDIR/linux-patch-api-${VERSION}/.git"
|
|
rm -rf "$TMPDIR/linux-patch-api-${VERSION}/releases"
|
|
rm -rf "$TMPDIR/linux-patch-api-${VERSION}/.github"
|
|
rm -rf "$TMPDIR/linux-patch-api-${VERSION}/debian"
|
|
rm -rf "$TMPDIR/linux-patch-api-${VERSION}/arch-package"
|
|
rm -rf "$TMPDIR/linux-patch-api-${VERSION}/.abuild"
|
|
rm -rf "$TMPDIR/linux-patch-api-${VERSION}/apk-package"
|
|
rm -rf "$TMPDIR/linux-patch-api-${VERSION}/.a0proj"
|
|
|
|
tar -czf ~/rpmbuild/SOURCES/linux-patch-api-${VERSION}.tar.gz -C "$TMPDIR" "linux-patch-api-${VERSION}"
|
|
rm -rf "$TMPDIR"
|
|
|
|
# Prepare spec file with dynamic version
|
|
echo "Preparing spec file..."
|
|
sed "s/VERSION_PLACEHOLDER/$VERSION/" linux-patch-api.spec > ~/rpmbuild/SPECS/linux-patch-api.spec
|
|
|
|
# Build RPM
|
|
echo "Building RPM package..."
|
|
rpmbuild -ba ~/rpmbuild/SPECS/linux-patch-api.spec
|
|
|
|
# Copy to releases directory
|
|
echo ""
|
|
echo "Copying package to releases/..."
|
|
mkdir -p releases
|
|
cp ~/rpmbuild/RPMS/x86_64/*.rpm releases/
|
|
|
|
echo ""
|
|
echo "=== Build Complete ==="
|
|
echo "Package: releases/linux-patch-api-*.rpm"
|
|
echo ""
|
|
echo "Install with:"
|
|
echo " dnf install -y ./releases/linux-patch-api-*.rpm"
|
|
echo " # or"
|
|
echo " yum install -y ./releases/linux-patch-api-*.rpm"
|