-
Notifications
You must be signed in to change notification settings - Fork 0
Expand file tree
/
Copy pathfoundations.mk
More file actions
99 lines (77 loc) · 2.28 KB
/
Copy pathfoundations.mk
File metadata and controls
99 lines (77 loc) · 2.28 KB
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
54
55
56
57
58
59
60
61
62
63
64
65
66
67
68
69
70
71
72
73
74
75
76
77
78
79
80
81
82
83
84
85
86
87
88
89
90
91
92
93
94
95
96
97
98
99
.PHONY: dirs
RED := $(shell printf '\033[0;31m')
GREEN := $(shell printf '\033[0;32m')
YELLOW := $(shell printf '\033[0;33m')
BLUE := $(shell printf '\033[0;34m')
CYAN := $(shell printf '\033[0;36m')
RESET := $(shell printf '\033[0m')
define sctl
/etc/systemd/system/multi-user.target.wants/$(1).$(or $(2),service)
endef
define socket
/etc/systemd/system/sockets.target.wants/$(1).socket
endef
define timer
/etc/systemd/system/timers.target.wants/$(1).timer
endef
define user-sctl
$(HOME)/.config/systemd/user/default.target.wants/$(1).service
endef
define user-timer
$(HOME)/.config/systemd/user/timers.target.wants/$(1).timer
endef
define bin
$(foreach arg,$(1),/usr/bin/$(arg))
endef
DIRS := $(DIRS) $(shell ../homunculus get-volumes 2>/dev/null)
dirs: $(DIRS)
root_dirs: $(ROOT_DIRS)
$(DIRS):
mkdir -p $@
$(ROOT_DIRS):
sudo mkdir -p $@
sudo chmod 755 $@
/usr/bin/%:
sudo pacman -S $(@F)
$(call sctl,%):
sudo systemctl daemon-reload
sudo systemctl enable $(basename $*).service --now
$(call socket,%):
sudo systemctl daemon-reload
sudo systemctl enable $(basename $*).socket --now
$(call timer,%):
sudo systemctl daemon-reload
sudo systemctl enable $(basename $*).timer --now
$(call user-sctl,%):
systemctl --user daemon-reload
systemctl --user enable $(basename $*).service --now
$(call user-timer,%):
systemctl --user daemon-reload
systemctl --user enable $(basename $*).timer --now
define install_conf
@if [ -d "$(1)" ]; then \
sudo mkdir -v -p $(2); \
sudo chmod -v 755 $(2) | grep -v retained ; \
else \
sudo cp -v $(1) $(2); \
if [ -x $(1) ]; then \
sudo chmod -v 755 $(2) | grep -v retained; \
else \
sudo chmod -v 644 $(2) | grep -v retained ; \
fi; \
fi ; \
sudo chown -v root:root $(2) | grep -v retained ; \
sudo touch --reference=$(1) $(2) ; \
touch $(call stamp_file,$(2)) ; \
case "$(1)" in \
*/systemd/user/*.service | */systemd/user/*.timer) systemctl --user daemon-reload && echo "reloaded user daemon: $(1)" ;; \
*/systemd/system/*.service | */systemd/system/*.timer) sudo systemctl daemon-reload && echo "reloaded system daemon: $(1)" ;; \
esac
endef
/etc/%: ./etc/%
$(call install_conf,$<,$@)
/usr/%: ./usr/%
$(call install_conf,$<,$@)
define stamp_file
$(foreach arg,$(1),/tmp/tower-stamp$(shell echo $(arg) | tr '/' '-'))
endef