Cible: Rocky Linux 9 (compatible RHEL/CentOS)
Changes:
- packaging/Dockerfile.rpm: Build pour Rocky Linux
- packaging/build-rpm.sh: Ajout paramètre distribution (rocky/rhel/centos)
- packaging/rpm/ja4sentinel.spec:
* Condition %if 0%{?rhel} >= 8 pour compatibilité RHEL
* Description mise à jour avec Rocky Linux
- packaging/test/Dockerfile.rpm: Test sur Rocky Linux 9
- packaging/test/test-*.sh: Tests spécifiques Rocky Linux
- .github/workflows/build-rpm.yml:
* Nom du job: 'Build RPM Package (Rocky Linux)'
* TARGET_DIST: rockylinux:9
* Simplification du build via Docker
Documentation:
- README.md: Instructions d'installation pour .rpm (Rocky/RHEL) et .deb (Debian/Ubuntu)
- Remplacement des instructions de build par installation via packages
Compatibilité:
- Rocky Linux 8.x et 9.x
- RHEL 8.x et 9.x
- CentOS Stream 8 et 9
- AlmaLinux 8.x et 9.x
Co-authored-by: Qwen-Coder <qwen-coder@alibabacloud.com>
81 lines
2.5 KiB
Bash
Executable File
81 lines
2.5 KiB
Bash
Executable File
#!/bin/bash
|
|
# Build script for .rpm package
|
|
# Usage: ./build-rpm.sh [version] [architecture] [distribution]
|
|
# distribution: rocky, rhel, centos (default: rocky)
|
|
|
|
set -e
|
|
|
|
# Sanitize version for RPM package (must start with digit)
|
|
VERSION="${1:-1.0.0}"
|
|
ARCH="${2:-x86_64}"
|
|
DIST="${3:-rocky}"
|
|
PACKAGE_NAME="ja4sentinel"
|
|
|
|
# Convert git version to RPM-compatible format
|
|
if [[ "$VERSION" =~ ^[0-9]+\.[0-9]+\.[0-9]+ ]]; then
|
|
RPM_VERSION="$VERSION"
|
|
elif [[ "$VERSION" =~ ^v([0-9]+\.[0-9]+\.[0-9]+) ]]; then
|
|
RPM_VERSION="${BASH_REMATCH[1]}"
|
|
else
|
|
RPM_VERSION="0.0.0.${VERSION//[^a-zA-Z0-9.]/_}"
|
|
fi
|
|
|
|
echo "=== Building ${PACKAGE_NAME} ${RPM_VERSION} for ${DIST} (${ARCH}) ==="
|
|
|
|
# Directories
|
|
SCRIPT_DIR="$(cd "$(dirname "${BASH_SOURCE[0]}")" && pwd)"
|
|
PROJECT_ROOT="$(dirname "$SCRIPT_DIR")"
|
|
BUILD_DIR="${PROJECT_ROOT}/build/rpm"
|
|
RPMBUILD_DIR="${BUILD_DIR}/rpmbuild"
|
|
|
|
# Clean and create build directory
|
|
rm -rf "${BUILD_DIR}"
|
|
mkdir -p "${RPMBUILD_DIR}/BUILD"
|
|
mkdir -p "${RPMBUILD_DIR}/RPMS"
|
|
mkdir -p "${RPMBUILD_DIR}/SOURCES"
|
|
mkdir -p "${RPMBUILD_DIR}/SPECS"
|
|
mkdir -p "${RPMBUILD_DIR}/SRPMS"
|
|
|
|
# Copy binary (build if not exists)
|
|
if [ ! -f "${PROJECT_ROOT}/dist/ja4sentinel-linux-amd64" ]; then
|
|
echo "Building binary..."
|
|
cd "${PROJECT_ROOT}"
|
|
make build-linux
|
|
fi
|
|
cp "${PROJECT_ROOT}/dist/ja4sentinel-linux-amd64" "${RPMBUILD_DIR}/SOURCES/ja4sentinel"
|
|
chmod 755 "${RPMBUILD_DIR}/SOURCES/ja4sentinel"
|
|
|
|
# Copy systemd service
|
|
cp "${SCRIPT_DIR}/systemd/ja4sentinel.service" "${RPMBUILD_DIR}/SOURCES/ja4sentinel.service"
|
|
chmod 644 "${RPMBUILD_DIR}/SOURCES/ja4sentinel.service"
|
|
|
|
# Copy default config
|
|
cp "${SCRIPT_DIR}/systemd/config.yml" "${RPMBUILD_DIR}/SOURCES/config.yml"
|
|
chmod 640 "${RPMBUILD_DIR}/SOURCES/config.yml"
|
|
|
|
# Copy spec file and update version
|
|
sed "s/Version: .*/Version: ${RPM_VERSION}/" "${SCRIPT_DIR}/rpm/ja4sentinel.spec" > "${RPMBUILD_DIR}/SPECS/ja4sentinel.spec"
|
|
|
|
# Build the RPM package
|
|
echo "Building .rpm package..."
|
|
rpmbuild -bb \
|
|
--define "_topdir ${RPMBUILD_DIR}" \
|
|
--define "_arch ${ARCH}" \
|
|
"${RPMBUILD_DIR}/SPECS/ja4sentinel.spec"
|
|
|
|
# Copy RPM to build directory
|
|
find "${RPMBUILD_DIR}/RPMS" -name "*.rpm" -exec cp {} "${BUILD_DIR}/" \;
|
|
|
|
# Calculate checksum
|
|
cd "${BUILD_DIR}"
|
|
for rpm_file in *.rpm; do
|
|
if [ -f "$rpm_file" ]; then
|
|
sha256sum "$rpm_file" > "${rpm_file}.sha256"
|
|
fi
|
|
done
|
|
|
|
echo ""
|
|
echo "=== Build complete ==="
|
|
echo "Package: ${BUILD_DIR}/${PACKAGE_NAME}-${VERSION}-1.${ARCH}.rpm"
|
|
ls -la "${BUILD_DIR}"/*.rpm 2>/dev/null || true
|