File: Makefile

package info (click to toggle)
piuparts 1.0.0
  • links: PTS, VCS
  • area: main
  • in suites: buster
  • size: 2,108 kB
  • sloc: python: 7,409; sh: 3,989; makefile: 167
file content (194 lines) | stat: -rw-r--r-- 7,131 bytes parent folder | download | duplicates (2)
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
192
193
194
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/
site27 = $(libdir)/python2.7/dist-packages
htdocsdir	 = $(sharedir)/piuparts/htdocs
etcdir = $(prefix)/etc

distribution=${shell dpkg-parsechangelog | sed -n 's/^Distribution: *//p'}
ifeq ($(distribution),UNRELEASED)
version		:= ${shell echo "`dpkg-parsechangelog | sed -n 's/^Version: *//p'`~`date +%Y%m%d%H%M`~`git describe --dirty`"}
else
version		:= ${shell dpkg-parsechangelog | sed -n 's/^Version: *//p'}
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.1.html piuparts_slave_run.8 piuparts_slave_join.8 piuparts_slave_stop.8 README.html README_server.html

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),python -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)

README.html: README.txt
	a2x --copy -a toc -a toclevels=3 -f xhtml -r /etc/asciidoc/ README.txt

README_server.html: README_server.txt
	a2x --copy -a toc -a toclevels=3 -f xhtml -r /etc/asciidoc/ README_server.txt

piuparts.1: piuparts.1.txt
	a2x -f manpage piuparts.1.txt

piuparts_slave_run.8: piuparts_slave_run.8.txt
	a2x -f manpage piuparts_slave_run.8.txt

piuparts_slave_join.8: piuparts_slave_join.8.txt
	a2x -f manpage piuparts_slave_join.8.txt

piuparts_slave_stop.8: piuparts_slave_stop.8.txt
	a2x -f manpage piuparts_slave_stop.8.txt

piuparts.1.html: piuparts.1.txt
	a2x --copy -f xhtml piuparts.1.txt


install-doc: build-stamp
	install -d $(DESTDIR)$(docdir)/
	install -m 0644 README.txt README.html README_server.txt README_server.html docbook-xsl.css $(DESTDIR)$(docdir)/
	install -d $(DESTDIR)$(man1dir)
	install -m 0644 piuparts.1 $(DESTDIR)$(man1dir)/
	install -d $(DESTDIR)$(man8dir)
	install -m 0644 piuparts_slave_run.8 piuparts_slave_join.8 piuparts_slave_stop.8 $(DESTDIR)$(man8dir)/
	gzip -9f $(DESTDIR)$(man1dir)/piuparts.1
	gzip -9f $(DESTDIR)$(man8dir)/piuparts_slave_run.8
	gzip -9f $(DESTDIR)$(man8dir)/piuparts_slave_join.8
	gzip -9f $(DESTDIR)$(man8dir)/piuparts_slave_stop.8
	install -m 0644 piuparts.1.html $(DESTDIR)$(docdir)/

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)$(site27)/piupartslib
	install -m 0644 piupartslib/*.py $(DESTDIR)$(site27)/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)
	install -d $(DESTDIR)$(sharedir)/piuparts/master
	install -m 0755 $(filter-out %.in %.py,$(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)
	install -d $(DESTDIR)$(sharedir)/piuparts/slave
	install -m 0755 $(filter-out %.in %.py,$(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:
	nosetests --verbose

clean:
	rm -f build-stamp
	rm -f build-master-stamp
	rm -f $(DOCS_GENERATED)
	rm -f piuparts.1.xml README.xml README_server.xml docbook-xsl.css piuparts.html
	rm -f *.pyc piupartslib/*.pyc master-bin/*.pyc slave-bin/*.pyc tests/*.pyc
	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 &