*** FIRST VERSION OF CI BUILD SCRIPT ***
[genesis.git] / fuel / build / Makefile
1 ##############################################################################
2 # Copyright (c) 2015 Ericsson AB and others.
3 # stefan.k.berg@ericsson.com
4 # jonas.bjurel@ericsson.com
5 # All rights reserved. This program and the accompanying materials
6 # are made available under the terms of the Apache License, Version 2.0
7 # which accompanies this distribution, and is available at
8 # http://www.apache.org/licenses/LICENSE-2.0
9 ##############################################################################
10
11 ############################################################################
12 # BEGIN of variables to customize
13 #
14 SHELL = /bin/bash
15
16 #Input args
17 export UNIT_TEST = FALSE
18 export INTERACTIVE = TRUE
19 export ISOSRC = file:$(shell pwd)/fuel-6.0.1.iso
20 export ISOCACHE = $(shell pwd)/$(shell basename $(ISOSRC))
21 export PRODNO = "OPNFV_BGS"
22 export REVSTATE = "P0000"
23 export NEWISO = $(shell pwd)/release/opnfv-${REVSTATE}.iso
24
25 # Note! Invoke with "make REVSTATE=RXXXX all" to make release build!
26 # Invoke with ICOCACHE=/full/path/to/iso if cached ISO is in non-standard location.
27
28 #Build variables
29 export BUILD_BASE := $(shell pwd)
30 export DEB_DEST := $(BUILD_BASE)/release/packages/ubuntu/pool/main
31 export PUPPET_DEST := $(BUILD_BASE)/release/puppet/modules
32 export CACHE_DIR := $(BUILD_BASE)/cache
33 export VERSION_FILE := $(BUILD_BASE)/.versions
34 DOCKERIMG = opnfv.org/ubuntu-builder:14.04
35 export TOPDIR := $(shell pwd)
36
37 #
38 # END of variables to customize
39 #############################################################################
40
41 #Include definitions
42 include config.mk
43 include cache.mk
44
45
46 ORIGDIR := $(TOPDIR)/origiso
47
48 SUBDIRS := f_isoroot
49 SUBDIRS += f_opnfv_puppet
50 SUBDIRS += f_osnaily
51 SUBDIRS += f_l23network
52 SUBDIRS += f_resolvconf
53 SUBDIRS += f_ntp
54 SUBDIRS += f_gif
55 SUBDIRS += f_libnss
56 SUBDIRS += f_libpcs
57 SUBDIRS += f_libxt
58 SUBDIRS += f_comm_java
59 SUBDIRS += f_ca_cert
60 SUBDIRS += f_atk_wrap
61 SUBDIRS += f_jre_head
62 SUBDIRS += f_jre
63 SUBDIRS += f_java
64 SUBDIRS += f_odl
65
66
67
68 # f_example is only an example of how to generate a .deb package and
69 # should not be enabled in official builds.
70 #SUBDIRS += f_example
71
72 SUBCLEAN = $(addsuffix .clean,$(SUBDIRS))
73
74 .PHONY: all
75 all:
76         @docker version >/dev/null 2>&1 || (echo 'No Docker installation available'; exit 1)
77         @echo "Versions of cached build results built by" $(shell hostname) "at" $(shell date -u) > $(BUILD_BASE)/.versions
78         @echo "cache.mk" $(shell md5sum $(BUILD_BASE)/cache.mk | cut -f1 -d " ") >> $(BUILD_BASE)/.versions
79         @echo "config.mk" $(shell md5sum $(BUILD_BASE)/config.mk | cut -f1 -d " ") >> $(BUILD_BASE)/.versions
80         @make -C docker
81         @docker/runcontext $(DOCKERIMG) $(MAKE) $(MAKEFLAGS) iso
82
83 $(ISOCACHE):
84         # Clone Fuel to non-persistent location and build
85         cd /tmp && git clone $(FUEL_MAIN_REPO)
86         cd /tmp/fuel-main && git checkout $(FUEL_MAIN_TAG)
87         @echo "fuel" `git -C /tmp/fuel-main show | grep commit | rev | cut -f1 -d " "` >> ${BUILD_BASE}/.versions
88
89         # Setup cgroups for docker-in-docker
90         sudo /root/enable_dockerx2
91         # Patch to fix race condition when doing "Docker-in-Docker" build
92         cd /tmp/fuel-main && patch -p1 < $(TOPDIR)/fuel-main_1.patch
93         # Patch to make the sandbox chroot in Fuel succeed with package
94         # installation in a Docker build
95         cd /tmp/fuel-main && patch -p1 < $(TOPDIR)/fuel-main_2.patch
96         # Remove Docker optimizations, otherwise multistrap will fail during
97         # Fuel build.
98         sudo rm -f /etc/apt/apt.conf.d/docker*
99         #
100         cd /tmp/fuel-main && ./prepare-build-env.sh
101         cd /tmp/fuel-main && make iso
102         mv /tmp/fuel-main/build/artifacts/fuel*.iso .
103
104 .PHONY: mount-origiso umount-origiso
105 mount-origiso: $(ISOCACHE)
106         @echo "Mounting original ISO in $(ORIGDIR)"
107         @mkdir -p $(ORIGDIR)
108         @fuseiso $(ISOCACHE) $(ORIGDIR)
109
110 umount-origiso:
111         @echo "Unmounting original ISO from $(ORIGDIR)"
112         @fusermount -u $(ORIGDIR)
113         @rmdir $(ORIGDIR)
114
115 .PHONY: $(SUBDIRS)
116 $(SUBDIRS):
117         @mkdir -p release/packages/ubuntu/pool/main release/puppet/modules release/isoroot
118         $(MAKE) -C $@ -f Makefile release
119
120 .PHONY: patch-packages
121 patch-packages:
122         ORIGISO=$(ISOCACHE) REVSTATE=$(REVSTATE) $(MAKE) -C $@ -f Makefile release
123
124 .PHONY: prepare
125 prepare:
126         $(MAKE) -C opendaylight -f Makefile setup
127
128 .PHONY: odl
129 odl:
130         $(MAKE) -C opendaylight -f Makefile
131
132 .PHONY: build-clean $(SUBCLEAN)
133 build-clean: $(SUBCLEAN)
134         $(MAKE) -C patch-packages -f Makefile clean
135         @rm -Rf release
136         @rm -Rf newiso
137         @rm -f $(NEWISO)
138
139 .PHONY: clean $(SUBCLEAN)
140 clean:  prepare $(SUBCLEAN)
141         $(MAKE) -C patch-packages -f Makefile clean
142         $(MAKE) -C opendaylight -f Makefile clean
143         @rm -f *.iso
144         @rm -Rf release
145         @rm -Rf newiso
146         @rm -f f_odl
147         @rm -f $(NEWISO)
148         @rm -f $(BUILD_BASE)/.versions
149
150 $(SUBCLEAN): %.clean:
151         $(MAKE) -C $* -f Makefile clean
152
153 # Todo: Make things smarter - we shouldn't need to clean everything
154 # betwen make invocations.
155 .PHONY: iso
156 iso:    prepare build-clean odl $(ISOCACHE) $(SUBDIRS) patch-packages
157         install/install.sh iso $(ISOCACHE) $(NEWISO) $(PRODNO) $(REVSTATE)
158         @printf "\n\nProduct ISO is $(NEWISO)\n\n"