-
Notifications
You must be signed in to change notification settings - Fork 10
/
Makefile
191 lines (149 loc) · 6.89 KB
/
Makefile
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
100
101
102
103
104
105
106
107
108
109
110
111
112
113
114
115
116
117
118
119
120
121
122
123
124
125
126
127
128
129
130
131
132
133
134
135
136
137
138
139
140
141
142
143
144
145
146
147
148
149
150
151
152
153
154
155
156
157
158
159
160
161
162
163
164
165
166
167
168
169
170
171
172
173
174
175
176
177
178
179
180
181
182
183
184
185
186
187
188
189
190
191
prefix = /usr/local
sbindir = $(prefix)/sbin
sharedir = $(prefix)/share
mandir = $(sharedir)/man
man1dir = $(mandir)/man1
man8dir = $(mandir)/man8
libdir = $(prefix)/lib
docdir = $(prefix)/share/doc/piuparts
site3 = $(libdir)/python3/dist-packages
htdocsdir = $(sharedir)/piuparts/htdocs
etcdir = $(prefix)/etc
distribution=${shell dpkg-parsechangelog -SDistribution}
ifeq ($(distribution),UNRELEASED)
version := ${shell echo "`dpkg-parsechangelog -SVersion`~`date +%Y%m%d%H%M`~`git describe --dirty`"}
else
version := ${shell dpkg-parsechangelog -SVersion}
endif
# generate several scripts, conffiles, ... from templates (*.in, *.py)
# by substituting placeholders
SCRIPTS_TEMPLATES = $(wildcard *.in master-bin/*.in slave-bin/*.in conf/*.in)
SCRIPTS_PYTHON_BINARY = $(wildcard *.py master-bin/*.py slave-bin/*.py)
SCRIPTS_GENERATED = $(SCRIPTS_TEMPLATES:.in=) $(SCRIPTS_PYTHON_BINARY:.py=)
DOCS_GENERATED = piuparts.1 piuparts_slave_run.8 piuparts_slave_join.8 piuparts_slave_stop.8 docs/build
define placeholder_substitution
sed -r \
-e 's/__PIUPARTS_VERSION__/$(version)/g' \
-e 's%@libdir@%$(libdir)%g' \
-e 's%@sharedir@%$(sharedir)%g' \
-e 's%@sbindir@%$(sbindir)%g' \
$< > $@
endef
%: %.in Makefile
$(placeholder_substitution)
%: %.py Makefile
$(placeholder_substitution)
all: build
python_scripts = $(wildcard *.py piupartslib/*.py master-bin/*.py slave-bin/*.py)
python-syntax-check:
@set -e -x; $(foreach py,$(python_scripts),python3 -m py_compile $(py);)
$(RM) $(python_scripts:=c)
build: build-stamp build-master-stamp
build-slave: build-stamp
build-master: build-stamp build-master-stamp
build-stamp: $(SCRIPTS_GENERATED) $(DOCS_GENERATED) Makefile
$(MAKE) -C instances
$(MAKE) python-syntax-check
touch $@
build-master-stamp:
(cd helpers/debiman-piuparts-distill && go build)
touch $@
build-doc: $(DOCS_GENERATED)
docs/build: docs/build
python3 -m sphinx docs/ docs/build/
piuparts.1: docs/piuparts/piuparts.1.txt
python3 -m sphinx -b man -c docs/piuparts/ docs/piuparts/ ./
piuparts_slave_run.8: docs/piuparts_slave_run/piuparts_slave_run.8.txt
python3 -m sphinx -b man -c docs/piuparts_slave_run/ docs/piuparts_slave_run/ ./
piuparts_slave_join.8: docs/piuparts_slave_join/piuparts_slave_join.8.txt
python3 -m sphinx -b man -c docs/piuparts_slave_join/ docs/piuparts_slave_join/ ./
piuparts_slave_stop.8: docs/piuparts_slave_stop/piuparts_slave_stop.8.txt
python3 -m sphinx -b man -c docs/piuparts_slave_stop/ docs/piuparts_slave_stop/ ./
install-doc: build-stamp
# txt
install -d $(DESTDIR)$(docdir)/
install -m 0644 docs/README.txt docs/README_server.txt $(DESTDIR)$(docdir)/
# html
cp -r docs/build/ $(DESTDIR)$(docdir)/html/
# manpages
install -d $(DESTDIR)$(man1dir)
install -m 0644 piuparts.1 $(DESTDIR)$(man1dir)/
gzip -9fn $(DESTDIR)$(man1dir)/piuparts.1
install -d $(DESTDIR)$(man8dir)
install -m 0644 piuparts_slave_run.8 piuparts_slave_join.8 piuparts_slave_stop.8 $(DESTDIR)$(man8dir)/
gzip -9fn $(DESTDIR)$(man8dir)/piuparts_slave_run.8
gzip -9fn $(DESTDIR)$(man8dir)/piuparts_slave_join.8
gzip -9fn $(DESTDIR)$(man8dir)/piuparts_slave_stop.8
install-conf: build-stamp
install -d $(DESTDIR)$(etcdir)/piuparts
install -m 0644 conf/piuparts.conf.sample $(DESTDIR)$(etcdir)/piuparts/piuparts.conf
install -m 0644 conf/distros.conf $(DESTDIR)$(etcdir)/piuparts/
install -d $(DESTDIR)$(etcdir)/apache2/conf-available
install -m 0644 conf/piuparts-master.conf $(DESTDIR)$(etcdir)/apache2/conf-available/
install-conf-4-running-from-git: build-stamp
install -d $(DESTDIR)$(etcdir)/piuparts
install -m 0644 conf/crontab-master $(DESTDIR)$(etcdir)/piuparts/
install -m 0644 conf/crontab-slave $(DESTDIR)$(etcdir)/piuparts/
install -m 0644 conf/distros.conf $(DESTDIR)$(etcdir)/piuparts/
install -m 0644 instances/piuparts.conf.* $(DESTDIR)$(etcdir)/piuparts/
install -d $(DESTDIR)$(sharedir)/piuparts/slave
install -m 0755 update-piuparts-slave-setup $(DESTDIR)$(sharedir)/piuparts/slave/
install -d $(DESTDIR)$(sharedir)/piuparts/master
install -m 0755 update-piuparts-master-setup $(DESTDIR)$(sharedir)/piuparts/master/
install-common: build-stamp
install -d $(DESTDIR)$(site3)/piupartslib
install -m 0644 piupartslib/*.py $(DESTDIR)$(site3)/piupartslib/
install -d $(DESTDIR)$(sharedir)/piuparts/lib
install -m 0644 lib/*.sh $(DESTDIR)$(sharedir)/piuparts/lib/
install-master: build-master-stamp install-common
install -d $(DESTDIR)$(libdir)/piuparts/
install -m 0755 helpers/debiman-piuparts-distill/debiman-piuparts-distill $(DESTDIR)$(libdir)/piuparts/
install -d $(DESTDIR)$(sharedir)/piuparts
install -m 0755 piuparts-master piuparts-master-backend piuparts-report piuparts-analyze $(DESTDIR)$(sharedir)/piuparts/
# do not install the templates (*.in, *.py, *.) nor __pycache__
install -d $(DESTDIR)$(sharedir)/piuparts/master
install -m 0755 $(filter-out %.in %.py %__pycache__,$(wildcard master-bin/*)) $(DESTDIR)$(sharedir)/piuparts/master/
install -d $(DESTDIR)$(sharedir)/piuparts/known_problems
install -m 0644 known_problems/*.conf $(DESTDIR)$(sharedir)/piuparts/known_problems/
install -d $(DESTDIR)$(htdocsdir)
install -m 0644 htdocs/*.* $(DESTDIR)$(htdocsdir)/
install -d $(DESTDIR)$(htdocsdir)/images
install -m 0644 htdocs/images/*.* $(DESTDIR)$(htdocsdir)/images/
install -d $(DESTDIR)$(htdocsdir)/templates/mail
install -m 0644 bug-templates/*.mail $(DESTDIR)$(htdocsdir)/templates/mail/
#install -d $(DESTDIR)$(etcdir)/piuparts/known_problems
#install -m 0644 known_problems/*.conf $(DESTDIR)$(etcdir)/piuparts/known_problems/
install-slave: install-common
install -d $(DESTDIR)$(sbindir)
install -m 0755 piuparts $(DESTDIR)$(sbindir)/
install -d $(DESTDIR)$(sharedir)/piuparts
install -m 0755 piuparts-slave $(DESTDIR)$(sharedir)/piuparts/
# do not install the templates (*.in, *.py) nor __pycache__
install -d $(DESTDIR)$(sharedir)/piuparts/slave
install -m 0755 $(filter-out %.in %.py %__pycache__,$(wildcard slave-bin/*)) $(DESTDIR)$(sharedir)/piuparts/slave/
install -d $(DESTDIR)$(etcdir)/piuparts
@set -e -x ; \
for d in $$(ls custom-scripts) ; do \
install -d $(DESTDIR)$(etcdir)/piuparts/$$d ; \
install -m 0755 custom-scripts/$$d/* $(DESTDIR)$(etcdir)/piuparts/$$d/ ; done
install: install-master install-slave
check:
python3 -m nose --verbose
clean:
rm -f build-stamp
rm -f build-master-stamp
rm -fr $(DOCS_GENERATED)
rm -fr .doctrees/
find . -iname '*.pyc' -type f -delete
find . -iname __pycache__ -type d -delete
rm -f $(SCRIPTS_GENERATED)
$(RM) helpers/debiman-piuparts-distill/debiman-piuparts-distill
$(MAKE) -C instances clean
# for maintainer convenience only
check-whitespace:
grep -r --exclude-dir .git --exclude '*.pyc' --exclude '*.png' --exclude '*.ico' -E '\s+$$' . || echo "no trailing whitespace found"
grep -r --exclude-dir .git --exclude '*.pyc' --exclude '*.png' --exclude '*.ico' -P ' \t' . || echo "no space-tab combo found"
# for maintainer convenience only
tg-deps:
tg summary --graphviz | dot -T png -o deps.png
xli deps.png &