aboutsummaryrefslogtreecommitdiff
path: root/makefile
blob: 9715ee5d60eba9c30d7173425481ba3114d4eaa2 (plain)
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
33
34
35
36
37
38
39
40
41
42
43
44
45
46
47
48
49
50
51
52
53
PREFIX=/usr/local
SBINDIR=$(PREFIX)/sbin

SED_SHELL:=
SED_SHELL+=s:^SBINDIR=.*:SBINDIR=$(SBINDIR):;

SED_SYSD:=
SED_SYSD+=s:^ExecStart=.*/\([^/]\+\)$$:ExecStart=$(SBINDIR)/\1:;


.PHONY: all
all:
	sed -i -e '$(SED_SHELL)' adu-download
	sed -i -e '$(SED_SHELL)' adu-upgrade
	sed -i -e '$(SED_SYSD)' adu-download.service
	sed -i -e '$(SED_SYSD)' adu-download.timer
	sed -i -e '$(SED_SYSD)' adu-upgrade.service


.PHONY: install
install: DESTDIR=$(PREFIX)
install: SBINDIR=$(DESTDIR)/sbin
install: SYSDDIR=$(DESTDIR)/lib/systemd/system
install:
	install -d '$(SBINDIR)'
	install -m 755 -t '$(SBINDIR)' adu-download
	install -m 755 -t '$(SBINDIR)' adu-upgrade
	install -d '$(SYSDDIR)'
	install -d '$(SYSDDIR)/system-update.target.wants'
	install -m 644 -t '$(SYSDDIR)' adu-download.service
	install -m 644 -t '$(SYSDDIR)' adu-download.timer
	install -m 644 -t '$(SYSDDIR)' adu-upgrade.service
	ln -s '$(SYSDDIR)/adu-upgrade.service' '$(SYSDDIR)/system-update.target.wants/adu-upgrade.service'
	systemctl daemon-reload
	#systemctl --now preset adu-download.timer
	systemctl --now enable adu-download.timer


.PHONY: uninstall
uninstall: DESTDIR=$(PREFIX)
uninstall: SBINDIR=$(DESTDIR)/sbin
uninstall: SYSDDIR=$(DESTDIR)/lib/systemd/system
uninstall:
	systemctl --now disable adu-download.timer
	rm -f '$(SYSDDIR)/system-update.target.wants/adu-upgrade.service'
	rm -f '$(SYSDDIR)/adu-upgrade.service'
	rm -f '$(SYSDDIR)/adu-download.timer'
	rm -f '$(SYSDDIR)/adu-download.service'
	rm -f '$(SBINDIR)/adu-upgrade'
	rm -f '$(SBINDIR)/adu-download'
	systemctl daemon-reload