From 82db92f344b98647d594d1528d391462bc917308 Mon Sep 17 00:00:00 2001 From: Pim van Pelt Date: Tue, 17 Jun 2025 00:22:01 +0200 Subject: [PATCH] Add an initial 'make pkg-deb' and debian/ control directory --- .gitignore | 10 ++++++++ Makefile | 20 ++++++++++++++++ debian/changelog | 8 +++++++ debian/control | 23 +++++++++++++++++++ debian/govpp-snmp-agentx.postrm.debhelper | 12 ++++++++++ debian/postinst | 28 +++++++++++++++++++++++ debian/prerm | 22 ++++++++++++++++++ debian/rules | 27 ++++++++++++++++++++++ 8 files changed, 150 insertions(+) create mode 100644 Makefile create mode 100644 debian/changelog create mode 100644 debian/control create mode 100644 debian/govpp-snmp-agentx.postrm.debhelper create mode 100755 debian/postinst create mode 100755 debian/prerm create mode 100755 debian/rules diff --git a/.gitignore b/.gitignore index 8a28538..57b69a5 100644 --- a/.gitignore +++ b/.gitignore @@ -1,2 +1,12 @@ govpp-snmp-agentx vppcfg.yaml + +# Debian packaging artifacts +debian/.debhelper/ +debian/.gocache/ +debian/go/ +debian/govpp-snmp-agentx/ +debian/files +debian/*.substvars +debian/debhelper-build-stamp +debian/*.debhelper diff --git a/Makefile b/Makefile new file mode 100644 index 0000000..53988f6 --- /dev/null +++ b/Makefile @@ -0,0 +1,20 @@ +.PHONY: build test clean pkg-deb + +# Build the govpp-snmp-agentx binary +build: + go build -o govpp-snmp-agentx . + +# Run all tests +test: + go test ./... + +# Clean build artifacts +clean: + rm -f govpp-snmp-agentx + [ -d debian/go ] && chmod -R +w debian/go || true + rm -rf debian/.debhelper debian/.gocache debian/go debian/govpp-snmp-agentx debian/files debian/*.substvars debian/debhelper-build-stamp + rm -f ../govpp-snmp-agentx_* + +# Build Debian package +pkg-deb: + fakeroot dpkg-buildpackage -us -uc -b diff --git a/debian/changelog b/debian/changelog new file mode 100644 index 0000000..6ab92c6 --- /dev/null +++ b/debian/changelog @@ -0,0 +1,8 @@ +govpp-snmp-agentx (1.0.0-1) bookworm; urgency=medium + + * Initial release + * SNMP AgentX daemon for VPP statistics + * Interface MIB support + * Systemd service integration + + -- Pim van Pelt Mon, 16 Jun 2025 00:00:00 +0000 diff --git a/debian/control b/debian/control new file mode 100644 index 0000000..ac39b9c --- /dev/null +++ b/debian/control @@ -0,0 +1,23 @@ +Source: govpp-snmp-agentx +Section: net +Priority: optional +Maintainer: Pim van Pelt +Build-Depends: debhelper-compat (= 13), golang-go (>= 1.21) +Standards-Version: 4.6.2 +Homepage: https://git.ipng.ch/ipng/govpp-agentx-snmp +Vcs-Git: https://git.ipng.ch/ipng/govpp-agentx-snmp +Vcs-Browser: https://git.ipng.ch/ipng/govpp-agentx-snmp + +Package: govpp-snmp-agentx +Architecture: any +Depends: ${misc:Depends}, ${shlibs:Depends}, snmp, snmpd, adduser +Description: GoVPP SNMP AgentX Daemon + A SNMP AgentX daemon that provides SNMP access to VPP (Vector Packet Processing) + statistics and interface information. This daemon acts as a subagent that + connects to the main SNMP daemon via the AgentX protocol. + . + Features: + - Interface MIB support + - VPP statistics exposure + - AgentX protocol implementation + - Systemd integration diff --git a/debian/govpp-snmp-agentx.postrm.debhelper b/debian/govpp-snmp-agentx.postrm.debhelper new file mode 100644 index 0000000..8c2757a --- /dev/null +++ b/debian/govpp-snmp-agentx.postrm.debhelper @@ -0,0 +1,12 @@ +# Automatically added by dh_installsystemd/13.11.4 +if [ "$1" = remove ] && [ -d /run/systemd/system ] ; then + systemctl --system daemon-reload >/dev/null || true +fi +# End automatically added section +# Automatically added by dh_installsystemd/13.11.4 +if [ "$1" = "purge" ]; then + if [ -x "/usr/bin/deb-systemd-helper" ]; then + deb-systemd-helper purge 'govpp-snmp-agentx.service' >/dev/null || true + fi +fi +# End automatically added section diff --git a/debian/postinst b/debian/postinst new file mode 100755 index 0000000..e67fdc2 --- /dev/null +++ b/debian/postinst @@ -0,0 +1,28 @@ +#!/bin/bash + +set -e + +case "$1" in + configure) + # Create agentx directories + mkdir -p /var/agentx/master + chown Debian-snmp:vpp /var/agentx /var/agentx/master + chmod 770 /var/agentx /var/agentx/master + + # Enable and start the service + systemctl daemon-reload + systemctl enable govpp-snmp-agentx.service + ;; + + abort-upgrade|abort-remove|abort-deconfigure) + ;; + + *) + echo "postinst called with unknown argument \`$1'" >&2 + exit 1 + ;; +esac + +#DEBHELPER# + +exit 0 diff --git a/debian/prerm b/debian/prerm new file mode 100755 index 0000000..8771633 --- /dev/null +++ b/debian/prerm @@ -0,0 +1,22 @@ +#!/bin/bash + +set -e + +case "$1" in + remove|upgrade|deconfigure) + systemctl stop govpp-snmp-agentx.service || true + systemctl disable govpp-snmp-agentx.service || true + ;; + + failed-upgrade) + ;; + + *) + echo "prerm called with unknown argument \`$1'" >&2 + exit 1 + ;; +esac + +#DEBHELPER# + +exit 0 \ No newline at end of file diff --git a/debian/rules b/debian/rules new file mode 100755 index 0000000..40dd549 --- /dev/null +++ b/debian/rules @@ -0,0 +1,27 @@ +#!/usr/bin/make -f + +export DH_VERBOSE = 1 +export GO111MODULE = on +export GOPROXY = direct +export GOCACHE = $(CURDIR)/debian/.gocache +export GOPATH = $(CURDIR)/debian/go + +%: + dh $@ + +override_dh_auto_build: + go build -v -ldflags="-s -w" -o govpp-snmp-agentx . + +override_dh_auto_install: + install -D -m 0755 govpp-snmp-agentx debian/govpp-snmp-agentx/usr/sbin/govpp-snmp-agentx + install -D -m 0644 govpp-snmp-agentx.service debian/govpp-snmp-agentx/lib/systemd/system/govpp-snmp-agentx.service + +override_dh_auto_configure: + # Skip auto configure + +override_dh_auto_test: + # Skip tests during packaging + +override_dh_auto_clean: + rm -f govpp-snmp-agentx + rm -rf debian/.gocache debian/go obj-* \ No newline at end of file