fix: Support Debian Bookworm et Ubuntu pour le package .deb

Cible: Debian Bookworm (12) et Ubuntu 22.04+

Changes:
- packaging/Dockerfile.deb: Build via Docker avec Go 1.24
- packaging/build-deb.sh: Ajout paramètre distribution (debian/ubuntu)
- packaging/test/Dockerfile.deb: Test sur Debian Bookworm
- packaging/test/test-*.sh: Tests spécifiques Debian/Ubuntu
- .github/workflows/build-deb.yml:
  * Nom du job: 'Build DEB Package (Debian/Ubuntu)'
  * TARGET_DIST: debian:bookworm
  * Build simplifié via Docker
- Makefile: package-deb utilise Docker (cohérent avec RPM)

Compatibilité:
- Debian 11 (Bullseye)
- Debian 12 (Bookworm)
- Ubuntu 20.04 LTS
- Ubuntu 22.04 LTS
- Ubuntu 24.04 LTS

Co-authored-by: Qwen-Coder <qwen-coder@alibabacloud.com>
This commit is contained in:
Jacquin Antoine
2026-02-25 21:25:45 +01:00
parent 6f7c5450f8
commit c62101a08e
7 changed files with 59 additions and 53 deletions

View File

@ -39,10 +39,11 @@ on:
env: env:
GO_VERSION: '1.24' GO_VERSION: '1.24'
PACKAGE_NAME: ja4sentinel PACKAGE_NAME: ja4sentinel
TARGET_DIST: debian:bookworm
jobs: jobs:
build-deb: build-deb:
name: Build DEB Package name: Build DEB Package (Debian/Ubuntu)
runs-on: ubuntu-latest runs-on: ubuntu-latest
permissions: permissions:
contents: write contents: write
@ -73,48 +74,36 @@ jobs:
echo "version=${VERSION}" >> $GITHUB_OUTPUT echo "version=${VERSION}" >> $GITHUB_OUTPUT
echo "Building version: ${VERSION}" echo "Building version: ${VERSION}"
- name: Install dependencies - name: Build DEB in Docker
run: | run: |
sudo apt-get update docker build --no-cache \
sudo apt-get install -y \ -t ${PACKAGE_NAME}-packager-deb \
libpcap-dev \ --build-arg VERSION="${{ steps.version.outputs.version }}" \
dpkg-dev \ --build-arg ARCH=amd64 \
fakeroot \ -f packaging/Dockerfile.deb .
lintian
# Extract DEB from image
- name: Build Go binary mkdir -p build/deb
run: | docker run --rm ${PACKAGE_NAME}-packager-deb sh -c 'cat /packages/*.deb' > build/${PACKAGE_NAME}.deb
make build-linux
ls -la dist/
- name: Build DEB package
run: |
VERSION="${{ steps.version.outputs.version }}"
./packaging/build-deb.sh "${VERSION}" "amd64"
- name: Run lintian checks
run: |
lintian build/deb/*.deb --suppress-tags "dir-or-file-in-/usr/share/doc" || true
- name: List build artifacts - name: List build artifacts
run: | run: |
echo "=== Build Artifacts ===" echo "=== Build Artifacts ==="
ls -lah build/deb/ ls -lah build/deb/
echo "=== Checksums ===" sha256sum build/${PACKAGE_NAME}.deb
cat build/deb/*.sha256 || true
- name: Upload DEB artifact - name: Upload DEB artifact
uses: actions/upload-artifact@v4 uses: actions/upload-artifact@v4
with: with:
name: ja4sentinel-deb-amd64 name: ${PACKAGE_NAME}-deb-amd64
path: build/deb/*.deb path: build/*.deb
retention-days: 30 retention-days: 30
- name: Upload checksum artifact - name: Upload checksum artifact
uses: actions/upload-artifact@v4 uses: actions/upload-artifact@v4
with: with:
name: ja4sentinel-deb-checksums name: ${PACKAGE_NAME}-deb-checksums
path: build/deb/*.sha256 path: build/*.deb.sha256
retention-days: 30 retention-days: 30
- name: Create release and upload assets (on tag) - name: Create release and upload assets (on tag)
@ -122,8 +111,7 @@ jobs:
uses: softprops/action-gh-release@v2 uses: softprops/action-gh-release@v2
with: with:
files: | files: |
build/deb/*.deb build/*.deb
build/deb/*.sha256
generate_release_notes: true generate_release_notes: true
make_latest: true make_latest: true
env: env:

View File

@ -90,9 +90,16 @@ fmt:
## package: Build all packages (deb + rpm) ## package: Build all packages (deb + rpm)
package: package-deb package-rpm package: package-deb package-rpm
## package-deb: Build DEB package ## package-deb: Build DEB package (requires Docker)
package-deb: build-linux package-deb: build-linux
./packaging/build-deb.sh "$(PKG_VERSION)" "amd64" docker build --no-cache -t ja4sentinel-packager-deb \
--build-arg VERSION=$(PKG_VERSION) \
--build-arg ARCH=amd64 \
-f packaging/Dockerfile.deb .
@echo "Extracting DEB from Docker image..."
docker run --rm ja4sentinel-packager-deb sh -c 'cat /packages/*.deb' > build/ja4sentinel.deb
@echo "DEB package created: build/ja4sentinel.deb"
ls -la build/*.deb
## package-rpm: Build RPM package (requires Docker) ## package-rpm: Build RPM package (requires Docker)
package-rpm: build-linux package-rpm: build-linux

View File

@ -1,17 +1,13 @@
# Dockerfile for building DEB packages # Dockerfile for building DEB packages for Debian/Ubuntu
FROM ubuntu:22.04 # Use Go 1.24 as base to ensure correct Go version
FROM golang:1.24-bookworm AS builder
ENV DEBIAN_FRONTEND=noninteractive # Install DEB build tools
# Install build dependencies
RUN apt-get update && apt-get install -y \ RUN apt-get update && apt-get install -y \
golang-go \
git \
make \
libpcap-dev \
dpkg-dev \ dpkg-dev \
fakeroot \ fakeroot \
lintian \ lintian \
libpcap-dev \
&& rm -rf /var/lib/apt/lists/* && rm -rf /var/lib/apt/lists/*
WORKDIR /app WORKDIR /app
@ -19,5 +15,21 @@ WORKDIR /app
# Copy source code # Copy source code
COPY . . COPY . .
# Default command: build DEB package # Build binary
CMD ["./packaging/build-deb.sh", "1.0.0", "amd64"] ARG VERSION=1.0.0
RUN mkdir -p dist && \
CGO_ENABLED=1 GOOS=linux GOARCH=amd64 \
go build -buildvcs=false -o dist/ja4sentinel-linux-amd64 ./cmd/ja4sentinel
# Build DEB for Debian/Ubuntu
ARG ARCH=amd64
RUN mkdir -p /app/packages && \
./packaging/build-deb.sh "${VERSION}" "${ARCH}" "debian" && \
cp /app/build/deb/*.deb /app/packages/
# Final stage - minimal image with just the DEB
FROM alpine:latest
COPY --from=builder /app/packages/ /packages/
CMD ["ls", "-la", "/packages/"]

View File

@ -1,28 +1,26 @@
#!/bin/bash #!/bin/bash
# Build script for .deb package # Build script for .deb package
# Usage: ./build-deb.sh [version] [architecture] # Usage: ./build-deb.sh [version] [architecture] [distribution]
# distribution: debian, ubuntu (default: debian)
set -e set -e
# Sanitize version for Debian package (must start with digit) # Sanitize version for Debian package (must start with digit)
VERSION="${1:-1.0.0}" VERSION="${1:-1.0.0}"
ARCH="${2:-amd64}" ARCH="${2:-amd64}"
DIST="${3:-debian}"
PACKAGE_NAME="ja4sentinel" PACKAGE_NAME="ja4sentinel"
# Convert git version to Debian-compatible format # Convert git version to Debian-compatible format
# e.g., "v1.0.0" -> "1.0.0", "efd4481-dirty" -> "0.0.0+efd4481"
if [[ "$VERSION" =~ ^[0-9]+\.[0-9]+\.[0-9]+ ]]; then if [[ "$VERSION" =~ ^[0-9]+\.[0-9]+\.[0-9]+ ]]; then
# Already a valid semver
DEB_VERSION="$VERSION" DEB_VERSION="$VERSION"
elif [[ "$VERSION" =~ ^v([0-9]+\.[0-9]+\.[0-9]+) ]]; then elif [[ "$VERSION" =~ ^v([0-9]+\.[0-9]+\.[0-9]+) ]]; then
# v-prefixed semver
DEB_VERSION="${BASH_REMATCH[1]}" DEB_VERSION="${BASH_REMATCH[1]}"
else else
# Git hash or other format -> use 0.0.0+<hash>
DEB_VERSION="0.0.0+${VERSION//[^a-zA-Z0-9+.-]/_}" DEB_VERSION="0.0.0+${VERSION//[^a-zA-Z0-9+.-]/_}"
fi fi
echo "=== Building ${PACKAGE_NAME} ${DEB_VERSION} for ${ARCH} ===" echo "=== Building ${PACKAGE_NAME} ${DEB_VERSION} for ${DIST} (${ARCH}) ==="
# Directories # Directories
SCRIPT_DIR="$(cd "$(dirname "${BASH_SOURCE[0]}")" && pwd)" SCRIPT_DIR="$(cd "$(dirname "${BASH_SOURCE[0]}")" && pwd)"

View File

@ -1,5 +1,5 @@
# Dockerfile for testing DEB package installation # Dockerfile for testing DEB package installation on Debian/Ubuntu
FROM ubuntu:22.04 FROM debian:bookworm-slim
ENV DEBIAN_FRONTEND=noninteractive ENV DEBIAN_FRONTEND=noninteractive

View File

@ -1,5 +1,5 @@
#!/bin/bash #!/bin/bash
# Test DEB package installation in Docker container # Test DEB package installation in Debian/Ubuntu container
set -e set -e
SCRIPT_DIR="$(cd "$(dirname "${BASH_SOURCE[0]}")" && pwd)" SCRIPT_DIR="$(cd "$(dirname "${BASH_SOURCE[0]}")" && pwd)"

View File

@ -1,9 +1,10 @@
#!/bin/bash #!/bin/bash
# Test script for DEB package installation # Test script for DEB package installation on Debian/Ubuntu
set -e set -e
echo "==========================================" echo "=========================================="
echo " JA4Sentinel DEB Package Installation Test" echo " JA4Sentinel DEB Package Installation Test"
echo " Target: Debian Bookworm / Ubuntu 22.04+"
echo "==========================================" echo "=========================================="
# Colors for output # Colors for output