Skip to content

Commit

Permalink
chore: Refactor Snort package creation process
Browse files Browse the repository at this point in the history
  • Loading branch information
bengo237 committed Aug 27, 2024
1 parent 4ba566e commit bea11c3
Show file tree
Hide file tree
Showing 2 changed files with 49 additions and 1 deletion.
6 changes: 5 additions & 1 deletion .github/workflows/package-snort.yml
Original file line number Diff line number Diff line change
Expand Up @@ -27,13 +27,17 @@ jobs:
- name: Install dependencies
run: sudo apt-get update && sudo apt-get install -y git dpkg-dev

- name: Build and Package Snort 3
- name: Build Snort 3 and dependencies
run: |
ARCH=${{ matrix.arch }}
bash ./scripts/snort3.sh
mkdir -p /work/packages/$ARCH
mv /work/*.deb /work/packages/$ARCH/
- name: Package Snort 3 with dependencies
run: |
bash ./scripts/package_snort3.sh ${{ matrix.arch }}
- name: Upload packages
uses: actions/upload-artifact@v4
with:
Expand Down
44 changes: 44 additions & 0 deletions scripts/package_snort3.sh
Original file line number Diff line number Diff line change
@@ -0,0 +1,44 @@
#!/bin/bash

# Variables
PACKAGE_NAME="snort3-full"
VERSION="3.2.2.0-1"
ARCH=$1
WORK_DIR="/work"
DEBIAN_DIR="$WORK_DIR/$PACKAGE_NAME/DEBIAN"
INSTALL_DIR="$WORK_DIR/$PACKAGE_NAME/usr/local/snort"

# Create directory structure
mkdir -p "$DEBIAN_DIR"
mkdir -p "$INSTALL_DIR"

# Copy the .deb files into the installation directory
cp $WORK_DIR/*.deb "$INSTALL_DIR/"

# Create the control file
cat <<EOL > "$DEBIAN_DIR/control"
Package: $PACKAGE_NAME
Version: $VERSION
Section: base
Priority: optional
Architecture: $ARCH
Depends: flex (>= 2.6.4), libdaq (>= 3.0.15), luajit (>= 2.1.0), hwloc (>= 2.5.0), libdnet (>= 1.14), pcre (>= 8.45), zlib (>= 1.2.13)
Maintainer: Dylane Bengono <[email protected]>
Description: Snort 3 with all dependencies bundled
This package contains Snort 3 and all its dependencies.
EOL

# Add post-installation script to install dependencies
cat <<EOL > "$DEBIAN_DIR/postinst"
#!/bin/bash
dpkg -i /usr/local/snort/*.deb
apt-get install -f
EOL

chmod 755 "$DEBIAN_DIR/postinst"

# Build the .deb package
dpkg-deb --build "$WORK_DIR/$PACKAGE_NAME"

# Move the final .deb package to the output directory
mv "$WORK_DIR/${PACKAGE_NAME}.deb" "$WORK_DIR/packages/$ARCH/"

0 comments on commit bea11c3

Please sign in to comment.