Skip to content

Commit 3c4d5e4

Browse files
authored
Add Ubuntu PPA packaging support (#47)
Adds Ubuntu PPA packaging with automated GitHub Actions workflow. - Debian packaging files in debian/ directory - GitHub Actions workflow for automated PPA uploads - Targets Ubuntu Questing (25.10) with Rust 1.88
1 parent a2b2e09 commit 3c4d5e4

8 files changed

Lines changed: 169 additions & 54 deletions

File tree

‎.github/workflows/ppa-release.yml‎

Lines changed: 74 additions & 37 deletions
Original file line numberDiff line numberDiff line change
@@ -6,11 +6,16 @@ on:
66
ubuntu_release:
77
description: 'Ubuntu release codename'
88
required: true
9-
default: 'noble'
9+
default: 'oracular'
1010
type: choice
1111
options:
12-
- noble # 24.04 LTS
13-
- jammy # 22.04 LTS
12+
- oracular # 24.10 with Rust 1.81
13+
- noble # 24.04 LTS with Rust 1.82
14+
tarball_suffix:
15+
description: 'Tarball suffix (e.g., ds1, ds2) - leave empty for new releases'
16+
required: false
17+
default: ''
18+
type: string
1419
push:
1520
tags:
1621
- 'v*'
@@ -22,12 +27,11 @@ env:
2227

2328
jobs:
2429
build-and-upload:
25-
runs-on: ubuntu-22.04
30+
runs-on: ubuntu-24.04
2631
strategy:
2732
matrix:
2833
ubuntu_release:
29-
- noble
30-
- jammy
34+
- questing
3135

3236
steps:
3337
- name: Checkout code
@@ -67,58 +71,91 @@ jobs:
6771
id: version
6872
run: |
6973
VERSION=$(grep '^version = ' Cargo.toml | head -1 | sed 's/version = "\(.*\)"/\1/')
70-
echo "version=$VERSION" >> $GITHUB_OUTPUT
7174
72-
# Set debian revision
73-
if [ "${{ matrix.ubuntu_release }}" = "noble" ]; then
74-
DEBIAN_REVISION="1ubuntu1"
75+
# Add tarball suffix if provided (e.g., +ds1, +ds2)
76+
TARBALL_SUFFIX="${{ github.event.inputs.tarball_suffix }}"
77+
if [ -n "$TARBALL_SUFFIX" ]; then
78+
TARBALL_VERSION="${VERSION}+${TARBALL_SUFFIX}"
79+
echo "version=$TARBALL_VERSION" >> $GITHUB_OUTPUT
80+
echo "Using tarball version: $TARBALL_VERSION"
7581
else
76-
DEBIAN_REVISION="1ubuntu1~${{ matrix.ubuntu_release }}1"
82+
echo "version=$VERSION" >> $GITHUB_OUTPUT
83+
echo "Using version: $VERSION"
7784
fi
85+
86+
# Extract Debian revision from changelog
87+
DEBIAN_REVISION=$(head -1 debian/changelog | sed 's/.*(\(.*\)-\(.*\)).*/\2/')
7888
echo "debian_revision=$DEBIAN_REVISION" >> $GITHUB_OUTPUT
7989
80-
- name: Update debian/changelog
90+
- name: Update changelog
8191
run: |
82-
cd debian
83-
84-
# Update distribution
85-
sed -i "s/) noble;/) ${{ matrix.ubuntu_release }};/" changelog
86-
87-
# For jammy, add backport entry
88-
if [ "${{ matrix.ubuntu_release }}" = "jammy" ]; then
89-
VERSION="${{ steps.version.outputs.version }}"
90-
REVISION="${{ steps.version.outputs.debian_revision }}"
91-
TIMESTAMP=$(date -R)
92-
93-
echo "rustnet-monitor ($VERSION-$REVISION) jammy; urgency=medium" > changelog.new
94-
echo "" >> changelog.new
95-
echo " * Backport to Ubuntu 22.04 Jammy" >> changelog.new
96-
echo "" >> changelog.new
97-
echo " -- Marco Cadetg <cadetg@gmail.com> $TIMESTAMP" >> changelog.new
98-
echo "" >> changelog.new
99-
cat changelog >> changelog.new
100-
mv changelog.new changelog
92+
VERSION="${{ steps.version.outputs.version }}"
93+
CURRENT_VERSION=$(head -1 debian/changelog | sed 's/.*(\(.*\)).*/\1/')
94+
95+
if [ "$VERSION-1ubuntu1" != "$CURRENT_VERSION" ]; then
96+
echo "Updating changelog from $CURRENT_VERSION to $VERSION-1ubuntu1"
97+
98+
# Create new changelog entry
99+
DEBFULLNAME="${{ env.DEBFULLNAME }}" DEBEMAIL="${{ env.DEBEMAIL }}" \
100+
dch --newversion "$VERSION-1ubuntu1" \
101+
--distribution "questing" \
102+
"New upstream release $VERSION"
103+
104+
echo "✓ Changelog updated"
105+
else
106+
echo "✓ Changelog already at correct version"
101107
fi
102108
103109
- name: Build source package
104110
run: |
105111
VERSION="${{ steps.version.outputs.version }}"
112+
BASE_VERSION=$(grep '^version = ' Cargo.toml | head -1 | sed 's/version = "\(.*\)"/\1/')
106113
PACKAGE_NAME="rustnet-monitor"
107114
108115
# Create build directory
109116
mkdir -p build-ppa
110117
111-
# Create orig tarball
112-
git archive --format=tar.gz --prefix="${PACKAGE_NAME}-${VERSION}/" HEAD \
113-
> "build-ppa/${PACKAGE_NAME}_${VERSION}.orig.tar.gz"
118+
# Extract source from release tag
119+
RELEASE_TAG="v${BASE_VERSION}"
120+
if git rev-parse "$RELEASE_TAG" >/dev/null 2>&1; then
121+
echo "✓ Found release tag: $RELEASE_TAG"
122+
git archive --format=tar --prefix="${PACKAGE_NAME}-${VERSION}/" "$RELEASE_TAG" | tar -x -C build-ppa
123+
else
124+
echo "⚠ Release tag $RELEASE_TAG not found, using HEAD"
125+
git archive --format=tar --prefix="${PACKAGE_NAME}-${VERSION}/" HEAD | tar -x -C build-ppa
126+
fi
114127
115-
# Extract and add debian directory
116-
cd build-ppa
117-
tar -xzf "${PACKAGE_NAME}_${VERSION}.orig.tar.gz"
128+
# Vendor dependencies separately from orig tarball
129+
echo "Vendoring Rust dependencies..."
130+
cd build-ppa/${PACKAGE_NAME}-${VERSION}
131+
132+
cargo vendor vendor
133+
134+
# Remove prebuilt static libraries (keep .dll for tests)
135+
echo "Cleaning vendor directory..."
136+
find vendor -name "*.a" -delete
137+
find vendor -name "*.lib" -delete
138+
139+
# Pack vendor directory as separate tarball in debian/
140+
echo "Creating vendor tarball..."
141+
tar -cJf ../vendor.tar.xz vendor
142+
rm -rf vendor
143+
144+
# Create orig tarball (without vendor directory)
145+
echo "Creating orig tarball..."
146+
cd ..
147+
ORIG_TARBALL="${PACKAGE_NAME}_${VERSION}.orig.tar.gz"
148+
tar -czf "${ORIG_TARBALL}" "${PACKAGE_NAME}-${VERSION}"
149+
150+
# Add debian directory and vendor tarball
118151
cp -r "$GITHUB_WORKSPACE/debian" "${PACKAGE_NAME}-${VERSION}/"
152+
mv vendor.tar.xz "${PACKAGE_NAME}-${VERSION}/debian/"
119153
120154
# Build source package
121155
cd "${PACKAGE_NAME}-${VERSION}"
156+
157+
# Always use -sa to include orig tarball
158+
# Launchpad will reuse existing file if hash matches
122159
debuild -S -sa -d -us -uc
123160
124161
- name: Sign and upload

‎debian/README.md‎

Lines changed: 2 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -11,7 +11,7 @@ git tag v0.15.0
1111
git push origin v0.15.0
1212
```
1313

14-
This automatically builds and uploads to both Ubuntu 22.04 (Jammy) and 24.04 (Noble).
14+
This automatically builds and uploads to Ubuntu 25.04 (Questing) which has Rust 1.85 for edition 2024 support.
1515

1616
## GitHub Secrets Setup
1717

@@ -49,7 +49,7 @@ sudo apt install rustnet
4949
- **Binary**: rustnet
5050
- **Maintainer**: Marco Cadetg <cadetg@gmail.com>
5151
- **PPA**: https://launchpad.net/~domcyrus/+archive/ubuntu/rustnet
52-
- **Supported**: Ubuntu 22.04 LTS, 24.04 LTS
52+
- **Supported**: Ubuntu 24.04 LTS (Noble) and later
5353
- **Architectures**: amd64, arm64, armhf
5454

5555
## Workflow

‎debian/cargo.config‎

Lines changed: 5 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,5 @@
1+
[source.crates-io]
2+
replace-with = "vendored-sources"
3+
4+
[source.vendored-sources]
5+
directory = "vendor"

‎debian/changelog‎

Lines changed: 6 additions & 7 deletions
Original file line numberDiff line numberDiff line change
@@ -1,14 +1,13 @@
1-
rustnet-monitor (0.14.0-1ubuntu1) noble; urgency=medium
1+
rustnet-monitor (0.14.0+ds6-1ubuntu1) questing; urgency=medium
22

3-
* Initial Ubuntu PPA release
3+
* Refactored packaging with vendored dependencies in debian/vendor.tar.xz
4+
* Target Ubuntu Questing (25.10) with Rust 1.88 for edition 2024 support
5+
* Use versioned cargo-1.88 and rustc-1.88 packages
46
* eBPF enabled by default on Linux with automatic procfs fallback
57
* JSON logging for SIEM integration
68
* TUN/TAP interface support for VPN monitoring
7-
* Multi-architecture support (amd64, arm64, armhf)
8-
* Desktop integration with .desktop file and icon
9-
* Automatic capability setting for non-root packet capture
109

11-
-- Marco Cadetg <domcyrus@example.com> Mon, 13 Oct 2025 12:00:00 +0000
10+
-- Marco Cadetg <cadetg@gmail.com> Mon, 13 Oct 2025 21:32:00 +0000
1211

1312
rustnet-monitor (0.14.0-1) unstable; urgency=medium
1413

@@ -20,4 +19,4 @@ rustnet-monitor (0.14.0-1) unstable; urgency=medium
2019
* Fixed high CPU usage on Linux
2120
* Bundled vmlinux.h files to eliminate network dependency during builds
2221

23-
-- Marco Cadetg <domcyrus@example.com> Sat, 12 Oct 2025 00:00:00 +0000
22+
-- Marco Cadetg <cadetg@gmail.com> Sat, 12 Oct 2025 00:00:00 +0000

‎debian/control‎

Lines changed: 2 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -3,8 +3,8 @@ Section: net
33
Priority: optional
44
Maintainer: Marco Cadetg <domcyrus@example.com>
55
Build-Depends: debhelper-compat (= 13),
6-
cargo,
7-
rustc,
6+
cargo-1.88,
7+
rustc-1.88,
88
libpcap-dev,
99
libelf-dev,
1010
elfutils,

‎debian/rules‎

Lines changed: 13 additions & 6 deletions
Original file line numberDiff line numberDiff line change
@@ -3,8 +3,10 @@
33
export DH_VERBOSE = 1
44
export RUSTFLAGS = -C strip=symbols
55

6-
# Use rustup-installed cargo/rustc instead of system version
7-
export PATH := $(HOME)/.cargo/bin:$(PATH)
6+
# Use versioned Rust 1.88 from Ubuntu Questing
7+
export CARGO = /usr/bin/cargo-1.88
8+
export RUSTC = /usr/bin/rustc-1.88
9+
export RUSTDOC = /usr/bin/rustdoc-1.88
810

911
# eBPF is enabled by default, no need for explicit feature flag
1012
export CARGO_BUILD_FLAGS = --release
@@ -16,14 +18,19 @@ export RUSTNET_ASSET_DIR = $(CURDIR)/debian/tmp/assets
1618
dh $@
1719

1820
override_dh_auto_clean:
19-
# Use rustup cargo for clean
20-
[ ! -f Cargo.toml ] || cargo clean || true
21+
$(CARGO) clean || true
22+
rm -rf target vendor .cargo
2123

2224
override_dh_auto_build:
25+
# Setup cargo to use vendored dependencies
26+
mkdir -p .cargo
27+
cp debian/cargo.config .cargo/config.toml
28+
# Extract vendored dependencies
29+
tar xJf debian/vendor.tar.xz
2330
# Create asset directory for build.rs
2431
mkdir -p $(RUSTNET_ASSET_DIR)
25-
# Build with rustup cargo (supports edition 2024)
26-
cargo build --release --verbose
32+
# Build with cargo-1.88 using vendored dependencies
33+
$(CARGO) build --release --frozen
2734

2835
override_dh_auto_install:
2936
# Install binary

‎debian/source/include-binaries‎

Lines changed: 1 addition & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1 @@
1+
debian/vendor.tar.xz

‎scripts/test-deb-build.sh‎

Lines changed: 66 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,66 @@
1+
#!/bin/bash
2+
set -e
3+
4+
UBUNTU_RELEASE=${1:-noble}
5+
SCRIPT_DIR="$(cd "$(dirname "${BASH_SOURCE[0]}")" && pwd)"
6+
PROJECT_DIR="$(dirname "$SCRIPT_DIR")"
7+
8+
echo "Testing Debian package build for Ubuntu $UBUNTU_RELEASE"
9+
echo "=================================================="
10+
11+
# Build the Docker container
12+
docker build -t rustnet-deb-test:$UBUNTU_RELEASE -f - "$PROJECT_DIR" <<EOF
13+
FROM ubuntu:$UBUNTU_RELEASE
14+
15+
# Install build dependencies
16+
RUN apt-get update && apt-get install -y \\
17+
debhelper \\
18+
devscripts \\
19+
dpkg-dev \\
20+
rustup \\
21+
libpcap-dev \\
22+
libelf-dev \\
23+
elfutils \\
24+
zlib1g-dev \\
25+
clang \\
26+
llvm \\
27+
pkg-config \\
28+
lintian \\
29+
file
30+
31+
WORKDIR /build
32+
COPY . /build/
33+
34+
# Build the source package
35+
RUN echo "Building source package..." && \\
36+
debuild -S -sa -d -us -uc
37+
38+
# Build the binary package (simulates what Launchpad does)
39+
RUN echo "Building binary package..." && \\
40+
cd .. && \\
41+
dpkg-source -x rustnet-monitor_*.dsc extracted && \\
42+
cd extracted && \\
43+
dpkg-buildpackage -b -uc -us
44+
45+
# List the built packages
46+
RUN echo "Built packages:" && \\
47+
ls -lh /build/../*.deb || true
48+
49+
# Run lintian on the package
50+
RUN echo "Running lintian checks..." && \\
51+
lintian /build/../*.deb || true
52+
53+
# Test the package contents
54+
RUN echo "Package contents:" && \\
55+
dpkg-deb -c /build/../rustnet_*.deb
56+
57+
CMD ["/bin/bash"]
58+
EOF
59+
60+
echo ""
61+
echo "Build completed successfully!"
62+
echo ""
63+
echo "To extract the .deb file, run:"
64+
echo " docker create --name rustnet-deb-extract rustnet-deb-test:$UBUNTU_RELEASE"
65+
echo " docker cp rustnet-deb-extract:/build/../rustnet_*.deb ."
66+
echo " docker rm rustnet-deb-extract"

0 commit comments

Comments
 (0)