diff --git a/.github/workflows/ppa.yml b/.github/workflows/ppa.yml new file mode 100644 index 0000000..e99f045 --- /dev/null +++ b/.github/workflows/ppa.yml @@ -0,0 +1,91 @@ +name: PPA Release + +on: + push: + tags: + - 'v*' + workflow_dispatch: + inputs: + series: + description: 'Ubuntu series to build for (comma-separated)' + required: false + default: 'noble,jammy' + +jobs: + build-and-upload: + runs-on: ubuntu-latest + strategy: + fail-fast: false + matrix: + series: ${{ fromJson(format('["{0}"]', join(inputs.series != '' && inputs.series || 'noble,jammy', '","'))) }} + env: + DEBFULLNAME: Xiaming Chen + DEBEMAIL: chenxm35@gmail.com + PPA_TARGET: ppa:caesar0301/ppa + steps: + - name: Checkout + uses: actions/checkout@v4 + with: + fetch-depth: 0 + + - name: Install build tools + run: | + sudo apt-get update + sudo apt-get install -y --no-install-recommends \ + devscripts debhelper dput \ + cmake pkg-config libpcap-dev + + - name: Setup GPG for non-interactive signing + env: + GPG_PRIVATE_KEY: ${{ secrets.GPG_PRIVATE_KEY }} + run: | + test -n "$GPG_PRIVATE_KEY" || { echo 'GPG_PRIVATE_KEY secret not set'; exit 1; } + mkdir -p ~/.gnupg + chmod 700 ~/.gnupg + printf 'pinentry-mode loopback\n' >> ~/.gnupg/gpg.conf + printf 'allow-loopback-pinentry\n' >> ~/.gnupg/gpg-agent.conf + gpgconf --kill gpg-agent || true + echo "$GPG_PRIVATE_KEY" | gpg --batch --import + echo "Imported keys:" && gpg --list-keys --keyid-format LONG + KEYID=$(gpg --list-keys --with-colons | awk -F: '/^pub/{print $5; exit}') + echo "DEBSIGN_KEYID=$KEYID" >> $GITHUB_ENV + + - name: Compute version from tag + id: ver + run: | + TAG_REF="${GITHUB_REF_NAME:-${GITHUB_REF##*/}}" + UPSTREAM="${TAG_REF#v}" + echo "upstream=$UPSTREAM" >> $GITHUB_OUTPUT + + - name: Update changelog for series + run: | + VERSION="${{ steps.ver.outputs.upstream }}-0ppa1~${{ matrix.series }}1" + dch --force-distribution -v "$VERSION" -D "${{ matrix.series }}" "Automated PPA release for ${{ matrix.series }} from tag v${{ steps.ver.outputs.upstream }}" + tail -n +1 debian/changelog + + - name: Build signed source package + env: + GPG_PASSPHRASE: ${{ secrets.GPG_PASSPHRASE }} + DEBSIGN_KEYID: ${{ env.DEBSIGN_KEYID }} + run: | + test -n "$DEBSIGN_KEYID" || { echo 'Missing DEBSIGN_KEYID'; exit 1; } + # debuild uses debsign -> gpg; force loopback pinentry to passphrase + export GPG_TTY=$(tty || true) + debuild -S -sa -k"$DEBSIGN_KEYID" -p"gpg --batch --yes --pinentry-mode loopback --passphrase $GPG_PASSPHRASE" + + - name: Upload to PPA + run: | + CHANGES_FILE=$(ls -1 ../pkt2flow_*~${{ matrix.series }}1_source.changes | tail -n1) + test -n "$CHANGES_FILE" || { echo 'No .changes found'; ls -l ..; exit 1; } + dput $PPA_TARGET "$CHANGES_FILE" + + - name: Upload source artifacts + uses: actions/upload-artifact@v4 + with: + name: ppa-source-${{ matrix.series }} + path: | + ../pkt2flow_*~${{ matrix.series }}1.dsc + ../pkt2flow_*~${{ matrix.series }}1_source.changes + ../pkt2flow_*~${{ matrix.series }}1.debian.tar.* + ../pkt2flow_*~${{ matrix.series }}1.orig.tar.* + if-no-files-found: warn diff --git a/CMakeLists.txt b/CMakeLists.txt index e82b2fb..1d28054 100644 --- a/CMakeLists.txt +++ b/CMakeLists.txt @@ -1,7 +1,7 @@ cmake_minimum_required(VERSION 3.16) project(pkt2flow - VERSION 1.2.0 + VERSION 1.4.1 DESCRIPTION "A simple utility to classify packets into flows" LANGUAGES C CXX) @@ -163,10 +163,12 @@ if(BUILD_TESTS) target_link_libraries(pkt2flow_tests pkt2flow_lib pkt2flow_test_lib) endif() -# Build example in examples/ -add_executable(example_pkt2flow examples/example_pkt2flow.c) -target_link_libraries(example_pkt2flow pkt2flow_lib) -target_include_directories(example_pkt2flow PRIVATE ${CMAKE_CURRENT_SOURCE_DIR}/include) +# Build example in examples/ only when tests and libs are built +if(BUILD_TESTS) + add_executable(example_pkt2flow examples/example_pkt2flow.c) + target_link_libraries(example_pkt2flow pkt2flow_lib) + target_include_directories(example_pkt2flow PRIVATE ${CMAKE_CURRENT_SOURCE_DIR}/include) +endif() # CPack configuration for packaging include(CPack) diff --git a/debian/changelog b/debian/changelog new file mode 100644 index 0000000..41eb3e3 --- /dev/null +++ b/debian/changelog @@ -0,0 +1,5 @@ +pkt2flow (1.2.0-0ppa1) noble; urgency=medium + + * Initial release for Ubuntu PPA. Build with CMake; tests disabled. + + -- Xiaming Chen Tue, 12 Aug 2025 00:00:00 +0000 diff --git a/debian/control b/debian/control new file mode 100644 index 0000000..c965419 --- /dev/null +++ b/debian/control @@ -0,0 +1,16 @@ +Source: pkt2flow +Section: utils +Priority: optional +Maintainer: Xiaming Chen +Build-Depends: debhelper-compat (= 13), cmake, pkg-config, libpcap-dev +Standards-Version: 4.6.2 +Homepage: https://github.com/caesar0301/pkt2flow +Rules-Requires-Root: no + +Package: pkt2flow +Architecture: any +Depends: ${shlibs:Depends}, ${misc:Depends} +Description: Split packets in pcap into per-flow pcaps + A simple utility that classifies packets into flows using the 4-tuple + (source IP, destination IP, source port, destination port) and writes each + flow to a separate pcap file. diff --git a/debian/copyright b/debian/copyright new file mode 100644 index 0000000..79c163f --- /dev/null +++ b/debian/copyright @@ -0,0 +1,24 @@ +Format: https://www.debian.org/doc/packaging-manuals/copyright-format/1.0/ +Upstream-Name: pkt2flow +Source: https://github.com/caesar0301/pkt2flow + +Files: * +Copyright: 2024-2025 Xiaming Chen +License: MIT + Permission is hereby granted, free of charge, to any person obtaining a copy + of this software and associated documentation files (the "Software"), to deal + in the Software without restriction, including without limitation the rights + to use, copy, modify, merge, publish, distribute, sublicense, and/or sell + copies of the Software, and to permit persons to whom the Software is + furnished to do so, subject to the following conditions: + . + The above copyright notice and this permission notice shall be included in + all copies or substantial portions of the Software. + . + THE SOFTWARE IS PROVIDED "AS IS", WITHOUT WARRANTY OF ANY KIND, EXPRESS OR + IMPLIED, INCLUDING BUT NOT LIMITED TO THE WARRANTIES OF MERCHANTABILITY, + FITNESS FOR A PARTICULAR PURPOSE AND NONINFRINGEMENT. IN NO EVENT SHALL THE + AUTHORS OR COPYRIGHT HOLDERS BE LIABLE FOR ANY CLAIM, DAMAGES OR OTHER + LIABILITY, WHETHER IN AN ACTION OF CONTRACT, TORT OR OTHERWISE, ARISING FROM, + OUT OF OR IN CONNECTION WITH THE SOFTWARE OR THE USE OR OTHER DEALINGS IN THE + SOFTWARE. diff --git a/debian/docs b/debian/docs new file mode 100644 index 0000000..b43bf86 --- /dev/null +++ b/debian/docs @@ -0,0 +1 @@ +README.md diff --git a/debian/pkt2flow.1 b/debian/pkt2flow.1 new file mode 100644 index 0000000..cc9659c --- /dev/null +++ b/debian/pkt2flow.1 @@ -0,0 +1,29 @@ +.TH pkt2flow 1 "August 2025" "pkt2flow 1.2.0" "User Commands" +.SH NAME +pkt2flow \- split packets in pcap into per-flow pcaps +.SH SYNOPSIS +.B pkt2flow +.RI [ options ] +.RI "pcapfile" +.SH DESCRIPTION +A simple utility to classify packets into flows using the 4-tuple +(source IP, destination IP, source port, destination port) and write each +flow to a separate pcap file. +.SH OPTIONS +.TP +.B -h +Print help and exit. +.TP +.B -u +Also dump UDP flows. +.TP +.B -v +Also dump invalid TCP flows without the SYN option. +.TP +.B -x +Also dump non-UDP/non-TCP IP flows. +.TP +.B -o DIR +Output directory. +.SH AUTHOR +Xiaming Chen diff --git a/debian/pkt2flow.manpages b/debian/pkt2flow.manpages new file mode 100644 index 0000000..b07c66b --- /dev/null +++ b/debian/pkt2flow.manpages @@ -0,0 +1 @@ +debian/pkt2flow.1 diff --git a/debian/rules b/debian/rules new file mode 100755 index 0000000..ddc2229 --- /dev/null +++ b/debian/rules @@ -0,0 +1,12 @@ +#!/usr/bin/make -f +export DH_VERBOSE = 1 + +%: + dh $@ --buildsystem=cmake + +override_dh_auto_configure: + dh_auto_configure -- -DCMAKE_BUILD_TYPE=Release -DBUILD_TESTS=OFF + +# No tests during package build +override_dh_auto_test: + true diff --git a/debian/source/format b/debian/source/format new file mode 100644 index 0000000..163aaf8 --- /dev/null +++ b/debian/source/format @@ -0,0 +1 @@ +3.0 (quilt) diff --git a/debian/watch b/debian/watch new file mode 100644 index 0000000..17d8ff2 --- /dev/null +++ b/debian/watch @@ -0,0 +1,3 @@ +version=4 +opts=filenamemangle=s/.+\/v?(\d\S*)\.tar\.gz/pkt2flow-$1.tar.gz/ \ + https://github.com/caesar0301/pkt2flow/tags .*/archive/.+\.tar\.gz