Files
ja4sentinel/packaging/test/test-deb.sh
Jacquin Antoine 61bf05454e feat: CI/CD pour packages .deb et .rpm + tests d'installation
Nouveaux workflows GitHub Actions:
- .github/workflows/build-deb.yml : Build et release DEB sur Ubuntu
- .github/workflows/build-rpm.yml : Build et release RPM sur Fedora
- Déclenchement sur tags v*, push main/master, workflow_dispatch
- Upload des artifacts et création automatique de release

Système de build de packages:
- packaging/build-deb.sh : Script de build .deb avec sanitization version
- packaging/build-rpm.sh : Script de build .rpm (via Docker)
- packaging/Dockerfile.deb : Container Ubuntu 22.04 pour build DEB
- packaging/Dockerfile.rpm : Container Go 1.24 + rpm pour build RPM

Fichiers de configuration systemd:
- packaging/systemd/ja4sentinel.service : Unit avec security hardening
  * NoNewPrivileges, ProtectSystem, ProtectHome
  * CAP_NET_RAW, CAP_NET_ADMIN pour packet capture
- packaging/systemd/config.yml : Configuration par défaut

Scripts mainteneur DEB:
- packaging/deb/postinst : Création user/group, dirs, config
- packaging/deb/prerm : Stop service avant upgrade/remove
- packaging/deb/postrm : Cleanup complet en purge

Spec file RPM:
- packaging/rpm/ja4sentinel.spec : Spec complet avec dependencies
  * Requires: systemd, libpcap
  * %pre/%post/%preun/%postun scripts

Tests d'installation dans containers:
- packaging/test/test-deb.sh : Build + test Docker Ubuntu
- packaging/test/test-rpm.sh : Build + test Docker Fedora
- packaging/test/test-install-deb.sh : 11 tests automatisés
- packaging/test/test-install-rpm.sh : 11 tests automatisés
- Dockerfile.deb/rpm : Containers de test dédiés

Makefile:
- package-deb : Build .deb
- package-rpm : Build .rpm via Docker (no-cache)
- package : Build les deux
- test-package-deb : Build + test installation DEB
- test-package-rpm : Build + test installation RPM
- test-package : Test les deux packages

Tests:
-  DEB: 11/11 tests passés (binaire, config, service, user, dirs)
-  RPM: Build réussi (3.3 MB)
- Version sanitization pour git tags (ex: efd4481-dirty → 0.0.0+efd4481-dirty)

Co-authored-by: Qwen-Coder <qwen-coder@alibabacloud.com>
2026-02-25 21:05:23 +01:00

44 lines
1.2 KiB
Bash
Executable File

#!/bin/bash
# Test DEB package installation in Docker container
set -e
SCRIPT_DIR="$(cd "$(dirname "${BASH_SOURCE[0]}")" && pwd)"
PROJECT_ROOT="$(dirname "$(dirname "$SCRIPT_DIR")")"
BUILD_DIR="${PROJECT_ROOT}/build/deb"
echo "=========================================="
echo " Testing DEB Package Installation"
echo "=========================================="
# Find the DEB package
DEB_PACKAGE=$(ls -1 "${BUILD_DIR}"/*.deb 2>/dev/null | head -1)
if [ -z "$DEB_PACKAGE" ]; then
echo "Error: No .deb package found in ${BUILD_DIR}"
echo "Run 'make package-deb' first"
exit 1
fi
echo "Found package: ${DEB_PACKAGE}"
# Copy package to test directory
cp "${DEB_PACKAGE}" "${SCRIPT_DIR}/"
# Build test image
echo "Building test Docker image..."
docker build -t ja4sentinel-test-deb \
-f "${SCRIPT_DIR}/Dockerfile.deb" \
"${SCRIPT_DIR}/"
# Run tests
echo ""
echo "Running installation tests..."
docker run --rm \
-v "${SCRIPT_DIR}/test-install-deb.sh:/test-install.sh:ro" \
ja4sentinel-test-deb \
/test-install.sh
echo ""
echo "=========================================="
echo " DEB Package Test Complete"
echo "=========================================="