1 ##############################################################################
2 # Copyright (c) 2015 Ericsson AB and others.
3 # stefan.k.berg@ericsson.com
4 # jonas.bjurel@ericsson.com
6 # All rights reserved. This program and the accompanying materials
7 # are made available under the terms of the Apache License, Version 2.0
8 # which accompanies this distribution, and is available at
9 # http://www.apache.org/licenses/LICENSE-2.0
10 ##############################################################################
13 ############################################################################
14 # BEGIN of variables to customize
17 export UNIT_TEST = FALSE
18 export INTERACTIVE = TRUE
19 export CENTDNLD = http://mirrors.cat.pdx.edu/centos/7.1.1503/isos/x86_64/CentOS-7-x86_64-DVD-1503-01.iso
20 export ISOSRC = file:$(shell pwd)/CentOS-7-x86_64-DVD-1503-01.iso
21 export ISOCACHE = $(shell pwd)/$(shell basename $(ISOSRC))
22 export PRODNO = "OPNFV_BGS"
23 export REVSTATE = "P0000"
24 export NEWISO = $(shell pwd)/release/OPNFV-CentOS-7-x86_64-${REVSTATE}.iso
25 export VBOXDNLD = http://download.virtualbox.org/virtualbox/rpm/el/7.1/x86_64/VirtualBox-4.3-4.3.26_98988_el7-1.x86_64.rpm
26 export VBOXRPM = $(shell pwd)/VirtualBox-4.3-4.3.26_98988_el7-1.x86_64.rpm
27 export VAGRANTDNLD = https://dl.bintray.com/mitchellh/vagrant/vagrant_1.7.2_x86_64.rpm
28 export VAGRANTRPM = $(shell pwd)/vagrant_1.7.2_x86_64.rpm
29 export GENESISRPM = $(shell pwd)/x86_64/opnfv-genesis-0.1-1.x86_64.rpm
31 # Note! Invoke with "make REVSTATE=RXXXX all" to make release build!
32 # Invoke with ICOCACHE=/full/path/to/iso if cached ISO is in non-standard location.
35 export BUILD_BASE := $(shell pwd)
36 export CACHE_DIR := $(BUILD_BASE)/cache
37 export VERSION_FILE := $(BUILD_BASE)/.versions
38 export TOPDIR := $(shell pwd)
40 CENTDIR := $(TOPDIR)/centiso
42 # END of variables to customize
43 #############################################################################
45 SUBCLEAN = $(addsuffix .clean,$(SUBDIRS))
50 @echo "Versions of cached build results built by" $(shell hostname) "at" $(shell date -u) > $(VERSION_FILE)
51 @echo "cache.mk" $(shell md5sum $(BUILD_BASE)/cache.mk | cut -f1 -d " ") >> $(VERSION_FILE)
52 @echo "config.mk" $(shell md5sum $(BUILD_BASE)/config.mk | cut -f1 -d " ") >> $(VERSION_FILE)
54 ############################################################################
55 # BEGIN of Include definitions
60 # END Include definitions
61 #############################################################################
64 test -s $(ISOCACHE) || { wget -nv $(CENTDNLD) ; }
67 test -s $(VBOXRPM) || { wget -nv $(VBOXDNLD) ; }
70 test -s $(VAGRANTRPM) || { wget -nv $(VAGRANTDNLD) ; }
72 .PHONY: mount-centiso umount-centiso
73 mount-centiso: $(ISOCACHE)
74 @echo "Mounting CentOS ISO in $(CENTDIR)"
76 @fuseiso $(ISOCACHE) $(CENTDIR)
80 @echo "Unmounting CentOS ISO from $(CENTDIR)"
81 @fusermount -u $(CENTDIR)
85 .PHONY: build-clean $(SUBCLEAN)
86 build-clean: $(SUBCLEAN)
92 .PHONY: clean $(SUBCLEAN)
93 clean: clean-cache $(SUBCLEAN)
98 @rm -f $(BUILD_BASE)/.versions
100 $(SUBCLEAN): %.clean:
101 $(MAKE) -C $* -f Makefile clean
105 rpmbuild --clean opnfv-genesis.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`)'
109 pushd ../../ && git archive --format=tar --prefix=opnfv-genesis-0.1/ HEAD | gzip > foreman/build/opnfv-genesis.tar.gz
110 rpmbuild -ba opnfv-genesis.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`)'
114 # Todo: Make things smarter - we shouldn't need to clean everything
115 # betwen make invocations.
117 iso: build-clean $(ISOCACHE) $(VBOXRPM) $(VAGRANTRPM) rpm
119 @mkdir centos release
120 cp -r $(CENTDIR)/* centos
122 # modify the installer iso's contents
123 @cp -f isolinux.cfg centos/isolinux/isolinux.cfg
124 @cp $(VBOXRPM) centos/Packages
125 @cp $(VAGRANTRPM) centos/Packages
126 @cp $(GENESISRPM) centos/Packages
127 # regenerate yum repo data
128 @echo "Generating new yum metadata"
129 createrepo --update -g ../c7-opnfv-x86_64-comps.xml centos
131 @echo "Building OPNFV iso"
132 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 $(NEWISO) centos
133 @printf "\n\nISO is built at $(NEWISO)\n\n"