Files
jarl/scripts/mkdeb.sh
T
abrown38andClaude Opus 5.5 293e6ddd33 Add backups, token expiry warnings and name server checks
- Daily database backups: jarl-backup.timer runs 'jarld backup', which
  writes jarl-<UTC time>.db into backup.dir, checks it before naming it,
  and prunes by the time in the name while always keeping the newest
  keep_at_least. New backup: section in jarl.yaml; the dashboard and
  'jarl status' show the newest backup and warn when it is stale or
  failed. The Debian package enables the timer.
- 'jarld restore [FILE | latest]': checks the backup, shows it next to
  the current database, keeps the current one aside and records the
  restore. 'jarld serve' holds a database lock, so a restore can't run
  under a live jarld and two jarlds can't share a database.
- Token expiry warnings from 14 days ahead: dashboard, token lists, a
  daily log line, and a CLI warning via the Jarl-Token-Expires header;
  'jarl token list --expiring'.
- 'jarl zone serials' and the zone page's Name servers tab: compare the
  serial on a primary zone's secondaries (NS records, also-notify) or a
  secondary zone's primaries with this server's.
- 'jarl zone delegation': for zones on the internet, check the parent's
  delegation and glue against the zone; an undelegated zone gets a note.
- Server: Jarl/<version> header; CLI exit code 2 for failed checks.

Co-Authored-By: Claude Opus 5.5 <noreply@anthropic.com>
2026-10-08 19:02:34 +00:00

90 lines
3.6 KiB
Bash
Executable File

#!/bin/sh
# Builds a Debian package of Jarl: dist/jarl_<version>_<arch>.deb.
# Run through 'make deb' (which sets the variables below); needs only
# dpkg-deb, no root and no debhelper.
#
# The package installs, with Debian's paths:
# /usr/bin/jarld, /usr/bin/jarl
# /usr/share/bash-completion/completions/{jarl,jarld}
# /usr/lib/systemd/system/{jarl.service,jarl-backup.service,jarl-backup.timer}
# /usr/lib/sysusers.d/jarl.conf, /usr/lib/tmpfiles.d/jarl.conf
# /usr/share/doc/jarl/ (README, CHANGELOG, docs, contrib)
# and its scripts (deploy/debian) create the jarl user and directories and
# /etc/jarl/jarl.yaml on the first install, turn on the daily backup timer,
# restart a running jarld on upgrades, and stop both on removal. No file in /etc belongs to the package,
# so an upgrade never asks about configuration files.
#
# Variables: DEB_ARCH (Debian architecture, e.g. amd64, arm64, armhf),
# DEB_VERSION, VERSION, LDFLAGS, GOFLAGS, and DEB_MAINTAINER (default: your
# git name and email).
set -eu
: "${DEB_ARCH:?}" "${DEB_VERSION:?}" "${VERSION:?}" "${LDFLAGS:?}"
GOFLAGS=${GOFLAGS:-}
# Debian architecture -> Go architecture.
goarm=
case "$DEB_ARCH" in
amd64) goarch=amd64 ;;
arm64) goarch=arm64 ;;
armhf) goarch=arm goarm=7 ;;
i386) goarch=386 ;;
ppc64el) goarch=ppc64le ;;
riscv64) goarch=riscv64 ;;
s390x) goarch=s390x ;;
*) echo "mkdeb: unsupported architecture $DEB_ARCH" >&2; exit 1 ;;
esac
if [ -z "${DEB_MAINTAINER:-}" ]; then
name=$(git config user.name 2>/dev/null || true)
email=$(git config user.email 2>/dev/null || true)
DEB_MAINTAINER="${name:-Jarl packager} <${email:-root@localhost}>"
fi
work=dist/deb/jarl_${DEB_VERSION}_${DEB_ARCH}
root=$work/root
out=dist/jarl_${DEB_VERSION}_${DEB_ARCH}.deb
rm -rf "$work"
mkdir -p "$root/DEBIAN"
# Binaries for the package's architecture (bin/ holds the host's, which
# also generated the completion scripts).
echo "mkdeb: building for linux/$goarch"
# go reads GOFLAGS (-trimpath) from the environment.
export GOFLAGS
GOOS=linux GOARCH=$goarch GOARM=$goarm CGO_ENABLED=0 go build -ldflags "$LDFLAGS" -o "$work/jarld" ./cmd/jarld
GOOS=linux GOARCH=$goarch GOARM=$goarm CGO_ENABLED=0 go build -ldflags "$LDFLAGS" -o "$work/jarl" ./cmd/jarl
make --no-print-directory install-files DESTDIR="$root" PREFIX=/usr \
UNITDIR=/usr/lib/systemd/system JARLD_BIN="$work/jarld" JARL_BIN="$work/jarl" >/dev/null
# Debian's machine-readable copyright file, from LICENSE.
indent() { sed -e 's/^$/./' -e 's/^/ /' "$1"; }
{
echo "Format: https://www.debian.org/doc/packaging-manuals/copyright-format/1.0/"
echo "Upstream-Name: jarl"
echo
echo "Files: *"
echo "Copyright: $(sed -n 's/^Copyright (c) //p' LICENSE)"
echo "License: Expat"
indent LICENSE
} > "$root/usr/share/doc/jarl/copyright"
for f in postinst prerm postrm; do
install -m 0755 "deploy/debian/$f" "$root/DEBIAN/$f"
done
# Directories 0755 and no group/other write, whatever the build's umask.
find "$root" -type d -exec chmod 0755 {} +
chmod -R go-w "$root"
size=$(du -sk --exclude=DEBIAN "$root" | cut -f1)
sed -e "s/@VERSION@/$DEB_VERSION/" -e "s/@ARCH@/$DEB_ARCH/" -e "s/@SIZE@/$size/" \
-e "s|@MAINTAINER@|$DEB_MAINTAINER|" deploy/debian/control.in > "$root/DEBIAN/control"
(cd "$root" && find . -path ./DEBIAN -prune -o -type f -print | sed 's|^\./||' | sort | xargs md5sum) > "$root/DEBIAN/md5sums"
chmod 0644 "$root/DEBIAN/control" "$root/DEBIAN/md5sums"
# Files belong to root in the package, whoever builds it.
dpkg-deb --root-owner-group -Zxz --build "$root" "$out" >/dev/null
rm -rf dist/deb
echo "mkdeb: wrote $out"
dpkg-deb --info "$out" | sed -n 's/^ \(Package\|Version\|Architecture\|Installed-Size\):/ \1:/p'