From a35e328ca65bef9796e956fd6148ba770e93f03f Mon Sep 17 00:00:00 2001 From: Andrew Cady Date: Fri, 29 May 2020 08:48:25 -0400 Subject: auto-install dependencies --- .gitignore | 1 + Makefile | 44 +++++++++++++++++++++++++++++++++++++++----- control.sh | 3 ++- 3 files changed, 42 insertions(+), 6 deletions(-) diff --git a/.gitignore b/.gitignore index 4db28ac..75418b0 100644 --- a/.gitignore +++ b/.gitignore @@ -1 +1,2 @@ control +equivs-stamp diff --git a/Makefile b/Makefile index 29b9577..e1af5a9 100644 --- a/Makefile +++ b/Makefile @@ -1,15 +1,46 @@ -control: control.sh depends.control .git/refs/heads/master - ./control.sh depends.control > $@ +all: control equivs-stamp + +ARCH := $(shell dpkg-architecture -q DEB_BUILD_ARCH) +ifndef VERSION +VERSION := $(shell TZ=UTC date -Is | tr -d :- | tr T . | sed 's/+.*//') +endif +export VERSION +PKG ?= $(notdir $(PWD)) + +PKG_FILE ?= $(PKG)_$(VERSION)_$(ARCH).deb +export PKG_FILE + +$(PKG_FILE): control + equivs-build control + +equivs-stamp: control + $(MAKE) $(PKG_FILE) + $(MAKE) install-remove-equivs + rm $(PKG_FILE) + touch $@ + +.PHONY: install-remove-equivs +install-remove-equivs: +ifneq (0,$(shell id -u)) + sudo $(MAKE) PKG_FILE=$(PKG_FILE) MAKEFLAGS=$(MAKEFLAGS) $@ +else + dpkg -i $(PKG_FILE) + f=$(PKG_FILE); dpkg -r $${f%%_*} +endif +#. DD_USER = dyndns DD_GROUP = dyndns -install-dyndns-server: +.PHONY: install all + +install: equivs-stamp ifneq ($(shell id -u),0) - $(SUDO_MAKE) $@ + sudo $(MAKE) MAKEFLAGS=$(MAKEFLAGS) $@ else : apt install pdns - : adduser $(DD_USER) + getent passwd $(DD_USER) || useradd --system --create-home $(DD_USER) + false chown root:$(DD_GROUP) /etc/powerdns chown pdns:$(DD_GROUP) /etc/powerdns/powerdns.sqlite3 chmod g+rwx /etc/powerdns @@ -25,3 +56,6 @@ endef ~$(DD_USER)/.ssh/authorized_keys: : writing file $@ $(file >$@,$(dyndns_authorized_keys_contents)) + +control: control.sh depends.control .git/refs/heads/master + ./control.sh depends.control > $@ diff --git a/control.sh b/control.sh index 5943455..7106187 100755 --- a/control.sh +++ b/control.sh @@ -1,8 +1,9 @@ #!/bin/sh +VERSION=${VERSION:-$(TZ=UTC date -Is | tr -d :- | tr T . | sed 's/+.*//')} cat - "$@" < -- cgit v1.2.3