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.4.1708/isos/x86_64/CentOS-7-x86_64-DVD-1708.iso
14 export RPM_DIST = $(shell rpm -E %dist)
16 export NETVPP_VERS := $(shell grep Version $(shell pwd)/rpm_specs/networking-vpp.spec | head -n 1 | awk '{ print $$2 }')
17 export NETVPP_REPO := $(shell awk -F\= '/^netvpp_repo/ {print $$2}' variables.sh )
18 export NETVPP_BRANCH := $(shell awk -F\= '/^netvpp_branch/ {print $$2}' variables.sh )
19 export NETVPP_COMMIT := $(shell git ls-remote $(NETVPP_REPO) $(NETVPP_BRANCH) | awk '{print substr($$1,1,7)}')
21 export RELRPMVERS = $(shell grep Version $(shell pwd)/rpm_specs/opnfv-apex-release.spec | head -n 1 | awk '{ print $$2 }')
22 export RPMVERS = $(shell grep Version $(shell pwd)/rpm_specs/opnfv-apex.spec | head -n 1 | awk '{ print $$2 }')
24 export BUILD_ROOT = $(shell pwd)
25 export BUILD_DIR = $(shell dirname $$(pwd))/.build
26 export CACHE_DIR = $(shell dirname $$(pwd))/.cache
27 export PATCHES_DIR = $(BUILD_ROOT)/patches
28 export QUAGGA_BUILD_DIR = $(BUILD_DIR)/quagga_build_dir
29 export QUAGGA_RPMS_DIR = $(QUAGGA_BUILD_DIR)/rpmbuild
30 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)'
32 export RPMREL = $(BUILD_DIR)/noarch/opnfv-apex-release-$(RPMVERS)-$(shell echo ${RELEASE} | tr -d '_-').noarch.rpm
33 export RPMCOM = $(BUILD_DIR)/noarch/python34-opnfv-apex-$(RPMVERS)-$(shell echo ${RELEASE} | tr -d '_-').noarch.rpm
34 export RPMUDR = $(BUILD_DIR)/noarch/opnfv-apex-undercloud-$(RPMVERS)-$(shell echo ${RELEASE} | tr -d '_-').noarch.rpm
35 export RPMODL = $(BUILD_DIR)/noarch/opnfv-apex-$(RPMVERS)-$(shell echo ${RELEASE} | tr -d '_-').noarch.rpm
36 export RPMONO = $(BUILD_DIR)/noarch/opnfv-apex-onos-$(RPMVERS)-$(shell echo ${RELEASE} | tr -d '_-').noarch.rpm
37 export ISO = $(BUILD_DIR)/release/OPNFV-CentOS-7-x86_64-${RELEASE}.iso
38 export CENTISO = $(BUILD_DIR)/$(shell basename $(CENTDNLD))
52 images: undercloud overcloud-full overcloud-opendaylight
55 rpms: images common-rpm undercloud-rpm opendaylight-rpm
58 rpms-check: release-rpm-check common-rpm-check undercloud-rpm-check opendaylight-rpm-check
62 rm -rf $(BUILD_DIR)/noarch
63 rm -rf $(BUILD_DIR)/BUILDROOT
65 $(BUILD_DIR)/opnfv-apex-release.tar.gz:
67 pushd ../ && git archive --format=tar.gz --prefix=opnfv-apex-release-$(RELRPMVERS)/ HEAD > $(BUILD_DIR)/opnfv-apex-release.tar.gz
69 .PHONY: release-rpm-check
70 release-rpm-check: $(BUILD_DIR)/opnfv-apex-release.tar.gz
71 rpmbuild --clean -bi -bl rpm_specs/opnfv-apex-release.spec $(RPM_DIR_ARGS) -D "_release $(shell echo $(RELEASE) | tr -d '_-')"
74 release-rpm: $(BUILD_DIR)/opnfv-apex-release.tar.gz $(RPMREL)
77 @echo "Building the Apex Release RPM"
78 # build the release RPM
79 rpmbuild --clean -ba rpm_specs/opnfv-apex-release.spec $(RPM_DIR_ARGS) -D "_release $(shell echo $(RELEASE) | tr -d '_-')"
81 $(BUILD_DIR)/opnfv-apex-common.tar.gz:
82 pushd ../ && git archive --format=tar.gz --prefix=opnfv-apex-$(RPMVERS)/ HEAD > $(BUILD_DIR)/opnfv-apex-common.tar.gz
84 .PHONY: common-rpm-check
85 common-rpm-check: $(BUILD_DIR)/opnfv-apex-common.tar.gz
86 rpmbuild --clean -bi -bl rpm_specs/opnfv-apex-common.spec $(RPM_DIR_ARGS) -D "_release $(shell echo $(RELEASE) | tr -d '_-')"
89 common-rpm: $(BUILD_DIR)/opnfv-apex-common.tar.gz $(RPMCOM)
92 @echo "Building the Apex Common RPM"
93 # build the common RPM
94 rpmbuild --clean -ba rpm_specs/opnfv-apex-common.spec $(RPM_DIR_ARGS) -D "_release $(shell echo $(RELEASE) | tr -d '_-')"
104 #######################
105 # PYTHON PEP8 CHECK #
106 #######################
108 .PHONY: python-pep8-check
118 @echo "Running yamllint against all .yaml files"
119 cd ../ && yamllint $(shell cd ../ && git ls-tree -r HEAD --name-only | grep 'yaml$$')
126 @echo "Running rpmlint against all RPM spec files"
127 rpmlint rpm_specs/*.spec
133 $(BUILD_DIR)/python-networking-vpp.tar.gz:
134 @echo "Preparing the networking-vpp RPM prerequisites"
135 git clone $(NETVPP_REPO) -b $(NETVPP_BRANCH) $(BUILD_DIR)/python-networking-vpp-$(NETVPP_VERS)
136 tar czf $(BUILD_DIR)/python-networking-vpp.tar.gz -C $(BUILD_DIR) python-networking-vpp-$(NETVPP_VERS)
138 .PHONY: networking-vpp-rpm
139 networking-vpp-rpm: $(BUILD_DIR)/noarch/python-networking-vpp-*.noarch.rpm
141 $(BUILD_DIR)/noarch/python-networking-vpp-*.noarch.rpm: $(BUILD_DIR)/python-networking-vpp.tar.gz
142 @echo "Building the Networking VPP RPM"
143 rpmbuild --clean -ba --target noarch rpm_specs/networking-vpp.spec $(RPM_DIR_ARGS) -D 'git .git$(NETVPP_COMMIT)'
150 undercloud: $(BUILD_DIR)/undercloud.qcow2
152 $(BUILD_DIR)/undercloud.qcow2:
153 @echo "Building the Apex Undercloud Image"
156 $(BUILD_DIR)/opnfv-apex-undercloud.tar.gz: $(BUILD_DIR)/undercloud.qcow2
157 @echo "Preparing the Apex Undercloud RPM prerequisites"
158 pushd ../ && git archive --format=tar --prefix=opnfv-apex-undercloud-$(RPMVERS)/ HEAD > $(BUILD_DIR)/opnfv-apex-undercloud.tar
159 tar -rf $(BUILD_DIR)/opnfv-apex-undercloud.tar \
160 --xform="s:.*undercloud.qcow2:opnfv-apex-undercloud-$(RPMVERS)/build/undercloud.qcow2:" $(BUILD_DIR)/undercloud.qcow2
161 gzip -f $(BUILD_DIR)/opnfv-apex-undercloud.tar
163 .PHONY: undercloud-rpm-check
164 undercloud-rpm-check: $(BUILD_DIR)/opnfv-apex-undercloud.tar.gz
165 rpmbuild --clean -bi -bl rpm_specs/opnfv-apex-undercloud.spec $(RPM_DIR_ARGS) -D "_release $(shell echo $(RELEASE) | tr -d '_-')"
167 .PHONY: undercloud-rpm
168 undercloud-rpm: $(BUILD_DIR)/opnfv-apex-undercloud.tar.gz $(RPMUDR)
171 @echo "Building the Apex Undercloud RPM"
172 rpmbuild --clean -ba rpm_specs/opnfv-apex-undercloud.spec $(RPM_DIR_ARGS) -D "_release $(shell echo $(RELEASE) | tr -d '_-')"
178 .PHONY: overcloud-full
179 overcloud-full: $(BUILD_DIR)/overcloud-full.qcow2
181 $(BUILD_DIR)/overcloud-full.qcow2: $(BUILD_DIR)/noarch/python-networking-vpp-*.noarch.rpm
182 @echo "Building the Apex Base Overcloud Image"
189 .PHONY: overcloud-opendaylight
190 overcloud-opendaylight: $(BUILD_DIR)/overcloud-full-opendaylight.qcow2
192 $(BUILD_DIR)/overcloud-full-opendaylight.qcow2: $(BUILD_DIR)/overcloud-full.qcow2
193 @echo "Building the Apex OpenDaylight Overcloud Image"
194 @./overcloud-opendaylight.sh
196 $(BUILD_DIR)/opnfv-apex.tar.gz: $(BUILD_DIR)/overcloud-full-opendaylight.qcow2
197 tar -czf $(BUILD_DIR)/opnfv-apex.tar.gz --xform="s:.*/:opnfv-apex-$(RPMVERS)/build/:" $(BUILD_DIR)/overcloud-full-opendaylight.qcow2 $(BUILD_DIR)/overcloud-full.initrd $(BUILD_DIR)/overcloud-full.vmlinuz
199 .PHONY: opendaylight-rpm-check
200 opendaylight-rpm-check: $(BUILD_DIR)/opnfv-apex.tar.gz
201 rpmbuild --clean -bi -bl rpm_specs/opnfv-apex.spec $(RPM_DIR_ARGS) -D "_release $(shell echo $(RELEASE) | tr -d '_-')"
203 .PHONY: opendaylight-rpm
204 opendaylight-rpm: $(BUILD_DIR)/opnfv-apex.tar.gz $(RPMODL)
207 @echo "Building the Apex OpenDaylight RPM"
208 # build the overcloud RPM
209 rpmbuild --clean -ba rpm_specs/opnfv-apex.spec $(RPM_DIR_ARGS) -D "_release $(shell echo $(RELEASE) | tr -d '_-')"
215 .PHONY: overcloud-onos
216 overcloud-onos: $(BUILD_DIR)/overcloud-full-onos.qcow2
218 $(BUILD_DIR)/overcloud-full-onos.qcow2: $(BUILD_DIR)/overcloud-full.qcow2
219 @echo "Building the Apex ONOS Overcloud Image"
222 $(BUILD_DIR)/opnfv-apex-onos.tar.gz: $(BUILD_DIR)/overcloud-full-onos.qcow2
223 tar -czf $(BUILD_DIR)/opnfv-apex-onos.tar.gz --xform="s:.*/:opnfv-apex-onos-$(RPMVERS)/build/:" $(BUILD_DIR)/overcloud-full-onos.qcow2
225 .PHONY: onos-rpm-check
226 onos-rpm-check: $(BUILD_DIR)/opnfv-apex-onos.tar.gz
227 rpmbuild --clean -bi -bl rpm_specs/opnfv-apex-onos.spec $(RPM_DIR_ARGS) -D "_release $(shell echo $(RELEASE) | tr -d '_-')"
230 onos-rpm: $(BUILD_DIR)/opnfv-apex-onos.tar.gz $(RPMONO)
233 @echo "Building the Apex ONOS RPM"
234 # build the overcloud RPM
235 rpmbuild --clean -ba rpm_specs/opnfv-apex-onos.spec $(RPM_DIR_ARGS) -D "_release $(shell echo $(RELEASE) | tr -d '_-')"
242 curl $(CENTDNLD) -z $(CENTISO) -o $(CENTISO) --verbose --silent --location
245 @rm -Rf $(BUILD_DIR)/centos
246 @rm -Rf $(BUILD_DIR)/release
249 .PHONY: mount-centiso umount-centiso
250 mount-centiso: $(CENTISO)
251 @echo "Mounting CentOS ISO in $(CENTDIR)"
253 @fuseiso $(CENTISO) $(CENTDIR)
257 @echo "Unmounting CentOS ISO from $(CENTDIR)"
258 @fusermount -u $(CENTDIR)
263 iso: iso-clean images rpms $(CENTISO)
264 @echo "Building the Apex ISO"
265 @mkdir $(BUILD_DIR)/centos $(BUILD_DIR)/release
266 cd $(BUILD_DIR)/centos && bsdtar -xf ../$(shell basename $(CENTISO))
267 # modify the installer iso's contents
268 @chmod -R u+w $(BUILD_DIR)/centos
269 @cp -f isolinux.cfg $(BUILD_DIR)/centos/isolinux/isolinux.cfg
270 @ln $(RPMCOM) $(BUILD_DIR)/centos/Packages
271 @ln $(RPMUDR) $(BUILD_DIR)/centos/Packages
272 @ln $(RPMODL) $(BUILD_DIR)/centos/Packages
273 # add packages to the centos packages
274 cd $(BUILD_DIR)/centos/Packages && yumdownloader openvswitch jq python34 python34-libs python34-PyYAML python34-setuptools
275 cd $(BUILD_DIR)/centos/Packages && yumdownloader python34-jinja2 python34-markupsafe ansible python34-six python34-cffi
276 cd $(BUILD_DIR)/centos/Packages && yumdownloader ipxe-roms-qemu python34-idna python34-pycparser python-crypto python-httplib2
277 cd $(BUILD_DIR)/centos/Packages && yumdownloader python-jinja2 python-keyczar python-paramiko sshpass python-ecdsa python34-ply
278 cd $(BUILD_DIR)/centos/Packages && yumdownloader libvirt-python python-lxml python-passlib python2-jmespath
279 cd $(BUILD_DIR)/centos/Packages && yumdownloader python34-urllib3 python34-pysocks python34-requests python34-chardet
280 cd $(BUILD_DIR)/centos/Packages && curl -O http://artifacts.opnfv.org/apex/dependencies/python3-ipmi-0.3.0-1.noarch.rpm
281 cd $(BUILD_DIR)/centos/Packages && curl -O http://artifacts.opnfv.org/apex/dependencies/python34-asn1crypto-0.22.0-1.el7.centos.noarch.rpm
282 cd $(BUILD_DIR)/centos/Packages && curl -O http://artifacts.opnfv.org/apex/dependencies/python34-cryptography-2.0.3-1.el7.centos.x86_64.rpm
283 cd $(BUILD_DIR)/centos/Packages && curl -O http://artifacts.opnfv.org/apex/dependencies/python34-iptables-0.12.0-1.el7.centos.x86_64.rpm
284 cd $(BUILD_DIR)/centos/Packages && curl -O http://artifacts.opnfv.org/apex/dependencies/python34-libvirt-3.6.0-1.el7.centos.x86_64.rpm
285 cd $(BUILD_DIR)/centos/Packages && curl -O http://artifacts.opnfv.org/apex/dependencies/python34-pbr-3.1.1-1.el7.centos.x86_64.rpm
286 cd $(BUILD_DIR)/centos/Packages && curl -O http://artifacts.opnfv.org/apex/dependencies/python34-PrettyTable-0.7.2-1.el7.centos.noarch.rpm
287 cd $(BUILD_DIR)/centos/Packages && curl -O http://artifacts.opnfv.org/apex/dependencies/python34-pycrypto-2.6.1-1.el7.centos.x86_64.rpm
288 cd $(BUILD_DIR)/centos/Packages && curl -O http://artifacts.opnfv.org/apex/dependencies/python34-pyghmi-1.0.22-1.el7.centos.noarch.rpm
289 cd $(BUILD_DIR)/centos/Packages && curl -O http://artifacts.opnfv.org/apex/dependencies/python34-virtualbmc-1.2.0-1.el7.centos.noarch.rpm
290 cd $(BUILD_DIR)/centos/Packages && curl -O http://artifacts.opnfv.org/apex/dependencies/python34-smmap2-2.0.3-1.el7.centos.noarch.rpm
291 cd $(BUILD_DIR)/centos/Packages && curl -O http://artifacts.opnfv.org/apex/dependencies/python34-pygerrit2-2.0.3-1.el7.centos.noarch.rpm
292 cd $(BUILD_DIR)/centos/Packages && curl -O http://artifacts.opnfv.org/apex/dependencies/python34-gitdb2-2.0.3-1.el7.centos.noarch.rpm
293 cd $(BUILD_DIR)/centos/Packages && curl -O http://artifacts.opnfv.org/apex/dependencies/python34-GitPython-2.1.7-1.el7.centos.noarch.rpm
294 # regenerate yum repo data
295 @echo "Generating new yum metadata"
296 createrepo --update -g $(BUILD_ROOT)/c7-opnfv-x86_64-comps.xml $(BUILD_DIR)/centos
298 @echo "Building OPNFV iso"
299 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
301 @printf "\n\nISO is built at $(ISO)\n\n"
308 @rm -rf $(QUAGGA_BUILD_DIR)
309 @sudo yum -y remove zrpc* quagga* c-capnproto* thrift*
315 quagga-zrpc: quagga-clean thrift-rpm capnproto-rpm quagga-rpm zrpc-rpm
321 zrpc-rpm: quagga-rpm $(QUAGGA_RPMS_DIR)/zrpcd-%.x86_64.rpm
323 $(QUAGGA_RPMS_DIR)/zrpcd-%.x86_64.rpm:
324 @echo "Building ZRPC RPM"
325 @./build_quagga.sh -a zrpc
331 quagga-rpm: $(QUAGGA_RPMS_DIR)/RPMS/x86_64/quagga-1.1.0_%.el7.centos.x86_64.rpm
333 $(QUAGGA_RPMS_DIR)/RPMS/x86_64/quagga-1.1.0_%.el7.centos.x86_64.rpm:
334 @echo "Building Quagga RPM"
335 @./build_quagga.sh -a quagga
340 .PHONY: capnproto-rpm
341 capnproto-rpm: $(QUAGGA_RPMS_DIR)/RPMS/x86_64/c-capnproto-%.x86_64.rpm
343 $(QUAGGA_RPMS_DIR)/RPMS/x86_64/c-capnproto-%.x86_64.rpm:
344 @echo "Building capnproto RPMs"
345 @./build_quagga.sh -a capnproto
352 thrift-rpm: $(QUAGGA_RPMS_DIR)/RPMS/x86_64/thrift-%.x86_64.rpm
354 $(QUAGGA_RPMS_DIR)/RPMS/x86_64/thrift-%.x86_64.rpm:
355 @echo "Building Thrift RPMs"
356 @./build_quagga.sh -a thrift