-
Notifications
You must be signed in to change notification settings - Fork 2
/
Makefile
152 lines (116 loc) · 5.33 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
prefix = /usr/local
sbindir = $(prefix)/sbin
sharedir = $(prefix)/share
mandir = $(sharedir)/man
man1dir = $(mandir)/man1
libdir = $(prefix)/lib
docdir = $(prefix)/share/doc/piuparts/
site26 = $(libdir)/python2.6/dist-packages
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 master-bin/*.in slave-bin/*.in conf/*.in)
SCRIPTS_PYTHON_BINARY = $(wildcard *.py)
SCRIPTS_GENERATED = $(SCRIPTS_TEMPLATES:.in=) $(SCRIPTS_PYTHON_BINARY:.py=)
DOCS_GENERATED = piuparts.1 piuparts.1.html README.html
define placeholder_substitution
sed -r \
-e 's/__PIUPARTS_VERSION__/$(version)/g' \
-e 's%@sharedir@%$(sharedir)%g' \
$< > $@
endef
%: %.in Makefile
$(placeholder_substitution)
%: %.py Makefile
$(placeholder_substitution)
all: install install-doc
python-syntax-check:
@set -e -x; $(foreach py,$(wildcard *.py piupartslib/*.py),python -m py_compile $(py);)
build: build-stamp
build-stamp: $(SCRIPTS_GENERATED) $(DOCS_GENERATED) Makefile
$(MAKE) python-syntax-check
touch $@
build-doc: $(DOCS_GENERATED)
README.html: README.txt
a2x --copy -a toc -a toclevels=3 -f xhtml -r /etc/asciidoc/ README.txt
piuparts.1: piuparts.1.txt
a2x -f manpage piuparts.1.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 docbook-xsl.css $(DESTDIR)$(docdir)/
install -d $(DESTDIR)$(man1dir)
install -m 0644 piuparts.1 $(DESTDIR)$(man1dir)/
gzip -9f $(DESTDIR)$(man1dir)/piuparts.1
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)/cron.d
install -m 0644 conf/crontab-master $(DESTDIR)$(etcdir)/cron.d/piuparts-master
install -m 0644 conf/crontab-slave $(DESTDIR)$(etcdir)/cron.d/piuparts-slave
sed -i -r '/^[^#]+/s/^/#/' $(DESTDIR)$(etcdir)/cron.d/piuparts-*
install -d $(DESTDIR)$(etcdir)/sudoers.d
install -m 440 conf/piuparts.sudoers $(DESTDIR)$(etcdir)/sudoers.d/piuparts
sed -i -r '/^[^#]+/s/^/#/' $(DESTDIR)$(etcdir)/sudoers.d/piuparts
install -d $(DESTDIR)$(etcdir)/apache2/conf.d
install -m 0644 conf/piuparts.apache $(DESTDIR)$(etcdir)/apache2/conf.d/
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/forward.* $(DESTDIR)$(etcdir)/piuparts/
install -m 0644 instances/piuparts.conf.* $(DESTDIR)$(etcdir)/piuparts/
install -d $(DESTDIR)$(sharedir)/piuparts/slave
install -m 0755 update-piuparts-setup $(DESTDIR)$(sharedir)/piuparts/slave/
install: build-stamp
install -d $(DESTDIR)$(sbindir)
install -m 0755 piuparts $(DESTDIR)$(sbindir)/
install -d $(DESTDIR)$(sharedir)/piuparts
install -m 0755 piuparts-slave piuparts-master piuparts-report piuparts-analyze $(DESTDIR)$(sharedir)/piuparts/
install -d $(DESTDIR)$(site26)/piupartslib
install -d $(DESTDIR)$(site27)/piupartslib
install -m 0644 piupartslib/*.py $(DESTDIR)$(site26)/piupartslib/
install -m 0644 piupartslib/*.py $(DESTDIR)$(site27)/piupartslib/
install -d $(DESTDIR)$(sharedir)/piuparts/lib
install -m 0644 lib/*.sh $(DESTDIR)$(sharedir)/piuparts/lib/
# do not install the templates (*.in)
install -d $(DESTDIR)$(sharedir)/piuparts/master
install -m 0755 $(filter-out %.in,$(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/
# do not install the templates (*.in)
install -d $(DESTDIR)$(sharedir)/piuparts/slave
install -m 0755 $(filter-out %.in,$(wildcard slave-bin/*)) $(DESTDIR)$(sharedir)/piuparts/slave/
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
@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 -d $(DESTDIR)$(etcdir)/piuparts/known_problems
#install -m 0644 known_problems/*.conf $(DESTDIR)$(etcdir)/piuparts/known_problems/
check:
python piuparts.py unittest
python unittests.py
clean:
rm -f build-stamp
rm -f piuparts.1 piuparts.1.xml piuparts.1.html README.xml README.html docbook-xsl.css piuparts.html
rm -f *.pyc piupartslib/*.pyc
rm -f $(SCRIPTS_GENERATED)