Skip to content

Commit

Permalink
chore(ci): update workflow to package Snort 3 with dependencies into …
Browse files Browse the repository at this point in the history
…a single .deb file
  • Loading branch information
bengo237 committed Aug 26, 2024
1 parent a8c02a3 commit 67e3304
Show file tree
Hide file tree
Showing 2 changed files with 34 additions and 11 deletions.
3 changes: 2 additions & 1 deletion .github/workflows/package-snort.yml
Original file line number Diff line number Diff line change
Expand Up @@ -30,9 +30,10 @@ jobs:
- name: Build and Package Snort 3
run: |
ARCH=${{ matrix.arch }}
# Adjust the script path if necessary
bash ./scripts/snort3.sh
mkdir -p /work/packages/$ARCH
mv /work/*.deb /work/packages/$ARCH/
mv /work/snort-package.deb /work/packages/$ARCH/
- name: Upload packages
uses: actions/upload-artifact@v3
Expand Down
42 changes: 32 additions & 10 deletions scripts/snort3.sh
Original file line number Diff line number Diff line change
Expand Up @@ -44,7 +44,11 @@ sudo mv ~/go/bin/protoc-gen-go-grpc /usr/local/bin/

# Create working directories
WORK_DIR=/work
PACKAGE_DIR=~/snort_package
DEBIAN_DIR=$PACKAGE_DIR/DEBIAN
sudo mkdir -p $WORK_DIR
mkdir -p $PACKAGE_DIR
mkdir -p $DEBIAN_DIR
sudo chmod 777 $WORK_DIR

# Install libdaq
Expand All @@ -54,7 +58,7 @@ tar -xvf v${LIBDAQ_VERSION}.tar.gz
cd libdaq-${LIBDAQ_VERSION}
./bootstrap && ./configure && make
sudo checkinstall --pkgname=libdaq --pkgversion=${LIBDAQ_VERSION} --backup=no --deldoc=yes --fstrans=no --default
sudo mv libdaq_${LIBDAQ_VERSION}-1_amd64.deb $WORK_DIR
sudo mv libdaq_${LIBDAQ_VERSION}-1_amd64.deb $PACKAGE_DIR
cd $WORK_DIR
rm -rf v${LIBDAQ_VERSION}.tar.gz

Expand All @@ -64,7 +68,7 @@ tar -xvf libdnet-${LIBDNET_VERSION}.tar.gz
cd libdnet-libdnet-${LIBDNET_VERSION}
./configure && make
sudo checkinstall --pkgname=libdnet --pkgversion=${LIBDNET_VERSION} --backup=no --deldoc=yes --fstrans=no --default
sudo mv libdnet_${LIBDNET_VERSION}-1_amd64.deb $WORK_DIR
sudo mv libdnet_${LIBDNET_VERSION}-1_amd64.deb $PACKAGE_DIR
cd $WORK_DIR
rm -rf libdnet-${LIBDNET_VERSION} libdnet-${LIBDNET_VERSION}.tar.gz

Expand All @@ -74,7 +78,7 @@ tar -xvf flex-${FLEX_VERSION}.tar.gz
cd flex-${FLEX_VERSION}
./configure && make
sudo checkinstall --pkgname=flex --pkgversion=${FLEX_VERSION} --backup=no --deldoc=yes --fstrans=no --default
sudo mv flex_${FLEX_VERSION}-1_amd64.deb $WORK_DIR
sudo mv flex_${FLEX_VERSION}-1_amd64.deb $PACKAGE_DIR
cd $WORK_DIR
rm -rf flex-${FLEX_VERSION} flex-${FLEX_VERSION}.tar.gz

Expand All @@ -84,7 +88,7 @@ tar -xvf hwloc-${HWLOC_VERSION}.tar.gz
cd hwloc-${HWLOC_VERSION}
./configure && make
sudo checkinstall --pkgname=hwloc --pkgversion=${HWLOC_VERSION} --backup=no --deldoc=yes --fstrans=no --default
sudo mv hwloc_${HWLOC_VERSION}-1_amd64.deb $WORK_DIR
sudo mv hwloc_${HWLOC_VERSION}-1_amd64.deb $PACKAGE_DIR
cd $WORK_DIR
rm -rf hwloc-${HWLOC_VERSION} hwloc-${HWLOC_VERSION}.tar.gz

Expand All @@ -94,7 +98,7 @@ git clone https://luajit.org/git/luajit.git
cd luajit
make
sudo checkinstall --pkgname=luajit --pkgversion=2.1.0 --backup=no --deldoc=yes --fstrans=no --default
sudo mv luajit_2.1.0-1_amd64.deb $WORK_DIR
sudo mv luajit_2.1.0-1_amd64.deb $PACKAGE_DIR
cd $WORK_DIR
rm -rf luajit

Expand All @@ -104,7 +108,7 @@ tar -xvf pcre-${PCRE_VERSION}.tar.gz
cd pcre-${PCRE_VERSION}
./configure && make
sudo checkinstall --pkgname=pcre --pkgversion=${PCRE_VERSION} --backup=no --deldoc=yes --fstrans=no --default
sudo mv pcre_${PCRE_VERSION}-1_amd64.deb $WORK_DIR
sudo mv pcre_${PCRE_VERSION}-1_amd64.deb $PACKAGE_DIR
cd $WORK_DIR
rm -rf pcre-${PCRE_VERSION} pcre-${PCRE_VERSION}.tar.gz

Expand All @@ -114,7 +118,7 @@ tar -xvf zlib-${ZLIB_VERSION}.tar.gz
cd zlib-${ZLIB_VERSION}
./configure && make
sudo checkinstall --pkgname=zlib --pkgversion=${ZLIB_VERSION} --backup=no --deldoc=yes --fstrans=no --default
sudo mv zlib_${ZLIB_VERSION}-1_amd64.deb $WORK_DIR
sudo mv zlib_${ZLIB_VERSION}-1_amd64.deb $PACKAGE_DIR
cd $WORK_DIR
rm -rf zlib-${ZLIB_VERSION} zlib-${ZLIB_VERSION}.tar.gz

Expand All @@ -127,9 +131,27 @@ export my_path=/usr/local
cd build
make -j$(nproc)
sudo checkinstall --pkgname=snort3 --pkgversion=${SNORT_VER} --backup=no --deldoc=yes --fstrans=no --default


sudo mv snort3_${SNORT_VER}-1_amd64.deb $PACKAGE_DIR
cd $WORK_DIR
rm -rf snort3-${SNORT_VER} ${SNORT_VER}.tar.gz

echo "Snort 3 installation and packaging is complete."
# Create control file
cat <<EOF > $DEBIAN_DIR/control
Package: snort-package
Version: 1.0
Section: base
Priority: optional
Architecture: all
Depends: libdaq (>= ${LIBDAQ_VERSION}), libdnet (>= ${LIBDNET_VERSION}), flex (>= ${FLEX_VERSION}), hwloc (>= ${HWLOC_VERSION}), pcre (>= ${PCRE_VERSION}), zlib (>= ${ZLIB_VERSION})
Maintainer: Dylane Bengono <[email protected]>
Description: Snort package with dependencies
This package includes Snort and its required dependencies.
EOF

# Build the final package
dpkg-deb --build $PACKAGE_DIR

# Clean up
rm -rf $PACKAGE_DIR

echo "Snort package with dependencies is created successfully."

0 comments on commit 67e3304

Please sign in to comment.