adding clarifications to installation document
[apex.git] / build / Makefile
1 ##############################################################################
2 # Copyright (c) 2015 Ericsson AB and others.
3 # stefan.k.berg@ericsson.com
4 # jonas.bjurel@ericsson.com
5 # dradez@redhat.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 ##############################################################################
11
12 SHELL = /bin/bash
13 ############################################################################
14 # BEGIN of variables to customize
15 #
16 #Input args
17 export UNIT_TEST = FALSE
18 export USE_MASTER = ""
19 export INTERACTIVE = TRUE
20 export CENTDNLD = http://mirrors.cat.pdx.edu/centos/7.1.1503/isos/x86_64/CentOS-7-x86_64-DVD-1503-01.iso
21 export ISOSRC = file:$(shell pwd)/CentOS-7-x86_64-DVD-1503-01.iso
22 export ISOCACHE = $(shell pwd)/$(shell basename $(ISOSRC))
23 export PRODNO = "OPNFV_BGS"
24 export REVSTATE = "0000"
25 export NEWISO = $(shell pwd)/release/OPNFV-CentOS-7-x86_64-${REVSTATE}.iso
26 export RPMVERS = $(shell grep Version $(shell pwd)/opnfv-apex.spec | awk '{ print $$2 }')
27 export APEXRPMCOM = $(shell pwd)/noarch/opnfv-apex-common-$(RPMVERS)-$(shell echo ${REVSTATE} | tr -d '_-').noarch.rpm
28 export APEXRPMINS = $(shell pwd)/noarch/opnfv-apex-undercloud-$(RPMVERS)-$(shell echo ${REVSTATE} | tr -d '_-').noarch.rpm
29 export APEXRPM = $(shell pwd)/noarch/opnfv-apex-$(RPMVERS)-$(shell echo ${REVSTATE} | tr -d '_-').noarch.rpm
30
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.
33
34 #Build variables
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)
39
40 CENTDIR := $(TOPDIR)/centiso
41 #
42 # END of variables to customize
43 #############################################################################
44
45 SUBCLEAN = $(addsuffix .clean,$(SUBDIRS))
46
47
48 .PHONY: all
49 all: iso
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)
53
54 ############################################################################
55 # BEGIN of Include definitions
56 #
57 include config.mk
58 include cache.mk
59 #
60 # END Include definitions
61 #############################################################################
62
63 $(ISOCACHE):
64         test -s $(ISOCACHE) || { wget -nv $(CENTDNLD) ; }
65
66 .PHONY: mount-centiso umount-centiso
67 mount-centiso: $(ISOCACHE)
68         @echo "Mounting CentOS ISO in $(CENTDIR)"
69         @mkdir -p $(CENTDIR)
70         @fuseiso $(ISOCACHE) $(CENTDIR)
71
72 umount-centiso:
73         @set +e
74         @echo "Unmounting CentOS ISO from $(CENTDIR)"
75         @fusermount -u $(CENTDIR)
76         @rmdir $(CENTDIR)
77         @set -e
78
79 .PHONY: build-clean $(SUBCLEAN)
80 build-clean: instack-clean $(SUBCLEAN)
81         @rm -Rf centos
82         @rm -Rf release
83         @rm -Rf newiso
84         @rm -f $(NEWISO)
85
86 .PHONY: clean $(SUBCLEAN)
87 clean:  clean-cache build-clean $(SUBCLEAN)
88         @rm -f *.iso
89         @rm -Rf release
90         @rm -Rf newiso
91         @rm -f $(NEWISO)
92         @rm -f $(BUILD_BASE)/.versions
93
94 $(SUBCLEAN): %.clean:
95         $(MAKE) -C $* -f Makefile clean
96
97 .PHONY: rpm-clean
98 rpm-clean:
99         @rm -f build/opnfv-apex-common.tar.gz
100         @rm -f build/opnfv-apex-undercloud.tar.gz
101         @rm -f build/opnfv-apex.tar.gz
102
103 .PHONY: rpm
104 rpm:
105         # build the common RPM
106         pushd ../ && git archive --format=tar.gz --prefix=opnfv-apex-common-$(RPMVERS)/ HEAD > build/opnfv-apex-common.tar.gz
107         rpmbuild -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 $(REVSTATE) | tr -d '_-')"
108         # build the undercloud RPM
109         tar -czf opnfv-apex-undercloud.tar.gz \
110                --xform="s:stack/instack.qcow2:opnfv-apex-undercloud-$(RPMVERS)/build/instack.qcow2:" \
111                --xform="s:instack.xml:opnfv-apex-undercloud-$(RPMVERS)/build/instack.xml:" \
112                --xform="s:baremetalbrbm_brbm1_brbm2_brbm3_0.xml:opnfv-apex-undercloud-$(RPMVERS)/build/baremetalbrbm_brbm1_brbm2_brbm3_0.xml:" \
113                --xform="s:baremetalbrbm_brbm1_brbm2_brbm3_1.xml:opnfv-apex-undercloud-$(RPMVERS)/build/baremetalbrbm_brbm1_brbm2_brbm3_1.xml:" \
114                --xform="s:baremetalbrbm_brbm1_brbm2_brbm3_2.xml:opnfv-apex-undercloud-$(RPMVERS)/build/baremetalbrbm_brbm1_brbm2_brbm3_2.xml:" \
115                --xform="s:baremetalbrbm_brbm1_brbm2_brbm3_3.xml:opnfv-apex-undercloud-$(RPMVERS)/build/baremetalbrbm_brbm1_brbm2_brbm3_3.xml:" \
116                --xform="s:baremetalbrbm_brbm1_brbm2_brbm3_4.xml:opnfv-apex-undercloud-$(RPMVERS)/build/baremetalbrbm_brbm1_brbm2_brbm3_4.xml:" \
117                --xform="s:brbm-net.xml:opnfv-apex-undercloud-$(RPMVERS)/build/brbm-net.xml:" \
118                --xform="s:brbm1-net.xml:opnfv-apex-undercloud-$(RPMVERS)/build/brbm1-net.xml:" \
119                --xform="s:brbm2-net.xml:opnfv-apex-undercloud-$(RPMVERS)/build/brbm2-net.xml:" \
120                --xform="s:brbm3-net.xml:opnfv-apex-undercloud-$(RPMVERS)/build/brbm3-net.xml:" \
121                --xform="s:default-pool.xml:opnfv-apex-undercloud-$(RPMVERS)/build/default-pool.xml:" \
122                --xform="s:network-environment.yaml:opnfv-apex-undercloud-$(RPMVERS)/build/network-environment.yaml:" \
123                --xform="s:nics/controller.yaml:opnfv-apex-undercloud-$(RPMVERS)/build/nics/controller.yaml:" \
124                --xform="s:nics/compute.yaml:opnfv-apex-undercloud-$(RPMVERS)/build/nics/compute.yaml:" \
125                --xform="s:nics/controller_private.yaml:opnfv-apex-undercloud-$(RPMVERS)/build/nics/controller_private.yaml:" \
126                --xform="s:nics/compute_private.yaml:opnfv-apex-undercloud-$(RPMVERS)/build/nics/compute_private.yaml:" \
127                --xform="s:nics/controller_storage.yaml:opnfv-apex-undercloud-$(RPMVERS)/build/nics/controller_storage.yaml:" \
128                --xform="s:nics/compute_storage.yaml:opnfv-apex-undercloud-$(RPMVERS)/build/nics/compute_storage.yaml:" \
129                --xform="s:nics/controller_private_storage.yaml:opnfv-apex-undercloud-$(RPMVERS)/build/nics/controller_private_storage.yaml:" \
130                --xform="s:nics/compute_private_storage.yaml:opnfv-apex-undercloud-$(RPMVERS)/build/nics/compute_private_storage.yaml:" \
131                --xform="s:nics/compute_br-ex.yaml:opnfv-apex-undercloud-$(RPMVERS)/build/nics/compute_br-ex.yaml:" \
132                --xform="s:nics/compute_private_br-ex.yaml:opnfv-apex-undercloud-$(RPMVERS)/build/nics/compute_private_br-ex.yaml:" \
133                --xform="s:nics/compute_storage_br-ex.yaml:opnfv-apex-undercloud-$(RPMVERS)/build/nics/compute_storage_br-ex.yaml:" \
134                --xform="s:nics/compute_private_storage_br-ex.yaml:opnfv-apex-undercloud-$(RPMVERS)/build/nics/compute_private_storage_br-ex.yaml:" \
135                --xform="s:nics/compute_no-public-ip.yaml:opnfv-apex-undercloud-$(RPMVERS)/build/nics/compute_no-public-ip.yaml:" \
136                --xform="s:nics/compute_private_no-public-ip.yaml:opnfv-apex-undercloud-$(RPMVERS)/build/nics/compute_private_no-public-ip.yaml:" \
137                --xform="s:nics/compute_storage_no-public-ip.yaml:opnfv-apex-undercloud-$(RPMVERS)/build/nics/compute_storage_no-public-ip.yaml:" \
138                --xform="s:nics/compute_private_storage_no-public-ip.yaml:opnfv-apex-undercloud-$(RPMVERS)/build/nics/compute_private_storage_no-public-ip.yaml:" \
139                --xform="s:nics/compute_br-ex_no-public-ip.yaml:opnfv-apex-undercloud-$(RPMVERS)/build/nics/compute_br-ex_no-public-ip.yaml:" \
140                --xform="s:nics/compute_private_br-ex_no-public-ip.yaml:opnfv-apex-undercloud-$(RPMVERS)/build/nics/compute_private_br-ex_no-public-ip.yaml:" \
141                --xform="s:nics/compute_storage_br-ex_no-public-ip.yaml:opnfv-apex-undercloud-$(RPMVERS)/build/nics/compute_storage_br-ex_no-public-ip.yaml:" \
142                --xform="s:nics/compute_private_storage_br-ex_no-public-ip.yaml:opnfv-apex-undercloud-$(RPMVERS)/build/nics/compute_private_storage_br-ex_no-public-ip.yaml:" \
143                --xform="s:instackenv-virt.json:opnfv-apex-undercloud-$(RPMVERS)/build/instackenv-virt.json:" \
144                --xform="s:instackenv.json.example:opnfv-apex-undercloud-$(RPMVERS)/build/instackenv.json.example:" \
145                stack/instack.qcow2 instack.xml baremetalbrbm_brbm1_brbm2_brbm3_0.xml baremetalbrbm_brbm1_brbm2_brbm3_1.xml \
146                baremetalbrbm_brbm1_brbm2_brbm3_2.xml baremetalbrbm_brbm1_brbm2_brbm3_3.xml baremetalbrbm_brbm1_brbm2_brbm3_4.xml \
147                brbm-net.xml brbm1-net.xml brbm2-net.xml brbm3-net.xml default-pool.xml instackenv-virt.json network-environment.yaml \
148                nics/controller.yaml nics/compute.yaml nics/controller_private.yaml nics/compute_private.yaml  \
149                nics/compute_br-ex.yaml nics/compute_private_br-ex.yaml nics/compute_storage_br-ex.yaml nics/compute_private_storage_br-ex.yaml \
150                nics/compute_no-public-ip.yaml nics/compute_private_no-public-ip.yaml nics/compute_storage_no-public-ip.yaml nics/compute_private_storage_no-public-ip.yaml \
151                nics/compute_br-ex_no-public-ip.yaml nics/compute_private_br-ex_no-public-ip.yaml nics/compute_storage_br-ex_no-public-ip.yaml nics/compute_private_storage_br-ex_no-public-ip.yaml \
152            nics/controller_storage.yaml nics/compute_storage.yaml nics/controller_private_storage.yaml    \
153            nics/compute_private_storage.yaml instackenv-virt.json instackenv.json.example
154         rpmbuild -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 $(REVSTATE) | tr -d '_-')"
155         # build the overcloud RPM
156         tar -czf opnfv-apex.tar.gz --xform="s:stack/overcloud-full-opendaylight.qcow2:opnfv-apex-$(RPMVERS)/build/stack/overcloud-full-opendaylight.qcow2:" stack/overcloud-full-opendaylight.qcow2
157         rpmbuild -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 $(REVSTATE) | tr -d '_-')"
158         tar -czf opnfv-apex-opendaylight-sfc.tar.gz --xform="s:stack/overcloud-full-opendaylight-sfc.qcow2:opnfv-apex-opendaylight-sfc-$(RPMVERS)/build/stack/overcloud-full-opendaylight-sfc.qcow2:" stack/overcloud-full-opendaylight-sfc.qcow2
159         rpmbuild -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 $(REVSTATE) | tr -d '_-')"
160
161 .PHONY: instack
162 instack:
163         @./instack.sh $(USE_MASTER)
164
165 .PHONY: instack-clean
166 instack-clean:
167         rm -f instackenv-virt.json
168         rm -f baremetalbrbm_brbm1_brbm2_brbm3_0.xml
169         rm -f baremetalbrbm_brbm1_brbm2_brbm3_1.xml
170         rm -f baremetalbrbm_brbm1_brbm2_brbm3_2.xml
171         rm -f baremetalbrbm_brbm1_brbm2_brbm3_3.xml
172         rm -f baremetalbrbm_brbm1_brbm2_brbm3_4.xml
173         rm -f instack.xml
174         rm -rf stack/onos
175
176 .PHONY: iso
177 iso:    build-clean instack rpm $(ISOCACHE)
178         @mkdir centos release
179         cd centos && bsdtar -xf ../$(shell basename $(ISOSRC))
180         # modify the installer iso's contents
181         @cp -f isolinux.cfg centos/isolinux/isolinux.cfg
182         @cp $(APEXRPMCOM) centos/Packages
183         @cp $(APEXRPMINS) centos/Packages
184         @cp $(APEXRPM) centos/Packages
185         cd centos/Packages && yumdownloader openvswitch
186         # regenerate yum repo data
187         @echo "Generating new yum metadata"
188         createrepo --update -g ../c7-opnfv-x86_64-comps.xml centos
189         # build the iso
190         @echo "Building OPNFV iso"
191         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
192         isohybrid $(NEWISO)
193         @printf "\n\nISO is built at $(NEWISO)\n\n"