opensnitch/utils/packaging/arch/PKGBUILD.in
trvon 60cd4311a8
build: daemon-only fork build + Arch packaging, kernel-matched eBPF
Add a daemon-only build path (no Python GUI) that builds the eBPF objects
against the running kernel's headers, deriving the BPF DataLayout from
clang and finalizing with opt; a structural unprivileged check target; an
install path that never clobbers existing units/config/rules; an Arch
PKGBUILD.in + prepare.sh and a test_install.sh harness. Document the
workflow and the event-loss diagnostics in README.md and ebpf_prog/README.
Gitignore the compiled ebpf_prog/*.o artifacts.

Co-Authored-By: Claude Opus 4.8 <noreply@anthropic.com>
2026-11-05 16:58:22 -07:00

57 lines
2.1 KiB
Text

# Render with prepare.sh; the local source archive is byte-checksummed.
pkgname=opensnitch-daemon-local
pkgver=1.9.0
pkgrel=1
pkgdesc='Local OpenSnitch daemon and eBPF objects, without the Python GUI'
arch=('x86_64')
url='https://github.com/trvon/opensnitch'
license=('GPL-3.0-only')
provides=("opensnitch-daemon=$pkgver")
conflicts=('opensnitch' 'opensnitch-git')
depends=('glibc' 'libnetfilter_queue' 'libnfnetlink' 'libmnl' 'iptables' 'nftables' 'systemd')
makedepends=('go' 'clang' 'llvm' 'binutils' 'linux-headers')
# Keep Go debugging/profiling information; strip BPF debug only with LLVM.
options=('!strip' '!debug')
backup=('etc/opensnitchd/default-config.json'
'etc/opensnitchd/system-fw.json'
'etc/opensnitchd/network_aliases.json'
'etc/opensnitchd/tasks/tasks.json'
'etc/opensnitchd/rules/000-allow-localhost.json'
'etc/opensnitchd/rules/000-allow-localhost6.json')
source=("opensnitch-native-$pkgver.tar.gz")
sha256sums=('@SOURCE_SHA256@')
prepare() {
cd "$srcdir/opensnitch-native/daemon"
# Explicit dependency bootstrap, separate from readonly compilation.
go mod download
}
build() {
cd "$srcdir/opensnitch-native"
local kver="${OPENSNITCH_KERNEL_VERSION:-$(uname -r)}"
local kdir="/usr/lib/modules/$kver/build"
test -d "$kdir"
make -j1 -C daemon
make -j1 ebpf KERNEL_VER="$kver" KERNEL_DIR="$kdir" KERNEL_HEADERS="$kdir"
}
check() {
cd "$srcdir/opensnitch-native"
sh utils/packaging/test_install.sh
}
package() {
cd "$srcdir/opensnitch-native"
local kver="${OPENSNITCH_KERNEL_VERSION:-$(uname -r)}"
local kdir="/usr/lib/modules/$kver/build"
make -j1 install-daemon DESTDIR="$pkgdir" PREFIX=/usr SYSTEMDUNITDIR=/usr/lib/systemd/system
make -j1 install-ebpf DESTDIR="$pkgdir" PREFIX=/usr \
KERNEL_VER="$kver" KERNEL_DIR="$kdir" KERNEL_HEADERS="$kdir"
local obj
for obj in "$pkgdir"/usr/lib/opensnitchd/ebpf/*.o; do
llvm-strip -g "$obj"
done
install -Dm644 BUILD_SOURCE.txt "$pkgdir/usr/share/doc/$pkgname/BUILD_SOURCE.txt"
install -Dm644 LICENSE "$pkgdir/usr/share/licenses/$pkgname/LICENSE"
}