-
Notifications
You must be signed in to change notification settings - Fork 1
/
Makefile
233 lines (204 loc) · 7.95 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
#!/usr/bin/make -f
VERSION ?= 1.1
DESTDIR ?= /usr
ifneq ($(RELEASE),)
PACKAGE_VERSION = $(VERSION).$(RELEASE)
else
PACKAGE_VERSION = $(VERSION).0
endif
RPMBUILD := rpmbuild
DEBBUILD := debbuild
INSTALL_DIR := install -d -m0755 -p
INSTALL_BIN := install -m0755 -p
INSTALL_DATA := install -m0644 -p
PYTHON_VER ?= $(shell python -V 2>&1 | cut -d' ' -f2 | awk -F'.' '{print $$1 "." $$2};')
PACKAGES_DIR ?= dist-packages
PYTEST_RESULT ?= pytest.xml
PYTEST_FLAGS ?= --junitxml=$(PYTEST_RESULT)
PYLINT_RESULT ?= pylint.txt
all: pylint test dist packages
.PHONY: all
dist:
@VERSION=$(PACKAGE_VERSION) python$(PYTHON_VER) setup.py sdist
.PHONY: dist
install: dist
@VERSION=$(PACKAGE_VERSION) python$(PYTHON_VER) setup.py install --prefix=$(DESTDIR)
.PHONY: install
pylint: $(PYLINT_RESULT)
.PHONY: pylint
$(PYLINT_RESULT): $(shell find reactor -name \*.py)
@pylint --ignore=tests --rcfile=pylintrc reactor | tee $@
test: cache_clean
@./py.test $(PYTEST_FLAGS) reactor
.PHONY: test
dist_install: dist_clean
@VERSION=$(PACKAGE_VERSION) python$(PYTHON_VER) setup.py bdist -p bdist
ifneq ($(DESTDIR),)
@$(INSTALL_DIR) $(DESTDIR)
@cd $(DESTDIR) && tar -zxf $(CURDIR)/dist/reactor-$(PACKAGE_VERSION).bdist.tar.gz
@mv $(DESTDIR)/usr/local/* $(DESTDIR)/usr; rmdir $(DESTDIR)/usr/local
@[ -d $(DESTDIR)/usr/lib*/python$(PYTHON_VER) ] || \
(cd $(DESTDIR)/usr/lib* && mv python* python$(PYTHON_VER))
@[ -d $(DESTDIR)/usr/lib*/python$(PYTHON_VER)/$(PACKAGES_DIR) ] || \
(cd $(DESTDIR)/usr/lib*/python$(PYTHON_VER) && mv *-packages $(PACKAGES_DIR))
@rm -rf $(DESTDIR)/usr/bin
endif
server_install: dist_clean
ifneq ($(DESTDIR),)
@$(INSTALL_DIR) $(DESTDIR)/etc/reactor
@$(INSTALL_DATA) etc/reactor/server.conf $(DESTDIR)/etc/reactor/server.conf
ifeq ($(UPSTART),y)
@$(INSTALL_DIR) $(DESTDIR)/etc/init
@$(INSTALL_DIR) $(DESTDIR)/etc/init.d
@$(INSTALL_BIN) etc/upstart/init/reactor-server.conf $(DESTDIR)/etc/init
@$(INSTALL_BIN) etc/upstart/init.d/reactor-server $(DESTDIR)/etc/init.d
else
@$(INSTALL_DIR) $(DESTDIR)/etc/init.d
@$(INSTALL_BIN) etc/sysV/init.d/reactor-server $(DESTDIR)/etc/init.d
endif
@$(INSTALL_DIR) $(DESTDIR)/etc/logrotate.d
@$(INSTALL_DATA) etc/logrotate.d/reactor-server $(DESTDIR)/etc/logrotate.d
@$(INSTALL_DIR) $(DESTDIR)/etc/cron.hourly
@$(INSTALL_BIN) etc/cron.hourly/clean-zk-logs $(DESTDIR)/etc/cron.hourly
@$(INSTALL_DIR) $(DESTDIR)/etc/reactor/example
@$(INSTALL_DIR) $(DESTDIR)/etc/reactor/default
@rsync -ruav example/ $(DESTDIR)/etc/reactor/example
@rsync -ruav default/ $(DESTDIR)/etc/reactor/default
@$(INSTALL_DIR) $(DESTDIR)/usr/bin
@$(INSTALL_BIN) bin/reactor-server $(DESTDIR)/usr/bin
@$(INSTALL_BIN) bin/reactor-defaults $(DESTDIR)/usr/bin
@$(INSTALL_BIN) bin/reactor-dump $(DESTDIR)/usr/bin
endif
manager_install: dist_clean
ifneq ($(DESTDIR),)
@$(INSTALL_DIR) $(DESTDIR)/etc/reactor
@$(INSTALL_DATA) etc/reactor/manager.conf $(DESTDIR)/etc/reactor/manager.conf
ifeq ($(UPSTART),y)
@$(INSTALL_DIR) $(DESTDIR)/etc/init
@$(INSTALL_DIR) $(DESTDIR)/etc/init.d
@$(INSTALL_BIN) etc/upstart/init/reactor-manager.conf $(DESTDIR)/etc/init
@$(INSTALL_BIN) etc/upstart/init.d/reactor-manager $(DESTDIR)/etc/init.d
else
@$(INSTALL_DIR) $(DESTDIR)/etc/init.d
@$(INSTALL_BIN) etc/sysV/init.d/reactor-manager $(DESTDIR)/etc/init.d
endif
@$(INSTALL_DIR) $(DESTDIR)/etc/logrotate.d
@$(INSTALL_DATA) etc/logrotate.d/reactor-manager $(DESTDIR)/etc/logrotate.d
@$(INSTALL_DIR) $(DESTDIR)/usr/bin
@$(INSTALL_BIN) bin/reactor-manager $(DESTDIR)/usr/bin
endif
client_install: dist_clean
ifneq ($(DESTDIR),)
@$(INSTALL_DIR) $(DESTDIR)/usr/bin
@$(INSTALL_BIN) bin/reactor $(DESTDIR)/usr/bin
endif
cache_clean:
@find . -name __pycache__ -exec rm -rf {} \; 2>/dev/null || true
@find . -name \*.pyc -exec rm -f {} \; 2>/dev/null || true
.PHONY: cache_clean
dist_clean: cache_clean
@rm -rf dist build reactor.egg-info
@rm -rf debbuild rpmbuild
.PHONY: dist_clean
clean: dist_clean
@rm -rf *.deb *.rpm extra/cobalt-novaclient*.*
@rm -rf pylint.txt pytest.xml
.PHONY: clean
$(RPMBUILD):
@$(INSTALL_DIR) $(RPMBUILD)
@$(INSTALL_DIR) $(RPMBUILD)/SRPMS
@$(INSTALL_DIR) $(RPMBUILD)/BUILD
@$(INSTALL_DIR) $(RPMBUILD)/BUILDROOT
@$(INSTALL_DIR) $(RPMBUILD)/SPECS
@$(INSTALL_DIR) $(RPMBUILD)/RPMS/noarch
@$(INSTALL_DIR) $(RPMBUILD)/SOURCES
.PHONY: $(RPMBUILD)
$(DEBBUILD):
@$(INSTALL_DIR) $(DEBBUILD)
.PHONY: $(DEBBUILD)
python-reactor.deb: $(DEBBUILD)
@$(INSTALL_DIR) $(DEBBUILD)/python-reactor
@$(MAKE) dist_install \
PYTHON_VER=2.7 \
PACKAGES_DIR=dist-packages \
DESTDIR=$(CURDIR)/$(DEBBUILD)/python-reactor
@rsync -ruav packagers/deb/python-reactor/ $(DEBBUILD)/python-reactor
@sed -i "s/@(VERSION)/$(PACKAGE_VERSION)/" $(DEBBUILD)/python-reactor/DEBIAN/control
@fakeroot dpkg -b $(DEBBUILD)/python-reactor .
.PHONY: python-reactor.deb
reactor-server.deb: $(DEBBUILD)
@$(INSTALL_DIR) $(DEBBUILD)/reactor-server
@$(MAKE) server_install \
UPSTART=y \
DESTDIR=$(CURDIR)/$(DEBBUILD)/reactor-server
@rsync -ruav packagers/deb/reactor-server/ $(DEBBUILD)/reactor-server
@sed -i "s/@(VERSION)/$(PACKAGE_VERSION)/" $(DEBBUILD)/reactor-server/DEBIAN/control
@fakeroot dpkg -b $(DEBBUILD)/reactor-server .
.PHONY: reactor-server.deb
reactor-manager.deb: $(DEBBUILD)
@$(INSTALL_DIR) $(DEBBUILD)/reactor-manager
@$(MAKE) manager_install \
UPSTART=y \
DESTDIR=$(CURDIR)/$(DEBBUILD)/reactor-manager
@rsync -ruav packagers/deb/reactor-manager/ $(DEBBUILD)/reactor-manager
@sed -i "s/@(VERSION)/$(PACKAGE_VERSION)/" $(DEBBUILD)/reactor-manager/DEBIAN/control
@fakeroot dpkg -b $(DEBBUILD)/reactor-manager .
.PHONY: reactor-manager.deb
reactor-client.deb: $(DEBBUILD)
@$(INSTALL_DIR) $(DEBBUILD)/reactor-client
@$(MAKE) client_install \
DESTDIR=$(CURDIR)/$(DEBBUILD)/reactor-client
@rsync -ruav packagers/deb/reactor-client/ $(DEBBUILD)/reactor-client
@sed -i "s/@(VERSION)/$(PACKAGE_VERSION)/" $(DEBBUILD)/reactor-client/DEBIAN/control
@fakeroot dpkg -b $(DEBBUILD)/reactor-client .
.PHONY: reactor-client.deb
python-reactor.rpm: $(RPMBUILD)
@rm -rf $(CURDIR)/$(RPMBUILD)/BUILDROOT/*
@$(MAKE) dist_install \
PYTHON_VER=2.6 \
PACKAGES_DIR=site-packages \
DESTDIR=$(CURDIR)/$(RPMBUILD)/BUILDROOT
@rpmbuild --with=suggests -bb --buildroot $(CURDIR)/$(RPMBUILD)/BUILDROOT \
--define="%_topdir $(CURDIR)/$(RPMBUILD)" \
--define="%version $(PACKAGE_VERSION)" \
packagers/rpm/python-reactor.spec
@find $(RPMBUILD) -name \*.rpm -exec mv {} . \;
.PHONY: python-reactor.rpm
reactor-server.rpm: $(RPMBUILD)
@rm -rf $(CURDIR)/$(RPMBUILD)/BUILDROOT/*
@$(MAKE) server_install \
UPSTART=n \
DESTDIR=$(CURDIR)/$(RPMBUILD)/BUILDROOT
@rpmbuild --with=suggests -bb --buildroot $(CURDIR)/$(RPMBUILD)/BUILDROOT \
--define="%_topdir $(CURDIR)/$(RPMBUILD)" \
--define="%version $(PACKAGE_VERSION)" \
packagers/rpm/reactor-server.spec
@find $(RPMBUILD) -name \*.rpm -exec mv {} . \;
.PHONY: reactor-server.rpm
reactor-manager.rpm: $(RPMBUILD)
@rm -rf $(CURDIR)/$(RPMBUILD)/BUILDROOT/*
@$(MAKE) manager_install \
UPSTART=n \
DESTDIR=$(CURDIR)/$(RPMBUILD)/BUILDROOT
@rpmbuild --with=suggests -bb --buildroot $(CURDIR)/$(RPMBUILD)/BUILDROOT \
--define="%_topdir $(CURDIR)/$(RPMBUILD)" \
--define="%version $(PACKAGE_VERSION)" \
packagers/rpm/reactor-manager.spec
@find $(RPMBUILD) -name \*.rpm -exec mv {} . \;
.PHONY: reactor-manager.rpm
reactor-client.rpm: $(RPMBUILD)
@rm -rf $(CURDIR)/$(RPMBUILD)/BUILDROOT/*
@$(MAKE) client_install \
DESTDIR=$(CURDIR)/$(RPMBUILD)/BUILDROOT
@rpmbuild --with=suggests -bb --buildroot $(CURDIR)/$(RPMBUILD)/BUILDROOT \
--define="%_topdir $(CURDIR)/$(RPMBUILD)" \
--define="%version $(PACKAGE_VERSION)" \
packagers/rpm/reactor-client.spec
@find $(RPMBUILD) -name \*.rpm -exec mv {} . \;
.PHONY: reactor-client.rpm
packages: deb-packages rpm-packages
.PHONY: packages
deb-packages: python-reactor.deb reactor-server.deb reactor-manager.deb reactor-client.deb
.PHONY: deb-packages
rpm-packages: python-reactor.rpm reactor-server.rpm reactor-manager.rpm reactor-client.rpm
.PHONY: rpm-packages