forked from neubot/neubot
-
Notifications
You must be signed in to change notification settings - Fork 0
/
Copy pathMakefile
299 lines (271 loc) · 8.88 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
192
193
194
195
196
197
198
199
200
201
202
203
204
205
206
207
208
209
210
211
212
213
214
215
216
217
218
219
220
221
222
223
224
225
226
227
228
229
230
231
232
233
234
235
236
237
238
239
240
241
242
243
244
245
246
247
248
249
250
251
252
253
254
255
256
257
258
259
260
261
262
263
264
265
266
267
268
269
270
271
272
273
274
275
276
277
278
279
280
281
282
283
284
285
286
287
288
289
290
291
292
293
294
295
296
297
298
299
# Makefile
#
# Copyright (c) 2010-2012 Simone Basso <[email protected]>,
# NEXA Center for Internet & Society at Politecnico di Torino
#
# This file is part of Neubot <http://www.neubot.org/>.
#
# Neubot is free software: you can redistribute it and/or modify
# it under the terms of the GNU General Public License as published by
# the Free Software Foundation, either version 3 of the License, or
# (at your option) any later version.
#
# Neubot is distributed in the hope that it will be useful,
# but WITHOUT ANY WARRANTY; without even the implied warranty of
# MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the
# GNU General Public License for more details.
#
# You should have received a copy of the GNU General Public License
# along with Neubot. If not, see <http://www.gnu.org/licenses/>.
#
#
# The scripts/release script will automatically update the
# version number each time we tag with a new release.
#
VERSION = 0.4.6-rc3
#
# The list of .PHONY targets. This is also used to build the
# help message--and note that the targets named with a leading
# underscore are private.
# Here we list targets in file order because this makes it easier
# to maintain this list.
#
PHONIES += help
PHONIES += regress
PHONIES += clean
PHONIES += archive
PHONIES += _install
PHONIES += install
PHONIES += uninstall
PHONIES += _deb_data
PHONIES += _deb_control
PHONIES += _deb
PHONIES += deb
PHONIES += release
.PHONY: $(PHONIES)
help:
@printf "Targets:"
@for TARGET in `grep ^PHONIES Makefile|sed 's/^.*+= //'`; do \
if echo $$TARGET|grep -qv ^_; then \
printf " $$TARGET"; \
fi; \
done
@printf '\n'
regress:
for FILE in $$(find regress/ -type f -executable); do \
echo "* Running regression test: $$FILE"; \
./$$FILE || exit 1; \
echo ""; \
echo ""; \
done
clean:
@echo "[CLEAN]"
@./scripts/cleanup
# _ _
# __ _ _ __ ___| |__ (_)_ _____
# / _` | '__/ __| '_ \| \ \ / / _ \
# | (_| | | | (__| | | | |\ V / __/
# \__,_|_| \___|_| |_|_| \_/ \___|
#
# Create source archives
#
STEM = neubot-$(VERSION)
ARCHIVE = git archive --prefix=$(STEM)/
archive:
@echo "[ARCHIVE]"
@install -d dist/
@for FMT in tar zip; do \
$(ARCHIVE) --format=$$FMT HEAD > dist/$(STEM).$$FMT; \
done
@gzip -9 dist/$(STEM).tar
# _ _ _ _
# (_)_ __ ___| |_ __ _| | |
# | | '_ \/ __| __/ _` | | |
# | | | | \__ \ || (_| | | |
# |_|_| |_|___/\__\__,_|_|_|
#
# Install neubot in the filesystem
#
#
# We need to override INSTALL with 'install -o 0 -g 0' when
# we install from sources because in this case we want to
# enforce root's ownership.
#
INSTALL = install
#
# Some systems don't install a symlink for python and
# might want to override
#
PYTHON = python
#
# These are some of the variables accepted by the GNU
# build system, in order to follow the rule of the least
# surprise [1].
# We install neubot in $(DATADIR)/neubot following sect.
# 3.1.1 of Debian Python Policy which covers the shipping
# of private modules [2].
# We follow BSD hier(7) and we install manual pages in
# /usr/local/man by default.
#
# [1] http://bit.ly/aLduJz (gnu.org)
# [2] http://bit.ly/ayYyAR (debian.org)
#
DESTDIR =
SYSCONFDIR = /etc
LOCALSTATEDIR = /var/neubot
PREFIX = /usr/local
BINDIR = $(PREFIX)/bin
DATADIR = $(PREFIX)/share
MANDIR = $(PREFIX)/man
_install:
$(INSTALL) -d $(DESTDIR)$(BINDIR)
$(INSTALL) bin/neubot $(DESTDIR)$(BINDIR)/neubot
$(INSTALL) -d $(DESTDIR)$(DATADIR)
for DIR in `cd UNIX/share && find . -mindepth 1 -type d`; do \
$(INSTALL) -d $(DESTDIR)$(DATADIR)/$$DIR; \
test $$? || exit 1; \
done
for FILE in `cd UNIX/share && find . -type f`; do \
$(INSTALL) -m644 UNIX/share/$$FILE $(DESTDIR)$(DATADIR)/$$FILE; \
test $$? || exit 1; \
done
$(INSTALL) -d $(DESTDIR)$(MANDIR)
for DIR in `cd UNIX/man && find . -mindepth 1 -type d`; do \
$(INSTALL) -d $(DESTDIR)$(MANDIR)/$$DIR; \
test $$? || exit 1; \
done
for FILE in `cd UNIX/man && find . -type f`; do \
gzip -9c UNIX/man/$$FILE > UNIX/man/$$FILE.gz; \
test $$? || exit 1; \
$(INSTALL) -m644 UNIX/man/$$FILE.gz $(DESTDIR)$(MANDIR)/$$FILE.gz; \
test $$? || exit 1; \
done
$(INSTALL) -d $(DESTDIR)$(SYSCONFDIR)
for DIR in `cd UNIX/etc && find . -mindepth 1 -type d`; do \
$(INSTALL) -d $(DESTDIR)$(SYSCONFDIR)/$$DIR; \
test $$? || exit 1; \
done
for FILE in `cd UNIX/etc && find . -type f`; do \
$(INSTALL) -m644 UNIX/etc/$$FILE $(DESTDIR)$(SYSCONFDIR)/$$FILE; \
test $$? || exit 1; \
done
$(INSTALL) -d $(DESTDIR)$(DATADIR)/neubot
for DIR in `find neubot -type d`; do \
$(INSTALL) -d $(DESTDIR)$(DATADIR)/$$DIR; \
test $$? || exit 1; \
done
for FILE in `find neubot -type f`; do \
$(INSTALL) -m644 $$FILE $(DESTDIR)$(DATADIR)/$$FILE; \
test $$? || exit 1; \
done
$(INSTALL) -d $(DESTDIR)$(LOCALSTATEDIR)
for PATTERN in 's|@BINDIR@|$(BINDIR)|g' 's|@DATADIR@|$(DATADIR)|g' \
's|@LOCALSTATEDIR@|$(LOCALSTATEDIR)|g'; do \
./scripts/sed_inplace $$PATTERN \
$(DESTDIR)$(BINDIR)/neubot \
$(DESTDIR)$(DATADIR)/applications/neubot.desktop \
$(DESTDIR)$(DATADIR)/neubot/notifier/unix.py \
$(DESTDIR)$(DATADIR)/neubot/viewer/unix.py \
$(DESTDIR)$(SYSCONFDIR)/xdg/autostart/neubot.desktop; \
test $$? || exit 1; \
done
uninstall:
make -f Makefile _install DESTDIR=dist/r
$(PYTHON) -m compileall dist/r/$(DATADIR)/neubot
rm -rf dist/f dist/d dist/UNINSTALL
find dist/r/ -depth -type f -print -exec rm {} \; >> dist/f
find dist/r/ -depth -type d -empty -print >> dist/d
sed 's|dist/r|rm -f $(DESTDIR)|g' dist/f >> dist/UNINSTALL
sed 's|dist/r|rmdir $(DESTDIR)|g' dist/d >> dist/UNINSTALL
sh dist/UNINSTALL || true
#
# Install should be invoked as root and will actually
# copy neubot on the filesystem, making sure that root
# owns the installed files.
# Moreover it will compile the modules into .pyc files
# using the compileall module.
#
install:
make -f Makefile _install INSTALL='install -o 0 -g 0'
$(PYTHON) -m compileall $(DESTDIR)$(DATADIR)/neubot
# _ _
# __| | ___| |__
# / _` |/ _ \ '_ \
# | (_| | __/ |_) |
# \__,_|\___|_.__/
#
# Make package for Debian/Ubuntu/Mint
#
DEB_PACKAGE = dist/neubot-$(VERSION)-1_all.deb
DEB_PACKAGE_NOX = dist/neubot-nox-$(VERSION)-1_all.deb
_deb_data:
make -f Makefile _install DESTDIR=dist/data \
PREFIX=/usr MANDIR=/usr/share/man
$(INSTALL) -d dist/data/etc/apt/sources.list.d
$(INSTALL) -m644 Debian/neubot.list dist/data/etc/apt/sources.list.d/
$(INSTALL) -d dist/data/etc/cron.daily
$(INSTALL) Debian/cron-neubot dist/data/etc/cron.daily/neubot
$(INSTALL) -d dist/data/etc/init.d
$(INSTALL) Debian/init-neubot dist/data/etc/init.d/neubot
$(INSTALL) -d dist/data/usr/share/doc/neubot
$(INSTALL) -m644 Debian/copyright dist/data/usr/share/doc/neubot/
$(INSTALL) -m644 Debian/changelog.Debian.gz \
dist/data/usr/share/doc/neubot
_deb_control:
$(INSTALL) -d dist/control
$(INSTALL) -m644 Debian/control/control dist/control/control
$(INSTALL) -m644 Debian/control/conffiles dist/control/conffiles
$(INSTALL) Debian/control/postinst dist/control/postinst
$(INSTALL) Debian/control/prerm dist/control/prerm
$(INSTALL) Debian/control/postrm dist/control/postrm
$(INSTALL) -m644 /dev/null dist/control/md5sums
./scripts/cksum.py -a md5 `find dist/data -type f` >dist/control/md5sums
./scripts/sed_inplace 's|dist\/data\/||g' dist/control/md5sums
SIZE=`du -k -s dist/data/|cut -f1` && \
./scripts/sed_inplace "s|@SIZE@|$$SIZE|" dist/control/control
#
# Note that we must make _deb_data before _deb_control
# because the latter must calculate the md5sums and the
# total size.
# Fakeroot will guarantee that we don't ship a debian
# package with ordinary user ownership.
# For now we do not fail if lintian fails because there
# is the nonstandard /var/neubot issue pending.
#
_deb:
make -f Makefile _deb_data
cd dist/data && tar czf ../data.tar.gz ./*
make -f Makefile _deb_control
cd dist/control && tar czf ../control.tar.gz ./*
echo '2.0' > dist/debian-binary
@ar r $(DEB_PACKAGE) dist/debian-binary \
dist/control.tar.gz dist/data.tar.gz
$(INSTALL) -m644 Debian/control/control-nox dist/control/control
SIZE=`du -k -s dist/data/|cut -f1` && \
./scripts/sed_inplace "s|@SIZE@|$$SIZE|" dist/control/control
cd dist/control && tar czf ../control.tar.gz ./*
@ar r $(DEB_PACKAGE_NOX) dist/debian-binary \
dist/control.tar.gz dist/data.tar.gz
@cd dist && rm -rf debian-binary control.tar.gz data.tar.gz \
control/ data/
@chmod 644 $(DEB_PACKAGE)
@chmod 644 $(DEB_PACKAGE_NOX)
deb:
@echo "[DEB]"
@fakeroot make -f Makefile _deb
@lintian $(DEB_PACKAGE) || true
@lintian $(DEB_PACKAGE_NOX) || true
# _
# _ __ ___| | ___ __ _ ___ ___
# | '__/ _ \ |/ _ \/ _` / __|/ _ \
# | | | __/ | __/ (_| \__ \ __/
# |_| \___|_|\___|\__,_|___/\___|
#
# Bless a new neubot release (sources and Debian).
#
release:
@make clean
@make deb
@make archive
@./scripts/update_apt
@cd dist && chmod 644 *