From 2206fa0eb3bd284449afcab2fb9eabffbf90652a Mon Sep 17 00:00:00 2001 From: Matthias Cramer Date: Fri, 21 Mar 2025 16:28:55 +0100 Subject: [PATCH] Debianization --- .gitignore | 4 +++- Makefile | 11 ++++++----- README.md | 9 +++++++++ debian/changelog | 11 +++++++++++ debian/control | 17 +++++++++++++++++ debian/copyright | 31 +++++++++++++++++++++++++++++++ debian/files | 3 +++ debian/install | 1 + debian/rules | 10 ++++++++++ 9 files changed, 91 insertions(+), 6 deletions(-) create mode 100644 debian/changelog create mode 100644 debian/control create mode 100644 debian/copyright create mode 100644 debian/files create mode 100644 debian/install create mode 100755 debian/rules diff --git a/.gitignore b/.gitignore index ff60ce3..824c89f 100644 --- a/.gitignore +++ b/.gitignore @@ -1,3 +1,5 @@ *~ *.o -pcapmirror \ No newline at end of file +pcapmirror +debian/debhelper-build-stamp +debian/pcapmirror.substvars diff --git a/Makefile b/Makefile index c496119..3484fd8 100644 --- a/Makefile +++ b/Makefile @@ -19,7 +19,7 @@ OBJS = $(SRCS:.c=.o) TARGET = pcapmirror # Installation directory -PREFIX = /usr/local +PREFIX = /usr # Default rule all: $(TARGET) @@ -34,16 +34,17 @@ $(TARGET): $(OBJS) # Clean up object files and executable clean: - rm -f $(OBJS) $(TARGET) + rm -f -f $(OBJS) $(TARGET) # Install the executable install: $(TARGET) - sudo install -D $(TARGET) $(PREFIX)/bin/$(TARGET) + mkdir -p $(DESTDIR)$(PREFIX)/bin + install -D $(TARGET) $(DESTDIR)$(PREFIX)/bin/$(TARGET) # Uninstall the executable uninstall: - sudo rm -f $(PREFIX)/bin/$(TARGET) + rm -f $(TARGET) $(DESTDIR)$(PREFIX)/bin/$(TARGET) # Run the executable (example) run: $(TARGET) - sudo ./$(TARGET) -i eth0 -f "tcp port 80" -v \ No newline at end of file + ./$(TARGET) -i eth0 -f "tcp port 80" -v diff --git a/README.md b/README.md index bae57be..871ceb5 100644 --- a/README.md +++ b/README.md @@ -55,5 +55,14 @@ On Fedora/CentOS/RHEL systems, you can install it using: ```bash sudo yum install libpcap-devel ``` +## Build debian package +If you have never built a debian pakage you probably need debhelper: +```bash +sudo apt-get install debhelper +``` +Then build the package with this command. +```bash +dpkg-buildpackage -uc -us +``` \ No newline at end of file diff --git a/debian/changelog b/debian/changelog new file mode 100644 index 0000000..9c132d1 --- /dev/null +++ b/debian/changelog @@ -0,0 +1,11 @@ +pcapmirror (0.2-1) unstable; urgency=medium + + * First Debian package + + -- Matthias Cramer Fri, 21 Mar 2025 16:00:05 +0100 + +pcapmirror (0.1-1) unstable; urgency=low + + * Initial release. + + -- Matthias Cramer Fri, 21 Mar 2025 15:41:17 +0100 diff --git a/debian/control b/debian/control new file mode 100644 index 0000000..f5bc20e --- /dev/null +++ b/debian/control @@ -0,0 +1,17 @@ +Source: pcapmirror +Section: net +Priority: optional +Maintainer: Matthias Cramer +Build-Depends: debhelper-compat (=13), libpcap-dev +Standards-Version: 4.5.0 +Homepage: https://git.freestone.net/cramer/pcapmirror + +Package: pcapmirror +Architecture: any +Depends: ${shlibs:Depends}, ${misc:Depends}, libpcap0.8 +Description: A simple packet mirroring tool using libpcap + pcapmirror is a command-line tool for capturing network traffic and + mirroring it to a remote destination using TZSP encapsulation. It + leverages the libpcap library for packet capture and provides options + for filtering traffic based on BPF syntax. This tool is useful for + network monitoring, intrusion detection, and remote packet analysis. \ No newline at end of file diff --git a/debian/copyright b/debian/copyright new file mode 100644 index 0000000..76a52a1 --- /dev/null +++ b/debian/copyright @@ -0,0 +1,31 @@ +Format: https://www.debian.org/doc/packaging-manuals/copyright-format/1.0/ +Upstream-Name: pcapmirror + +BSD 3-Clause License + +Copyright (c) 2025, Matthias Cramer, cramer@freestone.net + +Redistribution and use in source and binary forms, with or without +modification, are permitted provided that the following conditions are met: + +1. Redistributions of source code must retain the above copyright notice, this + list of conditions and the following disclaimer. + +2. Redistributions in binary form must reproduce the above copyright notice, + this list of conditions and the following disclaimer in the documentation + and/or other materials provided with the distribution. + +3. Neither the name of the copyright holder nor the names of its + contributors may be used to endorse or promote products derived from + this software without specific prior written permission. + +THIS SOFTWARE IS PROVIDED BY THE COPYRIGHT HOLDERS AND CONTRIBUTORS "AS IS" +AND ANY EXPRESS OR IMPLIED WARRANTIES, INCLUDING, BUT NOT LIMITED TO, THE +IMPLIED WARRANTIES OF MERCHANTABILITY AND FITNESS FOR A PARTICULAR PURPOSE ARE +DISCLAIMED. IN NO EVENT SHALL THE COPYRIGHT HOLDER OR CONTRIBUTORS BE LIABLE +FOR ANY DIRECT, INDIRECT, INCIDENTAL, SPECIAL, EXEMPLARY, OR CONSEQUENTIAL +DAMAGES (INCLUDING, BUT NOT LIMITED TO, PROCUREMENT OF SUBSTITUTE GOODS OR +SERVICES; LOSS OF USE, DATA, OR PROFITS; OR BUSINESS INTERRUPTION) HOWEVER +CAUSED AND ON ANY THEORY OF LIABILITY, WHETHER IN CONTRACT, STRICT LIABILITY, +OR TORT (INCLUDING NEGLIGENCE OR OTHERWISE) ARISING IN ANY WAY OUT OF THE USE +OF THIS SOFTWARE, EVEN IF ADVISED OF THE POSSIBILITY OF SUCH DAMAGE. diff --git a/debian/files b/debian/files new file mode 100644 index 0000000..32fdd01 --- /dev/null +++ b/debian/files @@ -0,0 +1,3 @@ +pcapmirror-dbgsym_0.2-1_amd64.deb debug optional automatic=yes +pcapmirror_0.2-1_amd64.buildinfo net optional +pcapmirror_0.2-1_amd64.deb net optional diff --git a/debian/install b/debian/install new file mode 100644 index 0000000..6fdfec3 --- /dev/null +++ b/debian/install @@ -0,0 +1 @@ +pcapmirror /usr/bin \ No newline at end of file diff --git a/debian/rules b/debian/rules new file mode 100755 index 0000000..41c4450 --- /dev/null +++ b/debian/rules @@ -0,0 +1,10 @@ +#!/usr/bin/make -f + +# See debhelper(7) (>= 13) for a description of compat levels. +# dh-sequence.mk is deprecated and is now integrated into dh. +export DEB_BUILD_MAINT_OPTIONS = hardening=+all + +%: + dh $@ + +