Fix 2 for moving ips to be static
[genesis.git] / foreman / 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 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.2-1.x86_64.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 $(VBOXRPM):
67         test -s $(VBOXRPM) || { wget -nv $(VBOXDNLD) ; }
68
69 $(VAGRANTRPM):
70         test -s $(VAGRANTRPM) || { wget -nv $(VAGRANTDNLD) ; }
71
72 .PHONY: mount-centiso umount-centiso
73 mount-centiso: $(ISOCACHE)
74         @echo "Mounting CentOS ISO in $(CENTDIR)"
75         @mkdir -p $(CENTDIR)
76         @fuseiso $(ISOCACHE) $(CENTDIR)
77
78 umount-centiso:
79         @set +e
80         @echo "Unmounting CentOS ISO from $(CENTDIR)"
81         @fusermount -u $(CENTDIR)
82         @rmdir $(CENTDIR)
83         @set -e
84
85 .PHONY: build-clean $(SUBCLEAN)
86 build-clean: $(SUBCLEAN)
87         @rm -Rf centos
88         @rm -Rf release
89         @rm -Rf newiso
90         @rm -f $(NEWISO)
91
92 .PHONY: clean $(SUBCLEAN)
93 clean:  clean-cache $(SUBCLEAN)
94         @rm -f *.iso
95         @rm -Rf release
96         @rm -Rf newiso
97         @rm -f $(NEWISO)
98         @rm -f $(BUILD_BASE)/.versions
99
100 $(SUBCLEAN): %.clean:
101         $(MAKE) -C $* -f Makefile clean
102
103 .PHONY: rpm-clean
104 rpm-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`)'
106
107 .PHONY: rpm
108 rpm:
109         pushd ../../ && git archive --format=tar --prefix=opnfv-genesis-0.2/ 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`)'
111         @make rpm-clean
112
113
114 # Todo: Make things smarter - we shouldn't need to clean everything
115 # betwen make invocations.
116 .PHONY: iso
117 iso:    build-clean $(ISOCACHE) $(VBOXRPM) $(VAGRANTRPM) rpm
118         @make mount-centiso
119         @mkdir centos release
120         cp -r $(CENTDIR)/* centos
121         @make umount-centiso
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
130         # build the iso
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"