feat: generate RPM packages for CentOS 7, Rocky Linux 8/9/10
Some checks failed
Build RPM Package / Build RPM Package (Rocky Linux) (push) Has been cancelled
Build DEB Package / Build DEB Package (Debian/Ubuntu) (push) Has been cancelled

- Update Dockerfile.package to build RPMs for multiple distributions
  using a unified fpm-based approach
- Add RPM maintainer scripts (postinst, prerm, postrm) for proper
  installation and service management
- Update ja4sentinel.spec for CentOS 7+ compatibility
- Add packaging/systemd/config.yml as default configuration
- Update test-rpm.sh to test installation on all 4 target distributions
- Fix CentOS 7 repository configuration (EOL - vault.centos.org)

Generated RPMs:
- el7: CentOS 7 (libpcap >= 1.4.0)
- el8: Rocky Linux 8 (libpcap >= 1.9.0)
- el9: Rocky Linux 9 (libpcap >= 1.9.0)
- el10: AlmaLinux 10 / Rocky Linux 10 (libpcap >= 1.9.0)

Co-authored-by: Qwen-Coder <qwen-coder@alibabacloud.com>
This commit is contained in:
Jacquin Antoine
2026-02-28 17:02:58 +01:00
parent 27eaa8aa4c
commit 86649b1630
8 changed files with 369 additions and 65 deletions

View File

@ -6,11 +6,13 @@ License: MIT
URL: https://github.com/your-repo/ja4sentinel
BuildArch: x86_64
# Rocky Linux / RHEL compatibility
# Requires EPEL for some dependencies if not in base repos
# Distribution-agnostic dependencies
# systemd is available on all target distros (CentOS 7, Rocky 8/9/10)
Requires: systemd
# libpcap is available in base repos for RHEL/CentOS/Rocky 8+
Requires: libpcap >= 1.9.0
# libpcap version varies by distro:
# - CentOS 7: 1.4.0
# - Rocky 8/9/10: 1.9.0+
Requires: libpcap >= 1.4.0
%description
JA4Sentinel is a Go-based tool for capturing network traffic on Linux servers,
@ -24,7 +26,7 @@ Features:
- IP/TCP metadata enrichment
- Multiple output formats (stdout, file, UNIX socket)
- Structured JSON logging for systemd/journald
- Compatible with Rocky Linux, RHEL, CentOS
- Compatible with CentOS 7, Rocky Linux 8/9/10, RHEL
%prep
# No source to unpack, binary is pre-built
@ -52,6 +54,7 @@ install -m 640 %{_sourcedir}/config.yml %{buildroot}/etc/ja4sentinel/config.yml.
install -m 640 %{_sourcedir}/config.yml %{buildroot}/usr/share/ja4sentinel/config.yml
%pre
# Create system user and group (compatible with CentOS 7+)
getent group ja4sentinel >/dev/null || groupadd -r ja4sentinel
getent passwd ja4sentinel >/dev/null || \
useradd -r -g ja4sentinel -d /var/lib/ja4sentinel -s /sbin/nologin \
@ -77,19 +80,19 @@ if [ ! -f /etc/ja4sentinel/config.yml ]; then
chmod 640 /etc/ja4sentinel/config.yml
fi
# Enable service
# Enable and start service (systemd macro for compatibility)
if [ $1 -eq 1 ] && [ -x /bin/systemctl ]; then
/bin/systemctl daemon-reload
/bin/systemctl enable ja4sentinel.service
/bin/systemctl start ja4sentinel.service
/bin/systemctl enable ja4sentinel.service 2>/dev/null || :
/bin/systemctl start ja4sentinel.service 2>/dev/null || :
fi
%preun
if [ $1 -eq 0 ]; then
# Package removal, stop and disable service
if [ -x /bin/systemctl ]; then
/bin/systemctl stop ja4sentinel.service >/dev/null 2>&1 || true
/bin/systemctl disable ja4sentinel.service >/dev/null 2>&1 || true
/bin/systemctl stop ja4sentinel.service >/dev/null 2>&1 || :
/bin/systemctl disable ja4sentinel.service >/dev/null 2>&1 || :
fi
fi
@ -113,4 +116,4 @@ fi
%changelog
* Wed Feb 25 2026 JA4Sentinel Team <team@example.com> - 1.0.0-1
- Initial package release
- Initial package release for CentOS 7, Rocky Linux 8/9/10

45
packaging/rpm/postinst Normal file
View File

@ -0,0 +1,45 @@
#!/bin/bash
#
# postinst - Script d'installation post-RPM pour ja4sentinel
# Compatible CentOS 7, Rocky Linux 8/9/10
#
set -e
echo "==> ja4sentinel: Running post-installation script..."
# Set proper ownership
chown -R ja4sentinel:ja4sentinel /var/lib/ja4sentinel 2>/dev/null || true
chown -R ja4sentinel:ja4sentinel /var/run/ja4sentinel 2>/dev/null || true
chown -R ja4sentinel:ja4sentinel /var/log/ja4sentinel 2>/dev/null || true
chown -R ja4sentinel:ja4sentinel /etc/ja4sentinel 2>/dev/null || true
# Set proper permissions
chmod 750 /var/lib/ja4sentinel 2>/dev/null || true
chmod 750 /var/log/ja4sentinel 2>/dev/null || true
chmod 750 /etc/ja4sentinel 2>/dev/null || true
# Install config if not exists
if [ ! -f /etc/ja4sentinel/config.yml ]; then
echo "==> ja4sentinel: Installing default configuration..."
cp /usr/share/ja4sentinel/config.yml /etc/ja4sentinel/config.yml
chown ja4sentinel:ja4sentinel /etc/ja4sentinel/config.yml 2>/dev/null || true
chmod 640 /etc/ja4sentinel/config.yml
fi
# Reload systemd and enable service (only if systemd is running)
if [ -x /bin/systemctl ] && [ -d /run/systemd/system ]; then
echo "==> ja4sentinel: Reloading systemd daemon..."
/bin/systemctl daemon-reload
echo "==> ja4sentinel: Enabling ja4sentinel.service..."
/bin/systemctl enable ja4sentinel.service 2>/dev/null || :
echo "==> ja4sentinel: Starting ja4sentinel.service..."
/bin/systemctl start ja4sentinel.service 2>/dev/null || :
else
echo "==> ja4sentinel: systemd not detected (container environment), skipping service management..."
fi
echo "==> ja4sentinel: Post-installation complete."
exit 0

18
packaging/rpm/postrm Normal file
View File

@ -0,0 +1,18 @@
#!/bin/bash
#
# postrm - Script de post-désinstallation RPM pour ja4sentinel
# Compatible CentOS 7, Rocky Linux 8/9/10
#
set -e
echo "==> ja4sentinel: Running post-removal script..."
# Reload systemd after removal
if [ -x /bin/systemctl ]; then
echo "==> ja4sentinel: Reloading systemd daemon..."
/bin/systemctl daemon-reload
fi
echo "==> ja4sentinel: Post-removal complete."
exit 0

21
packaging/rpm/prerm Normal file
View File

@ -0,0 +1,21 @@
#!/bin/bash
#
# prerm - Script de pré-désinstallation RPM pour ja4sentinel
# Compatible CentOS 7, Rocky Linux 8/9/10
#
set -e
echo "==> ja4sentinel: Running pre-removal script..."
# Stop and disable service before removal
if [ -x /bin/systemctl ]; then
echo "==> ja4sentinel: Stopping ja4sentinel.service..."
/bin/systemctl stop ja4sentinel.service >/dev/null 2>&1 || :
echo "==> ja4sentinel: Disabling ja4sentinel.service..."
/bin/systemctl disable ja4sentinel.service >/dev/null 2>&1 || :
fi
echo "==> ja4sentinel: Pre-removal complete."
exit 0