1 ##############################################################################
2 # Copyright (c) 2016 Red Hat Inc.
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 ##############################################################################
10 export USE_MASTER = ""
11 export CENTDNLD = http://mirrors.cat.pdx.edu/centos/7.3.1611/isos/x86_64/CentOS-7-x86_64-DVD-1611.iso
14 export RPM_DIST = $(shell rpm -E %dist)
16 export TACKER_REPO := $(shell awk -F\= '/^tacker_repo/ {print $$2}' variables.sh )
17 export TACKER_BRANCH := $(shell awk -F\= '/^tacker_branch/ {print $$2}' variables.sh )
18 export TACKER_COMMIT := $(shell git ls-remote $(TACKER_REPO) $(TACKER_BRANCH) | awk '{print substr($$1,1,7)}')
20 export TACKERCLIENT_REPO := $(shell awk -F\= '/^tackerclient_repo/ {print $$2}' variables.sh )
21 export TACKERCLIENT_BRANCH := $(shell awk -F\= '/^tackerclient_branch/ {print $$2}' variables.sh )
22 export TACKERCLIENT_COMMIT := $(shell git ls-remote $(TACKERCLIENT_REPO) $(TACKERCLIENT_BRANCH) | awk '{print substr($$1,1,7)}')
24 export CONGRESS_REPO := $(shell awk -F\= '/^congress_repo/ {print $$2}' variables.sh )
25 export CONGRESS_BRANCH := $(shell awk -F\= '/^congress_branch/ {print $$2}' variables.sh )
26 export CONGRESS_COMMIT := $(shell git ls-remote $(CONGRESS_REPO) $(CONGRESS_BRANCH) | awk '{print substr($$1,1,7)}')
28 export NETVPP_VERS := $(shell grep Version $(shell pwd)/rpm_specs/networking-vpp.spec | head -n 1 | awk '{ print $$2 }')
29 export NETVPP_REPO := $(shell awk -F\= '/^netvpp_repo/ {print $$2}' variables.sh )
30 export NETVPP_BRANCH := $(shell awk -F\= '/^netvpp_branch/ {print $$2}' variables.sh )
31 export NETVPP_COMMIT := $(shell git ls-remote $(NETVPP_REPO) $(NETVPP_BRANCH) | awk '{print substr($$1,1,7)}')
33 export RELRPMVERS = $(shell grep Version $(shell pwd)/rpm_specs/opnfv-apex-release.spec | head -n 1 | awk '{ print $$2 }')
34 export RPMVERS = $(shell grep Version $(shell pwd)/rpm_specs/opnfv-apex.spec | head -n 1 | awk '{ print $$2 }')
36 export BUILD_ROOT = $(shell pwd)
37 export BUILD_DIR = $(shell dirname $$(pwd))/.build
38 export CACHE_DIR = $(shell dirname $$(pwd))/.cache
39 export PATCHES_DIR = $(BUILD_ROOT)/patches
40 export QUAGGA_BUILD_DIR = $(BUILD_DIR)/quagga_build_dir
41 export QUAGGA_RPMS_DIR = $(QUAGGA_BUILD_DIR)/rpmbuild
42 export RPM_DIR_ARGS = -D '_topdir $(BUILD_DIR)' -D '_builddir $(BUILD_DIR)' -D '_sourcedir $(BUILD_DIR)' -D '_rpmdir $(BUILD_DIR)' -D '_specdir $(BUILD_DIR)' -D '_srcrpmdir $(BUILD_DIR)'
44 export RPMREL = $(BUILD_DIR)/noarch/opnfv-apex-release-$(RPMVERS)-$(shell echo ${RELEASE} | tr -d '_-').noarch.rpm
45 export RPMCOM = $(BUILD_DIR)/noarch/opnfv-apex-common-$(RPMVERS)-$(shell echo ${RELEASE} | tr -d '_-').noarch.rpm
46 export RPMUDR = $(BUILD_DIR)/noarch/opnfv-apex-undercloud-$(RPMVERS)-$(shell echo ${RELEASE} | tr -d '_-').noarch.rpm
47 export RPMODL = $(BUILD_DIR)/noarch/opnfv-apex-$(RPMVERS)-$(shell echo ${RELEASE} | tr -d '_-').noarch.rpm
48 export RPMONO = $(BUILD_DIR)/noarch/opnfv-apex-onos-$(RPMVERS)-$(shell echo ${RELEASE} | tr -d '_-').noarch.rpm
49 export ISO = $(BUILD_DIR)/release/OPNFV-CentOS-7-x86_64-${RELEASE}.iso
50 export CENTISO = $(BUILD_DIR)/$(shell basename $(CENTDNLD))
64 images: undercloud overcloud-full overcloud-opendaylight overcloud-onos
67 rpms: common-rpm undercloud-rpm opendaylight-rpm onos-rpm
70 rpms-check: release-rpm-check common-rpm-check undercloud-rpm-check opendaylight-rpm-check onos-rpm-check
74 rm -rf $(BUILD_DIR)/noarch
75 rm -rf $(BUILD_DIR)/BUILDROOT
77 $(BUILD_DIR)/opnfv-apex-release.tar.gz:
79 pushd ../ && git archive --format=tar.gz --prefix=opnfv-apex-release-$(RELRPMVERS)/ HEAD > $(BUILD_DIR)/opnfv-apex-release.tar.gz
81 .PHONY: release-rpm-check
82 release-rpm-check: $(BUILD_DIR)/opnfv-apex-release.tar.gz
83 rpmbuild --clean -bi -bl rpm_specs/opnfv-apex-release.spec $(RPM_DIR_ARGS) -D "release $(shell echo $(RELEASE) | tr -d '_-')"
86 release-rpm: $(BUILD_DIR)/opnfv-apex-release.tar.gz $(RPMREL)
89 @echo "Building the Apex Release RPM"
90 # build the release RPM
91 rpmbuild --clean -ba rpm_specs/opnfv-apex-release.spec $(RPM_DIR_ARGS) -D "release $(shell echo $(RELEASE) | tr -d '_-')"
93 $(BUILD_DIR)/opnfv-apex-common.tar.gz:
94 pushd ../ && git archive --format=tar.gz --prefix=opnfv-apex-common-$(RPMVERS)/ HEAD > $(BUILD_DIR)/opnfv-apex-common.tar.gz
96 .PHONY: common-rpm-check
97 common-rpm-check: $(BUILD_DIR)/opnfv-apex-common.tar.gz
98 rpmbuild --clean -bi -bl rpm_specs/opnfv-apex-common.spec $(RPM_DIR_ARGS) -D "release $(shell echo $(RELEASE) | tr -d '_-')"
101 common-rpm: $(BUILD_DIR)/opnfv-apex-common.tar.gz $(RPMCOM)
104 @echo "Building the Apex Common RPM"
105 # build the common RPM
106 rpmbuild --clean -ba rpm_specs/opnfv-apex-common.spec $(RPM_DIR_ARGS) -D "release $(shell echo $(RELEASE) | tr -d '_-')"
114 # clean previous coverage data
115 rm -rf ../tests/.coverage
116 rm -rf ../tests/htmlcov
118 cd ../tests && PYTHONPATH=../lib/python/ nosetests-3.4 . --with-coverage --cover-package apex --cover-package apex_python_utils --cover-html --cover-min-percentage 90
121 cd ../tests && coverage3 report --include '*lib/python/*' -m
123 #######################
124 # PYTHON PEP8 CHECK #
125 #######################
127 .PHONY: python-pep8-check
136 $(BUILD_DIR)/openstack-tacker.tar.gz:
137 @echo "Preparing the Tacker RPM prerequisites"
138 git clone $(TACKER_REPO) -b $(TACKER_BRANCH) $(BUILD_DIR)/openstack-tacker-2016.2
139 cp rpm_specs/openstack-tacker-server.service $(BUILD_DIR)/openstack-tacker-2016.2
140 tar czf $(BUILD_DIR)/openstack-tacker.tar.gz -C $(BUILD_DIR) openstack-tacker-2016.2
143 tacker-rpm: $(BUILD_DIR)/openstack-tacker.tar.gz $(BUILD_DIR)/noarch/openstack-tacker-2016.2-1.git$(TACKER_COMMIT).noarch.rpm
145 $(BUILD_DIR)/noarch/openstack-tacker-2016.2-1.git$(TACKER_COMMIT).noarch.rpm:
146 @echo "Building the Tacker RPM"
147 rpmbuild --clean -ba --target noarch rpm_specs/openstack-tacker.spec $(RPM_DIR_ARGS) -D 'git .git$(TACKER_COMMIT)'
153 $(BUILD_DIR)/python-tackerclient.tar.gz:
154 @echo "Preparing the TackerClient RPM prerequisites"
155 git clone $(TACKERCLIENT_REPO) -b $(TACKERCLIENT_BRANCH) $(BUILD_DIR)/python-tackerclient-2016.2
156 tar czf $(BUILD_DIR)/python-tackerclient.tar.gz -C $(BUILD_DIR) python-tackerclient-2016.2
158 .PHONY: tackerclient-rpm
159 tackerclient-rpm: $(BUILD_DIR)/python-tackerclient.tar.gz $(BUILD_DIR)/noarch/python-tackerclient-2016.2-1.git$(TACKERCLIENT_COMMIT).noarch.rpm
161 $(BUILD_DIR)/noarch/python-tackerclient-2016.2-1.git$(TACKERCLIENT_COMMIT).noarch.rpm:
162 @echo "Building the TackerClient RPM"
163 rpmbuild --clean -ba --target noarch rpm_specs/python-tackerclient.spec $(RPM_DIR_ARGS) -D 'git .git$(TACKERCLIENT_COMMIT)'
169 .PHONY: congress-clean
171 @rm -rf $(BUILD_DIR)/openstack-congress-2016.2
172 @rm -f $(BUILD_DIR)/openstack-congress.tar.gz
174 $(BUILD_DIR)/openstack-congress.tar.gz:
175 @echo "Preparing the Congress RPM prerequisites"
176 git clone $(CONGRESS_REPO) -b $(CONGRESS_BRANCH) $(BUILD_DIR)/openstack-congress-2016.2
177 cp rpm_specs/openstack-congress-server.service $(BUILD_DIR)/openstack-congress-2016.2
178 tar czf $(BUILD_DIR)/openstack-congress.tar.gz -C $(BUILD_DIR) openstack-congress-2016.2
181 congress-rpm: $(BUILD_DIR)/noarch/openstack-congress-2016.2-1.git$(CONGRESS_COMMIT).noarch.rpm
183 $(BUILD_DIR)/noarch/openstack-congress-2016.2-1.git$(CONGRESS_COMMIT).noarch.rpm: $(BUILD_DIR)/openstack-congress.tar.gz
184 @echo "Building the Congress RPM"
185 rpmbuild --clean -ba --target noarch rpm_specs/openstack-congress.spec $(RPM_DIR_ARGS) -D 'git .git$(CONGRESS_COMMIT)'
191 $(BUILD_DIR)/python-networking-vpp.tar.gz:
192 @echo "Preparing the networking-vpp RPM prerequisites"
193 git clone $(NETVPP_REPO) $(BUILD_DIR)/python-networking-vpp-$(NETVPP_VERS)
194 tar czf $(BUILD_DIR)/python-networking-vpp.tar.gz -C $(BUILD_DIR) python-networking-vpp-$(NETVPP_VERS)
196 .PHONY: networking-vpp-rpm
197 networking-vpp-rpm: $(BUILD_DIR)/noarch/python-networking-vpp-$(NETVPP_VERS)-1.git$(NETVPP_COMMIT)$(RPM_DIST).noarch.rpm
199 $(BUILD_DIR)/noarch/python-networking-vpp-$(NETVPP_VERS)-1.git$(NETVPP_COMMIT)$(RPM_DIST).noarch.rpm: $(BUILD_DIR)/python-networking-vpp.tar.gz
200 @echo "Building the Networking VPP RPM"
201 rpmbuild --clean -ba --target noarch rpm_specs/networking-vpp.spec $(RPM_DIR_ARGS) -D 'git .git$(NETVPP_COMMIT)'
208 undercloud: $(BUILD_DIR)/undercloud.qcow2
210 $(BUILD_DIR)/undercloud.qcow2: tackerclient-rpm
211 @echo "Building the Apex Undercloud Image"
214 $(BUILD_DIR)/opnfv-apex-undercloud.tar.gz: $(BUILD_DIR)/undercloud.qcow2
215 @echo "Preparing the Apex Undercloud RPM prerequisites"
216 pushd ../ && git archive --format=tar --prefix=opnfv-apex-undercloud-$(RPMVERS)/ HEAD > $(BUILD_DIR)/opnfv-apex-undercloud.tar
217 tar -rf $(BUILD_DIR)/opnfv-apex-undercloud.tar \
218 --xform="s:.*undercloud.qcow2:opnfv-apex-undercloud-$(RPMVERS)/build/undercloud.qcow2:" $(BUILD_DIR)/undercloud.qcow2
219 gzip -f $(BUILD_DIR)/opnfv-apex-undercloud.tar
221 .PHONY: undercloud-rpm-check
222 undercloud-rpm-check: $(BUILD_DIR)/opnfv-apex-undercloud.tar.gz
223 rpmbuild --clean -bi -bl rpm_specs/opnfv-apex-undercloud.spec $(RPM_DIR_ARGS) -D "release $(shell echo $(RELEASE) | tr -d '_-')"
225 .PHONY: undercloud-rpm
226 undercloud-rpm: $(BUILD_DIR)/opnfv-apex-undercloud.tar.gz $(RPMUDR)
229 @echo "Building the Apex Undercloud RPM"
230 rpmbuild --clean -ba rpm_specs/opnfv-apex-undercloud.spec $(RPM_DIR_ARGS) -D "release $(shell echo $(RELEASE) | tr -d '_-')"
236 .PHONY: overcloud-full
237 overcloud-full: $(BUILD_DIR)/overcloud-full.qcow2
239 $(BUILD_DIR)/overcloud-full.qcow2: congress-rpm tacker-rpm networking-vpp-rpm
240 @echo "Building the Apex Base Overcloud Image"
247 .PHONY: overcloud-opendaylight
248 overcloud-opendaylight: $(BUILD_DIR)/overcloud-full-opendaylight.qcow2
250 $(BUILD_DIR)/overcloud-full-opendaylight.qcow2: $(BUILD_DIR)/overcloud-full.qcow2
251 @echo "Building the Apex OpenDaylight Overcloud Image"
252 @./overcloud-opendaylight.sh
254 $(BUILD_DIR)/opnfv-apex.tar.gz: $(BUILD_DIR)/overcloud-full-opendaylight.qcow2
255 tar -czf $(BUILD_DIR)/opnfv-apex.tar.gz --xform="s:.*overcloud-full-opendaylight.qcow2:opnfv-apex-$(RPMVERS)/build/overcloud-full-opendaylight.qcow2:" $(BUILD_DIR)/overcloud-full-opendaylight.qcow2
257 .PHONY: opendaylight-rpm-check
258 opendaylight-rpm-check: $(BUILD_DIR)/opnfv-apex.tar.gz
259 rpmbuild --clean -bi -bl rpm_specs/opnfv-apex.spec $(RPM_DIR_ARGS) -D "release $(shell echo $(RELEASE) | tr -d '_-')"
261 .PHONY: opendaylight-rpm
262 opendaylight-rpm: $(BUILD_DIR)/opnfv-apex.tar.gz $(RPMODL)
265 @echo "Building the Apex OpenDaylight RPM"
266 # build the overcloud RPM
267 rpmbuild --clean -ba rpm_specs/opnfv-apex.spec $(RPM_DIR_ARGS) -D "release $(shell echo $(RELEASE) | tr -d '_-')"
273 .PHONY: overcloud-onos
274 overcloud-onos: $(BUILD_DIR)/overcloud-full-onos.qcow2
276 $(BUILD_DIR)/overcloud-full-onos.qcow2: $(BUILD_DIR)/overcloud-full.qcow2
277 @echo "Building the Apex ONOS Overcloud Image"
280 $(BUILD_DIR)/opnfv-apex-onos.tar.gz: $(BUILD_DIR)/overcloud-full-onos.qcow2
281 tar -czf $(BUILD_DIR)/opnfv-apex-onos.tar.gz --xform="s:.*overcloud-full-onos.qcow2:opnfv-apex-onos-$(RPMVERS)/build/overcloud-full-onos.qcow2:" $(BUILD_DIR)/overcloud-full-onos.qcow2
283 .PHONY: onos-rpm-check
284 onos-rpm-check: $(BUILD_DIR)/opnfv-apex-onos.tar.gz
285 rpmbuild --clean -bi -bl rpm_specs/opnfv-apex-onos.spec $(RPM_DIR_ARGS) -D "release $(shell echo $(RELEASE) | tr -d '_-')"
288 onos-rpm: $(BUILD_DIR)/opnfv-apex-onos.tar.gz $(RPMONO)
291 @echo "Building the Apex ONOS RPM"
292 # build the overcloud RPM
293 rpmbuild --clean -ba rpm_specs/opnfv-apex-onos.spec $(RPM_DIR_ARGS) -D "release $(shell echo $(RELEASE) | tr -d '_-')"
300 curl $(CENTDNLD) -z $(CENTISO) -o $(CENTISO) --verbose --silent --location
303 @rm -Rf $(BUILD_DIR)/centos
304 @rm -Rf $(BUILD_DIR)/release
307 .PHONY: mount-centiso umount-centiso
308 mount-centiso: $(CENTISO)
309 @echo "Mounting CentOS ISO in $(CENTDIR)"
311 @fuseiso $(CENTISO) $(CENTDIR)
315 @echo "Unmounting CentOS ISO from $(CENTDIR)"
316 @fusermount -u $(CENTDIR)
321 iso: iso-clean images rpms $(CENTISO)
322 @echo "Building the Apex ISO"
323 @mkdir $(BUILD_DIR)/centos $(BUILD_DIR)/release
324 cd $(BUILD_DIR)/centos && bsdtar -xf ../$(shell basename $(CENTISO))
325 # modify the installer iso's contents
326 @chmod -R u+w $(BUILD_DIR)/centos
327 @cp -f isolinux.cfg $(BUILD_DIR)/centos/isolinux/isolinux.cfg
328 @ln $(RPMCOM) $(BUILD_DIR)/centos/Packages
329 @ln $(RPMUDR) $(BUILD_DIR)/centos/Packages
330 @ln $(RPMODL) $(BUILD_DIR)/centos/Packages
331 # add packages to the centos packages
332 cd $(BUILD_DIR)/centos/Packages && yumdownloader openvswitch openstack-tripleo jq python34 python34-libs python34-yaml python34-setuptools ipxe-roms-qemu
333 cd $(BUILD_DIR)/centos/Packages && curl -O https://radez.fedorapeople.org/python34-markupsafe-0.23-9.el7.centos.x86_64.rpm
334 cd $(BUILD_DIR)/centos/Packages && curl -O https://radez.fedorapeople.org/python3-jinja2-2.8-5.el7.centos.noarch.rpm
335 cd $(BUILD_DIR)/centos/Packages && curl -O http://artifacts.opnfv.org/apex/dependencies/python3-ipmi-0.3.0-1.noarch.rpm
336 # regenerate yum repo data
337 @echo "Generating new yum metadata"
338 createrepo --update -g $(BUILD_ROOT)/c7-opnfv-x86_64-comps.xml $(BUILD_DIR)/centos
340 @echo "Building OPNFV iso"
341 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) $(BUILD_DIR)/centos
343 @printf "\n\nISO is built at $(ISO)\n\n"
349 .PHONY: python3-jinja2
350 python3-jinja2: python3-markupsafe
352 && curl -O -L artifacts.opnfv.org/apex/dependencies/python-jinja2-2.8-5.fc24.src.rpm \
353 && rpm2cpio python-jinja2-2.8-5.fc24.src.rpm | cpio -idmv \
354 && sed -i 's/python3-devel/python34-devel/' python-jinja2.spec \
355 && sed -i 's/python3-setuptools/python34-setuptools/' python-jinja2.spec \
356 && sed -i 's/python3-pytest/python34-pytest/' python-jinja2.spec \
357 && sed -i 's/python3-markupsafe/python34-markupsafe/' python-jinja2.spec \
358 && rpmbuild -ba python-jinja2.spec $(RPM_DIR_ARGS) -D "with_python3 1"
360 ########################
361 # python3-markupsafe #
362 ########################
364 .PHONY: python3-markupsafe
367 && curl -O -L artifacts.opnfv.org/apex/dependencies/python-markupsafe-0.23-9.fc24.src.rpm \
368 && rpm2cpio python-markupsafe-0.23-9.fc24.src.rpm | cpio -idmv \
369 && sed -i 's/python3-devel/python34-devel/' python-markupsafe.spec \
370 && sed -i 's/python3-setuptools/python34-setuptools/' python-markupsafe.spec \
371 && sed -i 's/python3-pytest/python34-pytest/' python-markupsafe.spec \
372 && sed -i 's/python3-markupsafe/python34-markupsafe/' python-markupsafe.spec \
373 && rpmbuild -ba python-markupsafe.spec $(RPM_DIR_ARGS) -D "with_python3 1"
380 @rm -rf $(QUAGGA_BUILD_DIR)
381 @sudo yum -y remove zrpc* quagga* c-capnproto* thrift*
387 quagga-zrpc: quagga-clean thrift-rpm capnproto-rpm quagga-rpm zrpc-rpm
393 zrpc-rpm: quagga-rpm $(QUAGGA_RPMS_DIR)/zrpcd-%.x86_64.rpm
395 $(QUAGGA_RPMS_DIR)/zrpcd-%.x86_64.rpm:
396 @echo "Building ZRPC RPM"
397 @./build_quagga.sh -a zrpc
403 quagga-rpm: $(QUAGGA_RPMS_DIR)/RPMS/x86_64/quagga-1.1.0_%.el7.centos.x86_64.rpm
405 $(QUAGGA_RPMS_DIR)/RPMS/x86_64/quagga-1.1.0_%.el7.centos.x86_64.rpm:
406 @echo "Building Quagga RPM"
407 @./build_quagga.sh -a quagga
412 .PHONY: capnproto-rpm
413 capnproto-rpm: $(QUAGGA_RPMS_DIR)/RPMS/x86_64/c-capnproto-%.x86_64.rpm
415 $(QUAGGA_RPMS_DIR)/RPMS/x86_64/c-capnproto-%.x86_64.rpm:
416 @echo "Building capnproto RPMs"
417 @./build_quagga.sh -a capnproto
424 thrift-rpm: $(QUAGGA_RPMS_DIR)/RPMS/x86_64/thrift-%.x86_64.rpm
426 $(QUAGGA_RPMS_DIR)/RPMS/x86_64/thrift-%.x86_64.rpm:
427 @echo "Building Thrift RPMs"
428 @./build_quagga.sh -a thrift