Consolidate ODL SFC RPM into ODL RPM
[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)/rpm_specs/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
21
22 .PHONY: all
23 all: iso
24
25 .PHONY: clean
26 clean: images-clean rpms-clean iso-clean tacker-clean congress-clean vpp-clean
27
28 .PHONY: images
29 images: undercloud overcloud-full overcloud-opendaylight overcloud-onos
30
31 .PHONY: images-clean
32 images-clean: undercloud-clean overcloud-full-clean overcloud-opendaylight-clean overcloud-onos-clean
33         @rm -rf images/
34
35 .PHONY: rpms
36 rpms: common-rpm undercloud-rpm opendaylight-rpm onos-rpm
37
38 .PHONY: rpms-check
39 rpms-check: common-rpm-check undercloud-rpm-check opendaylight-rpm-check onos-rpm-check
40
41 .PHONY: rpms-clean
42 rpms-clean: common-rpm-clean undercloud-rpm-clean opendaylight-rpm-clean onos-rpm-clean
43
44 opnfv-apex-common.tar.gz:
45         pushd ../ && git archive --format=tar.gz --prefix=opnfv-apex-common-$(RPMVERS)/ HEAD > build/opnfv-apex-common.tar.gz
46
47 .PHONY: common-rpm-check
48 common-rpm-check: opnfv-apex-common.tar.gz
49         rpmbuild --clean -bi -bl rpm_specs/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 '_-')"
50
51 .PHONY: common-rpm
52 common-rpm: opnfv-apex-common.tar.gz $(RPMCOM)
53
54 $(RPMCOM):
55         @echo "Building the Apex Common RPM"
56         # build the common RPM
57         rpmbuild --clean -ba rpm_specs/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 '_-')"
58
59 ##################
60 #  PYTHON TESTS  #
61 ##################
62
63 .PHONY: python-tests
64 python-tests:
65         # clean previous coverage data
66         rm -rf ../tests/.coverage
67         rm -rf ../tests/htmlcov
68         # run nose tests
69         cd ../tests && PYTHONPATH=../lib/python/ nosetests-3.4 . --with-coverage --cover-package apex --cover-package apex_python_utils --cover-html --cover-min-percentage 90
70
71         # generate reports
72         cd ../tests && coverage3 report --include '*lib/python/*' -m
73
74 #######################
75 #  PYTHON PEP8 CHECK  #
76 #######################
77
78 .PHONY: python-pep8-check
79 python-pep8-check:
80         pep8 ../lib/python
81         pep8 ../tests
82
83 ###############
84 #  TACKER     #
85 ###############
86
87 .PHONY: tacker-clean
88
89 tacker-clean:
90         @rm -rf openstack-tacker-2015.2
91         @rm -f openstack-tacker.tar.gz
92
93 openstack-tacker.tar.gz:
94         @echo "Preparing the Tacker RPM prerequisites"
95         git clone http://github.com/trozet/tacker -b SFC_colorado openstack-tacker-2015.2
96         tar czf openstack-tacker.tar.gz openstack-tacker-2015.2
97
98 .PHONY: tacker-rpm
99 tacker-rpm: openstack-tacker.tar.gz openstack-tacker-2015.2-1.trozet.noarch.rpm
100
101 openstack-tacker-2015.2-1.trozet.noarch.rpm:
102         @echo "Building the Tacker RPM"
103         rpmbuild --clean -bb --target noarch rpm_specs/openstack-tacker.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`)'
104
105 #################
106 #  TACKERCLIENT #
107 #################
108
109 .PHONY: tackerclient-clean
110
111 tackerclient-clean:
112         @rm -rf python-tackerclient-2015.2
113         @rm -f python-tackerclient.tar.gz
114
115 python-tackerclient.tar.gz:
116         @echo "Preparing the TackerClient RPM prerequisites"
117         git clone http://github.com/trozet/python-tackerclient -b SFC_refactor python-tackerclient-2015.2
118         tar czf python-tackerclient.tar.gz python-tackerclient-2015.2
119
120 .PHONY: tackerclient-rpm
121 tackerclient-rpm: python-tackerclient.tar.gz python-tackerclient-2015.2-1.trozet.noarch.rpm
122
123 python-tackerclient-2015.2-1.trozet.noarch.rpm:
124         @echo "Building the TackerClient RPM"
125         rpmbuild --clean -bb --target noarch rpm_specs/python-tackerclient.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`)'
126
127 ###############
128 #  CONGRESS   #
129 ###############
130
131 .PHONY: congress-clean
132
133 congress-clean:
134         @rm -rf openstack-congress-2016.1
135         @rm -f openstack-congress.tar.gz
136
137 openstack-congress.tar.gz:
138         @echo "Preparing the Congress RPM prerequisites"
139         git clone http://github.com/openstack/congress -b stable/mitaka openstack-congress-2016.1
140         cd openstack-congress-2016.1 && curl -O https://radez.fedorapeople.org/openstack-congress.service
141         tar czf openstack-congress.tar.gz openstack-congress-2016.1
142
143 .PHONY: congress-rpm
144 congress-rpm: openstack-congress.tar.gz openstack-congress-2016.1-1.noarch.rpm
145
146 openstack-congress-2016.1-1.noarch.rpm:
147         @echo "Building the Congress RPM"
148         rpmbuild --clean -bb --target noarch rpm_specs/openstack-congress.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`)'
149
150 ###############
151 #     VPP     #
152 ###############
153
154 VPP_DIR = vpp
155 MAVEN = apache-maven-3.3.9
156 MAVEN_FILE = $(MAVEN)-bin.tar.gz
157
158 .PHONY: vpp-clean
159 vpp-clean:
160         @rm -f vpp-bin.tar.gz
161         @rm -rf vpp-bin vpp
162         @rm -rf honeycomb $(MAVEN) $(MAVEN_FILE) honeycomb-1.0.0-99.noarch.rpm
163         @rm -rf networking-vpp networking-vpp.noarch.rpm
164
165 .PHONY: vpp-build
166 vpp-build: vpp-bin.tar.gz
167
168 vpp-bin.tar.gz: vpp honeycomb $(MAVEN)
169         $(MAKE) -C $(VPP_DIR) UNATTENDED=yes install-dep bootstrap build pkg-rpm
170         $(MAKE) -C $(VPP_DIR)/build-root PLATFORM=vpp TAG=vpp_debug vpp-api-install
171         pushd vpp/vpp-api/python && python setup.py bdist
172         pushd vpp/build-root/build-vpp-native/vpp-api/java/ && ../../../../../$(MAVEN)/bin/mvn install:install-file -Dfile=jvpp-registry-16.12.jar -DgroupId=io.fd.vpp -DartifactId=jvpp-registry -Dversion=16.12-SNAPSHOT -Dpackaging=jar
173         pushd vpp/build-root/build-vpp-native/vpp-api/java/ && ../../../../../$(MAVEN)/bin/mvn install:install-file -Dfile=jvpp-core-16.12.jar -DgroupId=io.fd.vpp -DartifactId=jvpp-core -Dversion=16.12-SNAPSHOT -Dpackaging=jar
174         pushd honeycomb && ../$(MAVEN)/bin/mvn clean install -DskipTests
175         pushd honeycomb/packaging/rpm/ && BUILD_NUMBER=99 ./rpmbuild.sh
176         mkdir vpp-bin
177         mv vpp/build-root/*.rpm vpp-bin/
178         mv honeycomb/packaging/rpm/RPMS/noarch/*.rpm .
179         mv vpp/vpp-api/python/dist/*.tar.gz vpp-bin/
180         tar czf vpp-bin.tar.gz vpp-bin
181
182 vpp:
183         git clone https://gerrit.fd.io/r/vpp
184
185 honeycomb:
186         git clone https://gerrit.fd.io/r/p/honeycomb.git
187
188 $(MAVEN): $(MAVEN_FILE)
189         tar zxvf apache-maven-3.3.9-bin.tar.gz
190         cp mvn_settings.xml $(MAVEN)/conf/settings.xml
191
192 $(MAVEN_FILE):
193         wget http://www.webhostingjams.com/mirror/apache/maven/maven-3/3.3.9/binaries/apache-maven-3.3.9-bin.tar.gz
194
195 .PHONY: networking-vpp-rpm
196 networking-vpp-rpm: networking-vpp.noarch.rpm
197
198 networking-vpp.noarch.rpm: networking-vpp
199         pushd networking-vpp && rpmbuild --clean -bb ../rpm_specs/networking-vpp.spec
200         mv networking-vpp/build/rpm/noarch/*.rpm networking-vpp.noarch.rpm
201
202 networking-vpp:
203         git clone https://git.openstack.org/openstack/networking-vpp
204
205 ###############
206 #  UNDERCLOUD #
207 ###############
208
209 .PHONY: undercloud-clean
210 undercloud-clean:
211         @rm -f images/undercloud.*
212
213 .PHONY: undercloud
214 undercloud: images/undercloud.qcow2
215
216 images/undercloud.qcow2: tackerclient-rpm
217         @echo "Building the Apex Undercloud Image"
218         @./undercloud.sh
219
220 opnfv-apex-undercloud.tar.gz: images/undercloud.qcow2
221         @echo "Preparing the Apex Undercloud RPM prerequisites"
222         pushd ../ && git archive --format=tar --prefix=opnfv-apex-undercloud-$(RPMVERS)/ HEAD > build/opnfv-apex-undercloud.tar
223         tar -rf opnfv-apex-undercloud.tar \
224                --xform="s:images/undercloud.qcow2:opnfv-apex-undercloud-$(RPMVERS)/build/undercloud.qcow2:" images/undercloud.qcow2
225         gzip -f opnfv-apex-undercloud.tar
226
227 .PHONY: undercloud-rpm-check
228 undercloud-rpm-check: opnfv-apex-undercloud.tar.gz
229         rpmbuild --clean -bi -bl rpm_specs/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 '_-')"
230
231 .PHONY: undercloud-rpm
232 undercloud-rpm: opnfv-apex-undercloud.tar.gz $(RPMUDR)
233
234 $(RPMUDR):
235         @echo "Building the Apex Undercloud RPM"
236         rpmbuild --clean -ba rpm_specs/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 '_-')"
237
238 ###############
239 #  OVERCLOUD  #
240 ###############
241
242 .PHONY: overcloud-full-clean
243 overcloud-full-clean:
244         @rm -rf images/overcloud-full.d
245         @rm -f images/overcloud-full.*
246
247 .PHONY: overcloud-full
248 overcloud-full: images/overcloud-full.qcow2
249
250 images/overcloud-full.qcow2: tacker-rpm tackerclient-rpm congress-rpm networking-vpp-rpm
251         @echo "Building the Apex Base Overcloud Image"
252         @./overcloud-full.sh
253
254 ###############
255 #    ODL      #
256 ###############
257
258 .PHONY: overcloud-opendaylight-clean
259 overcloud-opendaylight-clean:
260         @rm -f images/overcloud-full-opendaylight.qcow2
261
262 .PHONY: overcloud-opendaylight
263 overcloud-opendaylight: images/overcloud-full-opendaylight.qcow2
264
265 images/overcloud-full-opendaylight.qcow2: images/overcloud-full.qcow2
266         @echo "Building the Apex OpenDaylight Overcloud Image"
267         @./overcloud-opendaylight.sh
268
269 opnfv-apex.tar.gz: images/overcloud-full-opendaylight.qcow2
270         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
271
272 .PHONY: opendaylight-rpm-check
273 opendaylight-rpm-check: opnfv-apex.tar.gz
274         rpmbuild --clean -bi -bl rpm_specs/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 '_-')"
275
276 .PHONY: opendaylight-rpm
277 opendaylight-rpm: opnfv-apex.tar.gz $(RPMODL)
278
279 $(RPMODL):
280         @echo "Building the Apex OpenDaylight RPM"
281         # build the overcloud RPM
282         rpmbuild --clean -ba rpm_specs/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 '_-')"
283
284 ###############
285 #    ONOS     #
286 ###############
287
288 .PHONY: overcloud-onos-clean
289 overcloud-onos-clean:
290         @rm -f images/overcloud-full-onos.qcow2
291         @rm -rf images/puppet-onos
292         @rm -f images/puppet-onos.tar.gz
293
294 .PHONY: overcloud-onos
295 overcloud-onos: images/overcloud-full-onos.qcow2
296
297 images/overcloud-full-onos.qcow2: images/overcloud-full.qcow2
298         @echo "Building the Apex ONOS Overcloud Image"
299         @./overcloud-onos.sh
300
301 .PHONY: onos-rpm-clean
302 onos-rpm-clean:
303         @rpmbuild --clean rpm_specs/opnfv-apex-onos.spec -D "release $(shell echo $RELEASE | tr -d '_-')"
304
305 opnfv-apex-onos.tar.gz: images/overcloud-full-onos.qcow2
306         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
307
308 .PHONY: onos-rpm-check
309 onos-rpm-check: opnfv-apex-onos.tar.gz
310         rpmbuild --clean -bi -bl rpm_specs/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 '_-')"
311
312 .PHONY: onos-rpm
313 onos-rpm: opnfv-apex-onos.tar.gz $(RPMONO)
314
315 $(RPMONO):
316         @echo "Building the Apex ONOS RPM"
317         # build the overcloud RPM
318         rpmbuild --clean -ba rpm_specs/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 '_-')"
319
320 ###############
321 #    ISO      #
322 ###############
323
324 $(CENTISO):
325         curl $(CENTDNLD) -z $(CENTISO) -o $(CENTISO) --verbose --silent --location
326
327 .PHONY: iso-clean
328 iso-clean:
329         @rm -Rf centos
330         @rm -Rf release
331         @rm -f $(ISO)
332
333 .PHONY: mount-centiso umount-centiso
334 mount-centiso: $(CENTISO)
335         @echo "Mounting CentOS ISO in $(CENTDIR)"
336         @mkdir -p $(CENTDIR)
337         @fuseiso $(CENTISO) $(CENTDIR)
338
339 umount-centiso:
340         @set +e
341         @echo "Unmounting CentOS ISO from $(CENTDIR)"
342         @fusermount -u $(CENTDIR)
343         @rmdir $(CENTDIR)
344         @set -e
345
346 .PHONY: iso
347 iso:    iso-clean images rpms $(CENTISO)
348         @echo "Building the Apex ISO"
349         @mkdir centos release
350         cd centos && bsdtar -xf ../$(shell basename $(CENTISO))
351         # modify the installer iso's contents
352         @chmod -R u+w centos
353         @cp -f isolinux.cfg centos/isolinux/isolinux.cfg
354         @ln $(RPMCOM) centos/Packages
355         @ln $(RPMUDR) centos/Packages
356         @ln $(RPMODL) centos/Packages
357         @ln $(RPMONO) centos/Packages
358         # add packages to the centos packages
359         cd centos/Packages && yumdownloader openvswitch
360         cd centos/Packages && yumdownloader openstack-tripleo
361         cd centos/Packages && yumdownloader jq
362         cd centos/Packages && yumdownloader python34
363         cd centos/Packages && yumdownloader python34-libs
364         cd centos/Packages && yumdownloader python34-yaml
365         cd centos/Packages && yumdownloader python34-setuptools
366         cd centos/Packages && yumdownloader ipxe-roms-qemu
367         cd centos/Packages && curl -O https://radez.fedorapeople.org/python34-markupsafe-0.23-9.el7.centos.x86_64.rpm
368         cd centos/Packages && curl -O https://radez.fedorapeople.org/python3-jinja2-2.8-5.el7.centos.noarch.rpm
369         cd centos/Packages && curl -O http://artifacts.opnfv.org/apex/dependencies/python3-ipmi-0.3.0-1.noarch.rpm
370         # regenerate yum repo data
371         @echo "Generating new yum metadata"
372         createrepo --update -g ../c7-opnfv-x86_64-comps.xml centos
373         # build the iso
374         @echo "Building OPNFV iso"
375         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
376         isohybrid $(ISO)
377         @printf "\n\nISO is built at $(ISO)\n\n"
378
379 ####################
380 #  python3-jinja2  #
381 ####################
382
383 .PHONY: python3-jinja2
384 python3-jinja2: python3-markupsafe python-jinja2-2.8-5.fc24.src.rpm
385         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
386         rpm2cpio python-jinja2-2.8-5.fc24.src.rpm | cpio -idmv
387         sed -i 's/python3-devel/python34-devel/' python-jinja2.spec
388         sed -i 's/python3-setuptools/python34-setuptools/' python-jinja2.spec
389         sed -i 's/python3-pytest/python34-pytest/' python-jinja2.spec
390         sed -i 's/python3-markupsafe/python34-markupsafe/' python-jinja2.spec
391         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"
392
393 .PHONY: python3-jinja2-clean
394 python3-jinja2-clean:
395         rm -f python-jinja2-2.8-5.fc24.src.rpm
396         rm -f python-jinja2.spec
397         rm -f Jinja2-2.8.tar.gz
398
399 ########################
400 #  python3-markupsafe  #
401 ########################
402
403 .PHONY: python3-markupsafe
404 python3-markupsafe: python-markupsafe-0.23-9.fc24.src.rpm
405         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
406         rpm2cpio python-markupsafe-0.23-9.fc24.src.rpm | cpio -idmv
407         sed -i 's/python3-devel/python34-devel/' python-markupsafe.spec
408         sed -i 's/python3-setuptools/python34-setuptools/' python-markupsafe.spec
409         sed -i 's/python3-pytest/python34-pytest/' python-markupsafe.spec
410         sed -i 's/python3-markupsafe/python34-markupsafe/' python-markupsafe.spec
411         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"
412
413 .PHONY: python3-markupsafe-clean
414 python3-markupsafe-clean:
415         rm -f python-markupsafe-0.23-9.fc24.src.rpm
416         rm -f python-markupsafe.spec
417         rm -f MarkupSafe-0.23.tar.gz