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.2.1511/isos/x86_64/CentOS-7-x86_64-DVD-1511.iso
12 export CENTISO = $(shell pwd)/$(shell basename $(CENTDNLD))
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
22 all_networks="admin_network private_network storage_network external_network api_network"
30 clean: images-clean rpms-clean iso-clean
33 images: undercloud overcloud-full overcloud-opendaylight overcloud-onos overcloud-opendaylight-sfc
36 images-clean: undercloud-clean overcloud-full-clean overcloud-opendaylight-clean overcloud-onos-clean overcloud-opendaylight-sfc-clean
40 rpms: common-rpm undercloud-rpm opendaylight-rpm onos-rpm opendaylight-sfc-rpm
43 rpms-check: common-rpm-check undercloud-rpm-check opendaylight-rpm-check onos-rpm-check opendaylight-sfc-rpm-check
46 rpms-clean: common-rpm-clean undercloud-rpm-clean opendaylight-rpm-clean onos-rpm-clean opendaylight-sfc-rpm-clean
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
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 '_-')"
56 common-rpm: opnfv-apex-common.tar.gz $(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 '_-')"
69 # clean previous coverage data
70 rm -rf ../tests/.coverage
71 rm -rf ../tests/htmlcov
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
76 cd ../tests && coverage3 report --include '*lib/python/*' -m
78 #######################
80 #######################
82 .PHONY: python-pep8-check
91 .PHONY: undercloud-clean
93 @rm -f images/undercloud.*
96 undercloud: images/undercloud.qcow2
98 images/undercloud.qcow2:
99 @echo "Building the Apex Undercloud Image"
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
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 '_-')"
113 .PHONY: undercloud-rpm
114 undercloud-rpm: opnfv-apex-undercloud.tar.gz $(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 '_-')"
124 .PHONY: overcloud-full-clean
125 overcloud-full-clean:
126 @rm -rf images/overcloud-full.d
127 @rm -f images/overcloud-full.*
129 .PHONY: overcloud-full
130 overcloud-full: images/overcloud-full.qcow2
132 images/overcloud-full.qcow2:
133 @echo "Building the Apex Base Overcloud Image"
140 .PHONY: overcloud-opendaylight-clean
141 overcloud-opendaylight-clean:
142 @rm -f images/overcloud-full-opendaylight.qcow2
144 .PHONY: overcloud-opendaylight
145 overcloud-opendaylight: images/overcloud-full-opendaylight.qcow2
147 images/overcloud-full-opendaylight.qcow2: images/overcloud-full.qcow2
148 @echo "Building the Apex OpenDaylight Overcloud Image"
149 @./overcloud-opendaylight.sh
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
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 '_-')"
158 .PHONY: opendaylight-rpm
159 opendaylight-rpm: opnfv-apex.tar.gz $(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 '_-')"
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
176 .PHONY: overcloud-onos
177 overcloud-onos: images/overcloud-full-onos.qcow2
179 images/overcloud-full-onos.qcow2: images/overcloud-full.qcow2
180 @echo "Building the Apex ONOS Overcloud Image"
183 .PHONY: onos-rpm-clean
185 @rpmbuild --clean opnfv-apex-onos.spec -D "release $(shell echo $RELEASE | tr -d '_-')"
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
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 '_-')"
195 onos-rpm: opnfv-apex-onos.tar.gz $(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 '_-')"
206 .PHONY: overcloud-opendaylight-sfc-clean
207 overcloud-opendaylight-sfc-clean:
208 @rm -f images/overcloud-full-opendaylight-sfc.qcow2
210 .PHONY: overcloud-opendaylight-sfc
211 overcloud-opendaylight-sfc: images/overcloud-full-opendaylight-sfc.qcow2
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
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
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 '_-')"
224 .PHONY: opendaylight-sfc-rpm
225 opendaylight-sfc-rpm: opnfv-apex-opendaylight-sfc.tar.gz $(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 '_-')"
236 curl $(CENTDNLD) -z $(CENTISO) -o $(CENTISO) --verbose --silent --location
244 .PHONY: mount-centiso umount-centiso
245 mount-centiso: $(CENTISO)
246 @echo "Mounting CentOS ISO in $(CENTDIR)"
248 @fuseiso $(CENTISO) $(CENTDIR)
252 @echo "Unmounting CentOS ISO from $(CENTDIR)"
253 @fusermount -u $(CENTDIR)
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
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
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
288 @printf "\n\nISO is built at $(ISO)\n\n"
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"
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
310 ########################
311 # python3-markupsafe #
312 ########################
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"
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