forcing rpm-check if files added to the commit
[apex.git] / build / Makefile
1 ##############################################################################
2 # Copyright (c) 2016 Red Hat Inc.
3 # dradez@redhat.com
4 # All rights reserved. This program and the accompanying materials
5 # are made available under the terms of the Apache License, Version 2.0
6 # which accompanies this distribution, and is available at
7 # http://www.apache.org/licenses/LICENSE-2.0
8 ##############################################################################
9
10 export USE_MASTER = ""
11 export CENTDNLD = http://mirrors.cat.pdx.edu/centos/7.2.1511/isos/x86_64/CentOS-7-x86_64-DVD-1511.iso
12 export CENTISO = $(shell pwd)/$(shell basename $(CENTDNLD))
13 export RELEASE = "0"
14 export ISO = $(shell pwd)/release/OPNFV-CentOS-7-x86_64-${RELEASE}.iso
15 export RPMVERS = $(shell grep Version $(shell pwd)/opnfv-apex.spec | head -n 1 | awk '{ print $$2 }')
16 export RPMCOM = $(shell pwd)/noarch/opnfv-apex-common-$(RPMVERS)-$(shell echo ${RELEASE} | tr -d '_-').noarch.rpm
17 export RPMUDR = $(shell pwd)/noarch/opnfv-apex-undercloud-$(RPMVERS)-$(shell echo ${RELEASE} | tr -d '_-').noarch.rpm
18 export RPMODL = $(shell pwd)/noarch/opnfv-apex-$(RPMVERS)-$(shell echo ${RELEASE} | tr -d '_-').noarch.rpm
19 export RPMONO = $(shell pwd)/noarch/opnfv-apex-onos-$(RPMVERS)-$(shell echo ${RELEASE} | tr -d '_-').noarch.rpm
20 export RPMSFC = $(shell pwd)/noarch/opnfv-apex-opendaylight-sfc-$(RPMVERS)-$(shell echo ${RELEASE} | tr -d '_-').noarch.rpm
21
22 all_networks="admin_network private_network storage_network external_network api_network"
23
24
25
26 .PHONY: all
27 all: iso
28
29 .PHONY: clean
30 clean: images-clean rpms-clean iso-clean
31
32 .PHONY: images
33 images: undercloud overcloud-full overcloud-opendaylight overcloud-onos overcloud-opendaylight-sfc
34
35 .PHONY: images-clean
36 images-clean: undercloud-clean overcloud-full-clean overcloud-opendaylight-clean overcloud-onos-clean overcloud-opendaylight-sfc-clean
37         @rm -rf images/
38
39 .PHONY: rpms
40 rpms: common-rpm undercloud-rpm opendaylight-rpm onos-rpm opendaylight-sfc-rpm
41
42 .PHONY: rpms-check
43 rpms-check: common-rpm-check undercloud-rpm-check opendaylight-rpm-check onos-rpm-check opendaylight-sfc-rpm-check
44
45 .PHONY: rpms-clean
46 rpms-clean: common-rpm-clean undercloud-rpm-clean opendaylight-rpm-clean onos-rpm-clean opendaylight-sfc-rpm-clean
47
48 opnfv-apex-common.tar.gz:
49         pushd ../ && git archive --format=tar.gz --prefix=opnfv-apex-common-$(RPMVERS)/ HEAD > build/opnfv-apex-common.tar.gz
50
51 .PHONY: common-rpm-check
52 common-rpm-check: opnfv-apex-common.tar.gz
53         rpmbuild --clean -bi -bl opnfv-apex-common.spec -D '_topdir %(echo `pwd`)' -D '_builddir %(echo `pwd`)' -D '_sourcedir %(echo `pwd`)' -D '_rpmdir %(echo `pwd`)' -D '_specdir %(echo `pwd`)' -D '_srcrpmdir %(echo `pwd`)' -D "release $(shell echo $(RELEASE) | tr -d '_-')"
54
55 .PHONY: common-rpm
56 common-rpm: opnfv-apex-common.tar.gz $(RPMCOM)
57
58 $(RPMCOM):
59         @echo "Building the Apex Common RPM"
60         # build the common RPM
61         rpmbuild --clean -ba opnfv-apex-common.spec -D '_topdir %(echo `pwd`)' -D '_builddir %(echo `pwd`)' -D '_sourcedir %(echo `pwd`)' -D '_rpmdir %(echo `pwd`)' -D '_specdir %(echo `pwd`)' -D '_srcrpmdir %(echo `pwd`)' -D "release $(shell echo $(RELEASE) | tr -d '_-')"
62
63 ##################
64 #  PYTHON TESTS  #
65 ##################
66
67 .PHONY: python-tests
68 python-tests:
69         # clean previous coverage data
70         rm -rf ../tests/.coverage
71         rm -rf ../tests/htmlcov
72         # run nose tests
73         cd ../tests && PYTHONPATH=../lib/python/ nosetests-3.4 . --with-coverage --cover-package apex --cover-package apex_python_utils --cover-html --cover-min-percentage 85
74
75         # generate reports
76         cd ../tests && coverage3 report --include '*lib/python/*' -m
77
78 #######################
79 #  PYTHON PEP8 CHECK  #
80 #######################
81
82 .PHONY: python-pep8-check
83 python-pep8-check:
84         pep8 ../lib/python
85         pep8 ../tests
86
87 ###############
88 #  UNDERCLOUD #
89 ###############
90
91 .PHONY: undercloud-clean
92 undercloud-clean:
93         @rm -f images/undercloud.*
94
95 .PHONY: undercloud
96 undercloud: images/undercloud.qcow2
97
98 images/undercloud.qcow2:
99         @echo "Building the Apex Undercloud Image"
100         @./undercloud.sh
101
102 opnfv-apex-undercloud.tar.gz: images/undercloud.qcow2
103         @echo "Preparing the Apex Undercloud RPM prerequisites"
104         pushd ../ && git archive --format=tar --prefix=opnfv-apex-undercloud-$(RPMVERS)/ HEAD > build/opnfv-apex-undercloud.tar
105         tar -rf opnfv-apex-undercloud.tar \
106                --xform="s:images/undercloud.qcow2:opnfv-apex-undercloud-$(RPMVERS)/build/undercloud.qcow2:" images/undercloud.qcow2
107         gzip -f opnfv-apex-undercloud.tar
108
109 .PHONY: undercloud-rpm-check
110 undercloud-rpm-check: opnfv-apex-undercloud.tar.gz
111         rpmbuild --clean -bi -bl opnfv-apex-undercloud.spec -D '_topdir %(echo `pwd`)' -D '_builddir %(echo `pwd`)' -D '_sourcedir %(echo `pwd`)' -D '_rpmdir %(echo `pwd`)' -D '_specdir %(echo `pwd`)' -D '_srcrpmdir %(echo `pwd`)' -D "release $(shell echo $(RELEASE) | tr -d '_-')"
112
113 .PHONY: undercloud-rpm
114 undercloud-rpm: opnfv-apex-undercloud.tar.gz $(RPMUDR)
115
116 $(RPMUDR):
117         @echo "Building the Apex Undercloud RPM"
118         rpmbuild --clean -ba opnfv-apex-undercloud.spec -D '_topdir %(echo `pwd`)' -D '_builddir %(echo `pwd`)' -D '_sourcedir %(echo `pwd`)' -D '_rpmdir %(echo `pwd`)' -D '_specdir %(echo `pwd`)' -D '_srcrpmdir %(echo `pwd`)' -D "release $(shell echo $(RELEASE) | tr -d '_-')"
119
120 ###############
121 #  OVERCLOUD  #
122 ###############
123
124 .PHONY: overcloud-full-clean
125 overcloud-full-clean:
126         @rm -rf images/overcloud-full.d
127         @rm -f images/overcloud-full.*
128
129 .PHONY: overcloud-full
130 overcloud-full: images/overcloud-full.qcow2
131
132 images/overcloud-full.qcow2:
133         @echo "Building the Apex Base Overcloud Image"
134         @./overcloud-full.sh
135
136 ###############
137 #    ODL      #
138 ###############
139
140 .PHONY: overcloud-opendaylight-clean
141 overcloud-opendaylight-clean:
142         @rm -f images/overcloud-full-opendaylight.qcow2
143
144 .PHONY: overcloud-opendaylight
145 overcloud-opendaylight: images/overcloud-full-opendaylight.qcow2
146
147 images/overcloud-full-opendaylight.qcow2: images/overcloud-full.qcow2
148         @echo "Building the Apex OpenDaylight Overcloud Image"
149         @./overcloud-opendaylight.sh
150
151 opnfv-apex.tar.gz: images/overcloud-full-opendaylight.qcow2
152         tar -czf opnfv-apex.tar.gz --xform="s:images/overcloud-full-opendaylight.qcow2:opnfv-apex-$(RPMVERS)/build/images/overcloud-full-opendaylight.qcow2:" images/overcloud-full-opendaylight.qcow2
153
154 .PHONY: opendaylight-rpm-check
155 opendaylight-rpm-check: opnfv-apex.tar.gz
156         rpmbuild --clean -bi -bl opnfv-apex.spec -D '_topdir %(echo `pwd`)' -D '_builddir %(echo `pwd`)' -D '_sourcedir %(echo `pwd`)' -D '_rpmdir %(echo `pwd`)' -D '_specdir %(echo `pwd`)' -D '_srcrpmdir %(echo `pwd`)' -D "release $(shell echo $(RELEASE) | tr -d '_-')"
157
158 .PHONY: opendaylight-rpm
159 opendaylight-rpm: opnfv-apex.tar.gz $(RPMODL)
160
161 $(RPMODL):
162         @echo "Building the Apex OpenDaylight RPM"
163         # build the overcloud RPM
164         rpmbuild --clean -ba opnfv-apex.spec -D '_topdir %(echo `pwd`)' -D '_builddir %(echo `pwd`)' -D '_sourcedir %(echo `pwd`)' -D '_rpmdir %(echo `pwd`)' -D '_specdir %(echo `pwd`)' -D '_srcrpmdir %(echo `pwd`)' -D "release $(shell echo $(RELEASE) | tr -d '_-')"
165
166 ###############
167 #    ONOS     #
168 ###############
169
170 .PHONY: overcloud-onos-clean
171 overcloud-onos-clean:
172         @rm -f images/overcloud-full-onos.qcow2
173         @rm -rf images/puppet-onos
174         @rm -f images/puppet-onos.tar.gz
175
176 .PHONY: overcloud-onos
177 overcloud-onos: images/overcloud-full-onos.qcow2
178
179 images/overcloud-full-onos.qcow2: images/overcloud-full.qcow2
180         @echo "Building the Apex ONOS Overcloud Image"
181         @./overcloud-onos.sh
182
183 .PHONY: onos-rpm-clean
184 onos-rpm-clean:
185         @rpmbuild --clean opnfv-apex-onos.spec -D "release $(shell echo $RELEASE | tr -d '_-')"
186
187 opnfv-apex-onos.tar.gz: images/overcloud-full-onos.qcow2
188         tar -czf opnfv-apex-onos.tar.gz --xform="s:images/overcloud-full-onos.qcow2:opnfv-apex-onos-$(RPMVERS)/build/images/overcloud-full-onos.qcow2:" images/overcloud-full-onos.qcow2
189
190 .PHONY: onos-rpm-check
191 onos-rpm-check: opnfv-apex-onos.tar.gz
192         rpmbuild --clean -bi -bl opnfv-apex-onos.spec -D '_topdir %(echo `pwd`)' -D '_builddir %(echo `pwd`)' -D '_sourcedir %(echo `pwd`)' -D '_rpmdir %(echo `pwd`)' -D '_specdir %(echo `pwd`)' -D '_srcrpmdir %(echo `pwd`)' -D "release $(shell echo $(RELEASE) | tr -d '_-')"
193
194 .PHONY: onos-rpm
195 onos-rpm: opnfv-apex-onos.tar.gz $(RPMONO)
196
197 $(RPMONO):
198         @echo "Building the Apex ONOS RPM"
199         # build the overcloud RPM
200         rpmbuild --clean -ba opnfv-apex-onos.spec -D '_topdir %(echo `pwd`)' -D '_builddir %(echo `pwd`)' -D '_sourcedir %(echo `pwd`)' -D '_rpmdir %(echo `pwd`)' -D '_specdir %(echo `pwd`)' -D '_srcrpmdir %(echo `pwd`)' -D "release $(shell echo $(RELEASE) | tr -d '_-')"
201
202 ###############
203 #   ODL-SFC   #
204 ###############
205
206 .PHONY: overcloud-opendaylight-sfc-clean
207 overcloud-opendaylight-sfc-clean:
208         @rm -f images/overcloud-full-opendaylight-sfc.qcow2
209
210 .PHONY: overcloud-opendaylight-sfc
211 overcloud-opendaylight-sfc: images/overcloud-full-opendaylight-sfc.qcow2
212
213 images/overcloud-full-opendaylight-sfc.qcow2: images/overcloud-full-opendaylight.qcow2
214         @echo "Building the Apex OpenDaylight Overcloud Image"
215         @./overcloud-opendaylight-sfc.sh
216
217 opnfv-apex-opendaylight-sfc.tar.gz: images/overcloud-full-opendaylight-sfc.qcow2
218         tar -czf opnfv-apex-opendaylight-sfc.tar.gz --xform="s:images/overcloud-full-opendaylight-sfc.qcow2:opnfv-apex-opendaylight-sfc-$(RPMVERS)/build/images/overcloud-full-opendaylight-sfc.qcow2:" images/overcloud-full-opendaylight-sfc.qcow2
219
220 .PHONY: opendaylight-sfc-rpm-check
221 opendaylight-sfc-rpm-check: opnfv-apex-opendaylight-sfc.tar.gz
222         rpmbuild --clean -bi -bl opnfv-apex-opendaylight-sfc.spec -D '_topdir %(echo `pwd`)' -D '_builddir %(echo `pwd`)' -D '_sourcedir %(echo `pwd`)' -D '_rpmdir %(echo `pwd`)' -D '_specdir %(echo `pwd`)' -D '_srcrpmdir %(echo `pwd`)' -D "release $(shell echo $(RELEASE) | tr -d '_-')"
223
224 .PHONY: opendaylight-sfc-rpm
225 opendaylight-sfc-rpm: opnfv-apex-opendaylight-sfc.tar.gz $(RPMSFC)
226
227 $(RPMSFC):
228         @echo "Building the Apex OpenDaylight SFC RPM"
229         rpmbuild --clean -ba opnfv-apex-opendaylight-sfc.spec -D '_topdir %(echo `pwd`)' -D '_builddir %(echo `pwd`)' -D '_sourcedir %(echo `pwd`)' -D '_rpmdir %(echo `pwd`)' -D '_specdir %(echo `pwd`)' -D '_srcrpmdir %(echo `pwd`)' -D "release $(shell echo $(RELEASE) | tr -d '_-')"
230
231 ###############
232 #    ISO      #
233 ###############
234
235 $(CENTISO):
236         curl $(CENTDNLD) -z $(CENTISO) -o $(CENTISO) --verbose --silent --location
237
238 .PHONY: iso-clean
239 iso-clean:
240         @rm -Rf centos
241         @rm -Rf release
242         @rm -f $(ISO)
243
244 .PHONY: mount-centiso umount-centiso
245 mount-centiso: $(CENTISO)
246         @echo "Mounting CentOS ISO in $(CENTDIR)"
247         @mkdir -p $(CENTDIR)
248         @fuseiso $(CENTISO) $(CENTDIR)
249
250 umount-centiso:
251         @set +e
252         @echo "Unmounting CentOS ISO from $(CENTDIR)"
253         @fusermount -u $(CENTDIR)
254         @rmdir $(CENTDIR)
255         @set -e
256
257 .PHONY: iso
258 iso:    iso-clean images rpms $(CENTISO)
259         @echo "Building the Apex ISO"
260         @mkdir centos release
261         cd centos && bsdtar -xf ../$(shell basename $(CENTISO))
262         # modify the installer iso's contents
263         @chmod -R u+w centos
264         @cp -f isolinux.cfg centos/isolinux/isolinux.cfg
265         @ln $(RPMCOM) centos/Packages
266         @ln $(RPMUDR) centos/Packages
267         @ln $(RPMODL) centos/Packages
268         @ln $(RPMONO) centos/Packages
269         @ln $(RPMSFC) centos/Packages
270         # add packages to the centos packages
271         cd centos/Packages && yumdownloader openvswitch
272         cd centos/Packages && yumdownloader openstack-tripleo
273         cd centos/Packages && yumdownloader jq
274         cd centos/Packages && yumdownloader python34
275         cd centos/Packages && yumdownloader python34-libs
276         cd centos/Packages && yumdownloader python34-yaml
277         cd centos/Packages && yumdownloader python34-setuptools
278         cd centos/Packages && yumdownloader ipxe-roms-qemu
279         cd centos/Packages && curl -O https://radez.fedorapeople.org/python34-markupsafe-0.23-9.el7.centos.x86_64.rpm
280         cd centos/Packages && curl -O https://radez.fedorapeople.org/python3-jinja2-2.8-5.el7.centos.noarch.rpm
281         # regenerate yum repo data
282         @echo "Generating new yum metadata"
283         createrepo --update -g ../c7-opnfv-x86_64-comps.xml centos
284         # build the iso
285         @echo "Building OPNFV iso"
286         mkisofs -b isolinux/isolinux.bin -no-emul-boot -boot-load-size 4 -boot-info-table -V "OPNFV CentOS 7 x86_64" -R -J -v -T -o $(ISO) centos
287         isohybrid $(ISO)
288         @printf "\n\nISO is built at $(ISO)\n\n"
289
290 ###################
291 #  python3-jinja2  #
292 ###################
293
294 .PHONY: python3-jinja2
295 python3-jinja2: python3-markupsafe python-jinja2-2.8-5.fc24.src.rpm
296         curl -O http://ftp.linux.ncsu.edu/pub/fedora/linux//development/24/Everything/source/tree/Packages/p/python-jinja2-2.8-5.fc24.src.rpm
297         rpm2cpio python-jinja2-2.8-5.fc24.src.rpm | cpio -idmv
298         sed -i 's/python3-devel/python34-devel/' python-jinja2.spec
299         sed -i 's/python3-setuptools/python34-setuptools/' python-jinja2.spec
300         sed -i 's/python3-pytest/python34-pytest/' python-jinja2.spec
301         sed -i 's/python3-markupsafe/python34-markupsafe/' python-jinja2.spec
302         rpmbuild -ba python-jinja2.spec -D '_topdir %(echo `pwd`)' -D '_builddir %(echo `pwd`)' -D '_sourcedir %(echo `pwd`)' -D '_rpmdir %(echo `pwd`)' -D '_specdir %(echo `pwd`)' -D '_srcrpmdir %(echo `pwd`)' -D "with_python3 1"
303
304 .PHONY: python3-jinja2-clean
305 python3-jinja2-clean:
306         rm -f python-jinja2-2.8-5.fc24.src.rpm
307         rm -f python-jinja2.spec
308         rm -f Jinja2-2.8.tar.gz
309
310 ########################
311 #  python3-markupsafe  #
312 ########################
313
314 .PHONY: python3-markupsafe
315 python3-markupsafe: python-markupsafe-0.23-9.fc24.src.rpm
316         curl -O http://ftp.linux.ncsu.edu/pub/fedora/linux//development/24/Everything/source/tree/Packages/p/python-markupsafe-0.23-9.fc24.src.rpm
317         rpm2cpio python-markupsafe-0.23-9.fc24.src.rpm | cpio -idmv
318         sed -i 's/python3-devel/python34-devel/' python-markupsafe.spec
319         sed -i 's/python3-setuptools/python34-setuptools/' python-markupsafe.spec
320         sed -i 's/python3-pytest/python34-pytest/' python-markupsafe.spec
321         sed -i 's/python3-markupsafe/python34-markupsafe/' python-markupsafe.spec
322         rpmbuild -ba python-markupsafe.spec -D '_topdir %(echo `pwd`)' -D '_builddir %(echo `pwd`)' -D '_sourcedir %(echo `pwd`)' -D '_rpmdir %(echo `pwd`)' -D '_specdir %(echo `pwd`)' -D '_srcrpmdir %(echo `pwd`)' -D "with_python3 1"
323
324 .PHONY: python3-markupsafe-clean
325 python3-markupsafe-clean:
326         rm -f python-markupsafe-0.23-9.fc24.src.rpm
327         rm -f python-markupsafe.spec
328         rm -f MarkupSafe-0.23.tar.gz