Rework build system; cut release 1.3.1-1
Replace the dpkg-buildpackage / debhelper rig with the same pattern
used in vpp-maglev: a Makefile that cross-compiles CGO-free static
binaries for amd64 and arm64, plus a debian/build-deb.sh that stages
the .deb directly with dpkg-deb. The two arch packages drop into
build/ and run on any glibc/musl Linux of the matching arch.
VERSION is parsed once from debian/changelog and injected at link
time via -ldflags "-X 'main.Version=...' -X 'main.Commit=...' -X
'main.Date=...'", so 'govpp-snmp-agentx --version' is the source of
truth for which build is running. main.go's Version constant becomes
a var to make this work; the old sync-version make target is gone.
Removes the now-unused debian/{control,rules,postinst,prerm,*.debhelper}
files and adds build/ to .gitignore.
Co-Authored-By: Claude Opus 4.7 (1M context) <noreply@anthropic.com>
This commit is contained in:
+42
@@ -0,0 +1,42 @@
|
||||
#!/bin/bash
|
||||
# SPDX-License-Identifier: Apache-2.0
|
||||
# Build one govpp-snmp-agentx .deb for one architecture.
|
||||
# Usage: build-deb.sh <package> <amd64|arm64> <version>
|
||||
#
|
||||
# The version is also baked into the binary at link time (see Makefile
|
||||
# LDFLAGS), so `govpp-snmp-agentx --version` is the source of truth for
|
||||
# "which build". The .deb itself only carries the release version.
|
||||
set -euo pipefail
|
||||
|
||||
PACKAGE="${1:?usage: build-deb.sh <package> <amd64|arm64> <version>}"
|
||||
ARCH="${2:?usage: build-deb.sh <package> <amd64|arm64> <version>}"
|
||||
VERSION="${3:?usage: build-deb.sh <package> <amd64|arm64> <version>}"
|
||||
|
||||
REPO_ROOT="$(cd "$(dirname "$0")/.." && pwd)"
|
||||
PKG="${PACKAGE}_${VERSION}_${ARCH}"
|
||||
STAGING="$(mktemp -d)"
|
||||
trap 'rm -rf "$STAGING"' EXIT
|
||||
|
||||
echo "Building ${PKG}.deb"
|
||||
|
||||
install -d "$STAGING/DEBIAN"
|
||||
install -d "$STAGING/usr/sbin"
|
||||
install -d "$STAGING/usr/share/man/man1"
|
||||
install -d "$STAGING/lib/systemd/system"
|
||||
install -d "$STAGING/etc/default"
|
||||
|
||||
install -m 755 "$REPO_ROOT/build/${ARCH}/${PACKAGE}" "$STAGING/usr/sbin/${PACKAGE}"
|
||||
install -m 644 "$REPO_ROOT/${PACKAGE}.service" "$STAGING/lib/systemd/system/${PACKAGE}.service"
|
||||
install -m 644 "$REPO_ROOT/${PACKAGE}.default" "$STAGING/etc/default/${PACKAGE}"
|
||||
gzip -9 -c "$REPO_ROOT/docs/${PACKAGE}.1" > "$STAGING/usr/share/man/man1/${PACKAGE}.1.gz"
|
||||
|
||||
sed "s/@VERSION@/${VERSION}/;s/@ARCH@/${ARCH}/" \
|
||||
"$REPO_ROOT/debian/${PACKAGE}.control.in" > "$STAGING/DEBIAN/control"
|
||||
install -m 644 "$REPO_ROOT/debian/${PACKAGE}.conffiles" "$STAGING/DEBIAN/conffiles"
|
||||
install -m 755 "$REPO_ROOT/debian/${PACKAGE}.postinst" "$STAGING/DEBIAN/postinst"
|
||||
install -m 755 "$REPO_ROOT/debian/${PACKAGE}.prerm" "$STAGING/DEBIAN/prerm"
|
||||
|
||||
mkdir -p "$REPO_ROOT/build"
|
||||
OUT="$REPO_ROOT/build/${PKG}.deb"
|
||||
dpkg-deb --build --root-owner-group "$STAGING" "$OUT"
|
||||
echo "Built: $OUT"
|
||||
Reference in New Issue
Block a user