summaryrefslogtreecommitdiff
diff options
context:
space:
mode:
authorAndrew Cady <d@jerkface.net>2020-05-29 08:48:25 -0400
committerAndrew Cady <d@jerkface.net>2020-05-29 09:15:47 -0400
commita35e328ca65bef9796e956fd6148ba770e93f03f (patch)
tree4db2850358180f17456ac119710ebd837cc700e8
parent0d70aefb72bcef186cd73cb506be8197f740977d (diff)
auto-install dependencies
-rw-r--r--.gitignore1
-rw-r--r--Makefile44
-rwxr-xr-xcontrol.sh3
3 files changed, 42 insertions, 6 deletions
diff --git a/.gitignore b/.gitignore
index 4db28ac..75418b0 100644
--- a/.gitignore
+++ b/.gitignore
@@ -1 +1,2 @@
1control 1control
2equivs-stamp
diff --git a/Makefile b/Makefile
index 29b9577..e1af5a9 100644
--- a/Makefile
+++ b/Makefile
@@ -1,15 +1,46 @@
1control: control.sh depends.control .git/refs/heads/master 1all: control equivs-stamp
2 ./control.sh depends.control > $@ 2
3ARCH := $(shell dpkg-architecture -q DEB_BUILD_ARCH)
4ifndef VERSION
5VERSION := $(shell TZ=UTC date -Is | tr -d :- | tr T . | sed 's/+.*//')
6endif
7export VERSION
8PKG ?= $(notdir $(PWD))
9
10PKG_FILE ?= $(PKG)_$(VERSION)_$(ARCH).deb
11export PKG_FILE
12
13$(PKG_FILE): control
14 equivs-build control
15
16equivs-stamp: control
17 $(MAKE) $(PKG_FILE)
18 $(MAKE) install-remove-equivs
19 rm $(PKG_FILE)
20 touch $@
21
22.PHONY: install-remove-equivs
23install-remove-equivs:
24ifneq (0,$(shell id -u))
25 sudo $(MAKE) PKG_FILE=$(PKG_FILE) MAKEFLAGS=$(MAKEFLAGS) $@
26else
27 dpkg -i $(PKG_FILE)
28 f=$(PKG_FILE); dpkg -r $${f%%_*}
29endif
30#.
3 31
4DD_USER = dyndns 32DD_USER = dyndns
5DD_GROUP = dyndns 33DD_GROUP = dyndns
6 34
7install-dyndns-server: 35.PHONY: install all
36
37install: equivs-stamp
8ifneq ($(shell id -u),0) 38ifneq ($(shell id -u),0)
9 $(SUDO_MAKE) $@ 39 sudo $(MAKE) MAKEFLAGS=$(MAKEFLAGS) $@
10else 40else
11 : apt install pdns 41 : apt install pdns
12 : adduser $(DD_USER) 42 getent passwd $(DD_USER) || useradd --system --create-home $(DD_USER)
43 false
13 chown root:$(DD_GROUP) /etc/powerdns 44 chown root:$(DD_GROUP) /etc/powerdns
14 chown pdns:$(DD_GROUP) /etc/powerdns/powerdns.sqlite3 45 chown pdns:$(DD_GROUP) /etc/powerdns/powerdns.sqlite3
15 chmod g+rwx /etc/powerdns 46 chmod g+rwx /etc/powerdns
@@ -25,3 +56,6 @@ endef
25 56
26~$(DD_USER)/.ssh/authorized_keys: 57~$(DD_USER)/.ssh/authorized_keys:
27 : writing file $@ $(file >$@,$(dyndns_authorized_keys_contents)) 58 : writing file $@ $(file >$@,$(dyndns_authorized_keys_contents))
59
60control: control.sh depends.control .git/refs/heads/master
61 ./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 @@
1#!/bin/sh 1#!/bin/sh
2VERSION=${VERSION:-$(TZ=UTC date -Is | tr -d :- | tr T . | sed 's/+.*//')}
2cat - "$@" <<END 3cat - "$@" <<END
3Package: $(basename $(pwd)) 4Package: $(basename $(pwd))
4Source: $(basename $(pwd)) 5Source: $(basename $(pwd))
5Version: $(TZ=UTC date -Is | tr -d :- | tr T . | sed 's/+.*//') 6Version: ${VERSION}
6Architecture: $(dpkg-architecture -q DEB_BUILD_ARCH) 7Architecture: $(dpkg-architecture -q DEB_BUILD_ARCH)
7Origin: local 8Origin: local
8Maintainer: root <root@localhost> 9Maintainer: root <root@localhost>