Add a Debian package and bash completion

make deb builds dist/jarl_<version>_<arch>.deb with dpkg-deb alone (no
root), for the host or another architecture (DEB_ARCH=arm64). The package
creates the jarl user and directories and an example jarl.yaml on the
first install, restarts a running jarld on upgrades, never touches
/etc/jarl/jarl.yaml, stops jarld on removal, and keeps Jarl's data even
on purge.

make install and the package install bash completion for jarl and jarld.
Besides commands and flags it completes server and group names from the
CLI configuration, zone, view, ACL, TSIG key and user names from the
server, and record types. make dist includes the completion scripts.

Co-Authored-By: Claude Opus 5.5 <noreply@anthropic.com>
This commit is contained in:
abrown38andClaude Opus 5.5 committed 2026-10-08 15:10:57 +00:00
1 parent 0f2c318aaf
commit 352c9cb394
13 files changed
+555 -30

No files matched your search

+56 -24
View File
@@ -1,11 +1,13 @@
# Jarl build and install.
#
# make build bin/jarld and bin/jarl
# make build bin/jarld and bin/jarl (and their bash completion)
# make test unit tests (integration tests run when BIND is found;
# set JARL_BIND_ROOT, see docs/development.md)
# make e2e end-to-end test against a real named (scripts/e2e.sh)
# sudo make install install binaries, systemd unit, sysusers/tmpfiles
# files and an example /etc/jarl/jarl.yaml
# sudo make install install binaries, bash completion, systemd unit,
# sysusers/tmpfiles files and an example /etc/jarl/jarl.yaml
# make deb a Debian package in dist/ (DEB_ARCH=arm64 for another
# architecture); install it with 'sudo apt install ./dist/jarl_*.deb'
# make dist static binaries for linux/amd64 and linux/arm64 in dist/
VERSION ?= $(shell cat VERSION 2>/dev/null || echo 0.0.0-dev)
@@ -13,21 +15,39 @@ LDFLAGS := -s -w -X jarl/internal/version.Version=$(VERSION)
GOFLAGS := -trimpath
export CGO_ENABLED := 0
PREFIX ?= /usr/local
BINDIR ?= $(PREFIX)/bin
DOCDIR ?= $(PREFIX)/share/doc/jarl
UNITDIR ?= /etc/systemd/system
PREFIX ?= /usr/local
BINDIR ?= $(PREFIX)/bin
DOCDIR ?= $(PREFIX)/share/doc/jarl
# bash-completion also looks in /usr/local/share (XDG_DATA_DIRS).
BASHCOMPDIR ?= $(PREFIX)/share/bash-completion/completions
UNITDIR ?= /etc/systemd/system
SYSUSERSDIR ?= /usr/lib/sysusers.d
TMPFILESDIR ?= /usr/lib/tmpfiles.d
DESTDIR ?=
DESTDIR ?=
.PHONY: all build test vet e2e install uninstall dist clean
# The binaries install-files copies (make deb points these at other
# architectures' builds).
JARLD_BIN ?= bin/jarld
JARL_BIN ?= bin/jarl
# make deb: the package's architecture (Debian name) and version.
DEB_ARCH ?= $(shell dpkg --print-architecture 2>/dev/null || go env GOARCH)
DEB_VERSION ?= $(subst -,~,$(VERSION))
.PHONY: all build completion test vet e2e install install-files uninstall deb dist clean
all: build
build:
go build $(GOFLAGS) -ldflags '$(LDFLAGS)' -o bin/jarld ./cmd/jarld
go build $(GOFLAGS) -ldflags '$(LDFLAGS)' -o bin/jarl ./cmd/jarl
$(MAKE) --no-print-directory completion
# Bash completion scripts, generated by the binaries themselves.
completion:
@mkdir -p bin/completion
bin/jarl completion bash > bin/completion/jarl
bin/jarld completion bash > bin/completion/jarld
vet:
go vet ./...
@@ -39,19 +59,7 @@ test: vet
e2e: build
scripts/e2e.sh
install: build
install -D -m 0755 bin/jarld $(DESTDIR)$(BINDIR)/jarld
install -D -m 0755 bin/jarl $(DESTDIR)$(BINDIR)/jarl
install -D -m 0644 deploy/systemd/jarl.service $(DESTDIR)$(UNITDIR)/jarl.service
sed -i 's#/usr/local/bin/jarld#$(BINDIR)/jarld#; s#/usr/local/share/doc/jarl#$(DOCDIR)#' $(DESTDIR)$(UNITDIR)/jarl.service
install -D -m 0644 deploy/sysusers.d/jarl.conf $(DESTDIR)$(SYSUSERSDIR)/jarl.conf
install -D -m 0644 deploy/tmpfiles.d/jarl.conf $(DESTDIR)$(TMPFILESDIR)/jarl.conf
install -D -m 0644 README.md $(DESTDIR)$(DOCDIR)/README.md
install -D -m 0644 CHANGELOG.md $(DESTDIR)$(DOCDIR)/CHANGELOG.md
install -d $(DESTDIR)$(DOCDIR)/docs $(DESTDIR)$(DOCDIR)/contrib/acme.sh $(DESTDIR)$(DOCDIR)/contrib/lego
install -m 0644 docs/*.md $(DESTDIR)$(DOCDIR)/docs/
install -m 0644 contrib/acme.sh/dns_jarl.sh $(DESTDIR)$(DOCDIR)/contrib/acme.sh/
install -m 0755 contrib/lego/jarl-lego.sh $(DESTDIR)$(DOCDIR)/contrib/lego/
install: build install-files
@if [ ! -e $(DESTDIR)/etc/jarl/jarl.yaml ]; then \
install -d -m 0750 $(DESTDIR)/etc/jarl; \
bin/jarld config --example > $(DESTDIR)/etc/jarl/jarl.yaml; \
@@ -63,17 +71,41 @@ install: build
@echo " chgrp jarl /etc/jarl /etc/jarl/jarl.yaml && systemctl daemon-reload"
@echo "Then follow docs/install.md (init, import, adopt, start)."
# Everything but /etc/jarl/jarl.yaml (shared by install and deb).
install-files:
install -D -m 0755 $(JARLD_BIN) $(DESTDIR)$(BINDIR)/jarld
install -D -m 0755 $(JARL_BIN) $(DESTDIR)$(BINDIR)/jarl
install -D -m 0644 bin/completion/jarl $(DESTDIR)$(BASHCOMPDIR)/jarl
install -D -m 0644 bin/completion/jarld $(DESTDIR)$(BASHCOMPDIR)/jarld
install -D -m 0644 deploy/systemd/jarl.service $(DESTDIR)$(UNITDIR)/jarl.service
sed -i 's#/usr/local/bin/jarld#$(BINDIR)/jarld#; s#/usr/local/share/doc/jarl#$(DOCDIR)#' $(DESTDIR)$(UNITDIR)/jarl.service
install -D -m 0644 deploy/sysusers.d/jarl.conf $(DESTDIR)$(SYSUSERSDIR)/jarl.conf
install -D -m 0644 deploy/tmpfiles.d/jarl.conf $(DESTDIR)$(TMPFILESDIR)/jarl.conf
install -D -m 0644 README.md $(DESTDIR)$(DOCDIR)/README.md
install -D -m 0644 CHANGELOG.md $(DESTDIR)$(DOCDIR)/CHANGELOG.md
install -d $(DESTDIR)$(DOCDIR)/docs $(DESTDIR)$(DOCDIR)/contrib/acme.sh $(DESTDIR)$(DOCDIR)/contrib/lego
install -m 0644 docs/*.md $(DESTDIR)$(DOCDIR)/docs/
install -m 0644 contrib/acme.sh/dns_jarl.sh $(DESTDIR)$(DOCDIR)/contrib/acme.sh/
install -m 0755 contrib/lego/jarl-lego.sh $(DESTDIR)$(DOCDIR)/contrib/lego/
uninstall:
rm -f $(DESTDIR)$(BINDIR)/jarld $(DESTDIR)$(BINDIR)/jarl $(DESTDIR)$(UNITDIR)/jarl.service \
$(DESTDIR)$(BASHCOMPDIR)/jarl $(DESTDIR)$(BASHCOMPDIR)/jarld \
$(DESTDIR)$(SYSUSERSDIR)/jarl.conf $(DESTDIR)$(TMPFILESDIR)/jarl.conf
rm -rf $(DESTDIR)$(DOCDIR)
@echo "Kept /etc/jarl, /var/lib/jarl and the files in /etc/bind/jarl and /var/lib/bind/jarl."
dist:
# A Debian package, built with dpkg-deb (no root needed). The package's
# scripts are in deploy/debian; scripts/mkdeb.sh explains the layout.
deb: build
DEB_ARCH='$(DEB_ARCH)' DEB_VERSION='$(DEB_VERSION)' VERSION='$(VERSION)' \
LDFLAGS='$(LDFLAGS)' GOFLAGS='$(GOFLAGS)' scripts/mkdeb.sh
dist: build
for arch in amd64 arm64; do \
GOOS=linux GOARCH=$$arch go build $(GOFLAGS) -ldflags '$(LDFLAGS)' -o dist/jarl-$(VERSION)-linux-$$arch/jarld ./cmd/jarld && \
GOOS=linux GOARCH=$$arch go build $(GOFLAGS) -ldflags '$(LDFLAGS)' -o dist/jarl-$(VERSION)-linux-$$arch/jarl ./cmd/jarl && \
cp -r README.md CHANGELOG.md docs deploy contrib dist/jarl-$(VERSION)-linux-$$arch/ && \
cp -r README.md CHANGELOG.md docs deploy contrib bin/completion dist/jarl-$(VERSION)-linux-$$arch/ && \
tar -C dist -czf dist/jarl-$(VERSION)-linux-$$arch.tar.gz jarl-$(VERSION)-linux-$$arch || exit 1; \
done