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 ##############################################################################
13 # This file will be created if needed by runcontext to contain proxy
15 -include environment.mk
17 ############################################################################
18 # BEGIN of variables to customize
21 export ISOSRC = file:$(shell pwd)/fuel-7.0.iso
22 export ISOCACHE = $(shell pwd)/$(shell basename $(ISOSRC))
23 export PRODNO = "OPNFV_BGS"
24 export REVSTATE = "P0000"
25 export NEWISO = $(shell pwd)/release/opnfv-${REVSTATE}.iso
27 # Note! Invoke with "make REVSTATE=RXXXX all" to make release build!
28 # Invoke with ICOCACHE=/full/path/to/iso if cached ISO is in non-standard location.
31 export BUILD_BASE := $(shell pwd)
32 export DEB_DEST := $(BUILD_BASE)/release/packages/ubuntu/pool/main
33 export UDEB_DEST := $(BUILD_BASE)/release/packages/ubuntu/pool/debian-installer
34 export PUPPET_DEST := $(BUILD_BASE)/release/puppet/modules
35 export VERSION_FILE := $(BUILD_BASE)/.versions
36 export DOCKERIMG = opnfv.org/ubuntu-builder:14.04
37 export TOPDIR := $(shell pwd)
38 export REPOINFO := $(BUILD_BASE)/repo_info.sh
44 # f_example is only an example of how to generate a .deb package and
45 # should not be enabled in official builds.
48 ORIGDIR := $(TOPDIR)/origiso
50 # END of variables to customize
51 #############################################################################
53 SUBCLEAN = $(addsuffix .clean,$(SUBDIRS))
57 @docker version >/dev/null 2>&1 || (echo 'No Docker installation available'; exit 1)
59 @docker/runcontext $(DOCKERIMG) $(MAKE) $(MAKEFLAGS) iso
62 ############################################################################
63 # BEGIN of Include definitions
68 # END Include definitions
69 #############################################################################
72 # Clone Fuel to non-persistent location and build
73 if [ ! -d /tmp/fuel-main ]; then \
74 cd /tmp && git clone $(FUEL_MAIN_REPO); \
76 cd /tmp/fuel-main && git checkout $(FUEL_MAIN_TAG)
77 @echo "fuel" `git -C /tmp/fuel-main show | grep commit | head -1 | cut -d " " -f2` >> $(VERSION_FILE)
78 # Setup cgroups for docker-in-docker
79 sudo /root/enable_dockerx2
80 # Patch for adding dosfstools, as Fuel 6.1 is running mkfs.vfat
81 cd /tmp/fuel-main && patch -p0 < $(TOPDIR)/fuel-main_5.patch
82 # Patch for changing the second layer Docker --bip address
83 cd /tmp/fuel-main && patch -p0 < $(TOPDIR)/fuel-main_6.patch
84 # Remove Docker optimizations, otherwise multistrap will fail during
86 sudo rm -f /etc/apt/apt.conf.d/docker*
88 cd /tmp/fuel-main && ./prepare-build-env.sh
89 cd /tmp/fuel-main && make repos
90 $(REPOINFO) -r /tmp/fuel-main > gitinfo_fuel.txt
92 cd /tmp/fuel-main && sudo make iso
93 cp /tmp/fuel-main/build/artifacts/fuel*.iso .
95 .PHONY: mount-origiso umount-origiso
96 mount-origiso: $(ISOCACHE)
97 @echo "Mounting original ISO in $(ORIGDIR)"
99 @fuseiso $(ISOCACHE) $(ORIGDIR)
102 @echo "Unmounting original ISO from $(ORIGDIR)"
103 @fusermount -u $(ORIGDIR)
108 @mkdir -p release/packages/ubuntu/pool/main release/packages/ubuntu/pool/debian-installer release/puppet/modules release/isoroot
109 $(MAKE) -C $@ -f Makefile release
111 .PHONY: patch-packages
113 ORIGISO=$(ISOCACHE) REVSTATE=$(REVSTATE) $(MAKE) -C $@ -f Makefile release
115 .PHONY: clean $(SUBCLEAN)
117 $(MAKE) -C patch-packages -f Makefile clean
123 @rm -f $(BUILD_BASE)/gitinfo_*.txt
126 deepclean: clean clean-cache
128 docker rmi opnfv.org/ubuntu-builder:14.04 &>/dev/null || exit 0
129 docker rmi opnfv.org/ubuntu-builder:latest &>/dev/null || exit 0
130 docker rmi ubuntu:14.04 &>/dev/null || exit 0
131 @if docker images | grep -q "ubuntu *14.04"; then \
132 echo "Error: ubuntu:14.04 still present!"; \
135 @if docker images | grep -q "opnfv.org/ubuntu-builder"; then \
136 echo "Error: opnfv.org/ubuntu-builder still present!"; \
140 $(SUBCLEAN): %.clean:
141 $(MAKE) -C $* -f Makefile clean
145 @if [ -f environment.mk ]; then \
146 sudo bash -c "cat environment.mk >> /etc/environment"; \
149 # Todo: Make things smarter - we shouldn't need to clean everything
150 # betwen make invocations.
152 iso: setup-env $(ISOCACHE) $(SUBDIRS) patch-packages
153 $(REPOINFO) . > gitinfo_main.txt
154 install/install.sh iso $(ISOCACHE) $(NEWISO) $(PRODNO) $(REVSTATE)
155 @printf "\n\nProduct ISO is $(NEWISO)\n\n"
157 # Start a bash shell in docker for Makefile debugging
160 @docker version >/dev/null 2>&1 || (echo 'No Docker installation available'; exit 1)
162 docker/runcontext $(DOCKERIMG) debug
164 #############################################################################
165 # Cache operations - only used when building through ci/build.sh
166 #############################################################################
168 # Create a unique hash to be used for getting and putting cache, based on:
169 # - The commit ID of the full Fuel repo structre
170 # - The contents of all local Fuel patches
172 cd /tmp && git clone $(FUEL_MAIN_REPO)
173 cd /tmp/fuel-main && git checkout $(FUEL_MAIN_TAG)
174 cd /tmp/fuel-main && make repos
175 $(REPOINFO) -r /tmp/fuel-main > .cachedata
176 sha1sum fuel-main*.patch >> .cachedata
177 cat .cachedata | $(CACHETOOL) getid > .cacheid
178 # Not removing fuel-main as it is re-used in build
180 # Clean local data related to caching - called prior to ordinary build
182 clean-cache: $(SUBCLEANCACHE)
183 rm -f .cachedata .cacheid
185 # Try to download cache - called prior to ordinary build
188 @if $(CACHETOOL) check $(shell cat .cacheid); then \
189 $(CACHETOOL) get $(shell cat .cacheid) | tar xf -;\
194 # Store cache if not already stored - called after ordinary build
197 @tar cf - fuel*.iso gitinfo_fuel.txt | $(CACHETOOL) put $(shell cat .cacheid)