Adds some network parsing for baremetal deployments and other fixes
[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 APEXRPM = $(shell pwd)/noarch/opnfv-apex-$(RPMVERS)-$(shell echo ${REVSTATE} | tr -d '_-').noarch.rpm
28
29 # Note! Invoke with "make REVSTATE=RXXXX all" to make release build!
30 # Invoke with ICOCACHE=/full/path/to/iso if cached ISO is in non-standard location.
31
32 #Build variables
33 export BUILD_BASE := $(shell pwd)
34 export CACHE_DIR := $(BUILD_BASE)/cache
35 export VERSION_FILE := $(BUILD_BASE)/.versions
36 export TOPDIR := $(shell pwd)
37
38 CENTDIR := $(TOPDIR)/centiso
39 #
40 # END of variables to customize
41 #############################################################################
42
43 SUBCLEAN = $(addsuffix .clean,$(SUBDIRS))
44
45
46 .PHONY: all
47 all: iso
48         @echo "Versions of cached build results built by" $(shell hostname) "at" $(shell date -u) > $(VERSION_FILE)
49         @echo "cache.mk" $(shell md5sum $(BUILD_BASE)/cache.mk | cut -f1 -d " ") >> $(VERSION_FILE)
50         @echo "config.mk" $(shell md5sum $(BUILD_BASE)/config.mk | cut -f1 -d " ") >> $(VERSION_FILE)
51
52 ############################################################################
53 # BEGIN of Include definitions
54 #
55 include config.mk
56 include cache.mk
57 #
58 # END Include definitions
59 #############################################################################
60
61 $(ISOCACHE):
62         test -s $(ISOCACHE) || { wget -nv $(CENTDNLD) ; }
63
64 .PHONY: mount-centiso umount-centiso
65 mount-centiso: $(ISOCACHE)
66         @echo "Mounting CentOS ISO in $(CENTDIR)"
67         @mkdir -p $(CENTDIR)
68         @fuseiso $(ISOCACHE) $(CENTDIR)
69
70 umount-centiso:
71         @set +e
72         @echo "Unmounting CentOS ISO from $(CENTDIR)"
73         @fusermount -u $(CENTDIR)
74         @rmdir $(CENTDIR)
75         @set -e
76
77 .PHONY: build-clean $(SUBCLEAN)
78 build-clean: instack-clean $(SUBCLEAN)
79         @rm -Rf centos
80         @rm -Rf release
81         @rm -Rf newiso
82         @rm -f $(NEWISO)
83
84 .PHONY: clean $(SUBCLEAN)
85 clean:  clean-cache build-clean $(SUBCLEAN)
86         @rm -f *.iso
87         @rm -Rf release
88         @rm -Rf newiso
89         @rm -f $(NEWISO)
90         @rm -f $(BUILD_BASE)/.versions
91
92 $(SUBCLEAN): %.clean:
93         $(MAKE) -C $* -f Makefile clean
94
95 .PHONY: rpm-clean
96 rpm-clean:
97         @rm -f build/opnfv-apex.tar.gz
98
99 .PHONY: rpm
100 rpm:
101         pushd ../ && git archive --format=tar --prefix=opnfv-apex-$(RPMVERS)/ HEAD > build/opnfv-apex.tar
102         tar -u --xform="s:stack/instack.qcow2:opnfv-apex-$(RPMVERS)/build/instack.qcow2:" --file=opnfv-apex.tar stack/instack.qcow2
103         tar -u --xform="s:instack.xml:opnfv-apex-$(RPMVERS)/build/instack.xml:" --file=opnfv-apex.tar instack.xml
104         tar -u --xform="s:baremetalbrbm_brbm1_brbm2_brbm3_0.xml:opnfv-apex-$(RPMVERS)/build/baremetalbrbm_brbm1_brbm2_brbm3_0.xml:" --file=opnfv-apex.tar baremetalbrbm_brbm1_brbm2_brbm3_0.xml
105         tar -u --xform="s:baremetalbrbm_brbm1_brbm2_brbm3_1.xml:opnfv-apex-$(RPMVERS)/build/baremetalbrbm_brbm1_brbm2_brbm3_1.xml:" --file=opnfv-apex.tar baremetalbrbm_brbm1_brbm2_brbm3_1.xml
106         tar -u --xform="s:baremetalbrbm_brbm1_brbm2_brbm3_2.xml:opnfv-apex-$(RPMVERS)/build/baremetalbrbm_brbm1_brbm2_brbm3_2.xml:" --file=opnfv-apex.tar baremetalbrbm_brbm1_brbm2_brbm3_2.xml
107         tar -u --xform="s:baremetalbrbm_brbm1_brbm2_brbm3_3.xml:opnfv-apex-$(RPMVERS)/build/baremetalbrbm_brbm1_brbm2_brbm3_3.xml:" --file=opnfv-apex.tar baremetalbrbm_brbm1_brbm2_brbm3_3.xml
108         tar -u --xform="s:baremetalbrbm_brbm1_brbm2_brbm3_4.xml:opnfv-apex-$(RPMVERS)/build/baremetalbrbm_brbm1_brbm2_brbm3_4.xml:" --file=opnfv-apex.tar baremetalbrbm_brbm1_brbm2_brbm3_4.xml
109         tar -u --xform="s:brbm-net.xml:opnfv-apex-$(RPMVERS)/build/brbm-net.xml:" --file=opnfv-apex.tar brbm-net.xml
110         tar -u --xform="s:brbm1-net.xml:opnfv-apex-$(RPMVERS)/build/brbm1-net.xml:" --file=opnfv-apex.tar brbm1-net.xml
111         tar -u --xform="s:brbm2-net.xml:opnfv-apex-$(RPMVERS)/build/brbm2-net.xml:" --file=opnfv-apex.tar brbm2-net.xml
112         tar -u --xform="s:brbm3-net.xml:opnfv-apex-$(RPMVERS)/build/brbm3-net.xml:" --file=opnfv-apex.tar brbm3-net.xml
113         tar -u --xform="s:default-pool.xml:opnfv-apex-$(RPMVERS)/build/default-pool.xml:" --file=opnfv-apex.tar default-pool.xml
114         tar -u --xform="s:instackenv-virt.json:opnfv-apex-$(RPMVERS)/build/instackenv-virt.json:" --file=opnfv-apex.tar instackenv-virt.json
115         tar -u --xform="s:stack/overcloud-full-odl.qcow2:opnfv-apex-$(RPMVERS)/build/stack/overcloud-full.qcow2:" --file=opnfv-apex.tar stack/overcloud-full-odl.qcow2
116         gzip -f opnfv-apex.tar
117         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 '_-')"
118
119 .PHONY: instack
120 instack:
121         @./instack.sh $(USE_MASTER)
122
123 .PHONY: instack-clean
124 instack-clean:
125         rm -f instackenv-virt.json
126         rm -f baremetalbrbm_brbm1_brbm2_brbm3_0.xml
127         rm -f baremetalbrbm_brbm1_brbm2_brbm3_1.xml
128         rm -f baremetalbrbm_brbm1_brbm2_brbm3_2.xml
129         rm -f baremetalbrbm_brbm1_brbm2_brbm3_3.xml
130         rm -f baremetalbrbm_brbm1_brbm2_brbm3_4.xml
131         rm -f instack.xml
132
133 .PHONY: iso
134 iso:    build-clean instack rpm $(ISOCACHE)
135         @mkdir centos release
136         cd centos && bsdtar -xf ../$(shell basename $(ISOSRC))
137         # modify the installer iso's contents
138         @cp -f isolinux.cfg centos/isolinux/isolinux.cfg
139         @cp $(APEXRPM) centos/Packages
140         cd centos/Packages && yumdownloader openvswitch
141         # regenerate yum repo data
142         @echo "Generating new yum metadata"
143         createrepo --update -g ../c7-opnfv-x86_64-comps.xml centos
144         # build the iso
145         @echo "Building OPNFV iso"
146         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
147         isohybrid $(NEWISO)
148         @printf "\n\nISO is built at $(NEWISO)\n\n"