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-8.0.iso
22 export ISOCACHE = $(shell pwd)/$(shell basename $(ISOSRC))
23 export PRODNO = "OPNFV_FUEL"
24 export REVSTATE = "P0000"
26 ifdef BUILD_FUEL_PLUGINS
27 $(warning Overriding plugin build selection to $(BUILD_FUEL_PLUGINS))
28 export NEWISO = $(shell pwd)/release/unofficial-opnfv-${REVSTATE}.iso
30 export NEWISO = $(shell pwd)/release/opnfv-${REVSTATE}.iso
33 # Note! Invoke with "make REVSTATE=RXXXX all" to make release build!
34 # Invoke with ICOCACHE=/full/path/to/iso if cached ISO is in non-standard location.
37 export BUILD_BASE := $(shell pwd)
38 export DEB_DEST := $(BUILD_BASE)/release/packages/ubuntu/pool/main
39 export UDEB_DEST := $(BUILD_BASE)/release/packages/ubuntu/pool/debian-installer
40 export PUPPET_DEST := $(BUILD_BASE)/release/puppet/modules
41 export VERSION_FILE := $(BUILD_BASE)/.versions
42 export DOCKERIMG = opnfv.org/ubuntu-builder:14.04
43 export TOPDIR := $(shell pwd)
44 export REPOINFO := $(BUILD_BASE)/repo_info.sh
47 # Use nearby repositories
48 export MIRROR_UBUNTU_URL := $(shell ./f_isoroot/f_repobuild/select_ubuntu_repo.sh --url)
49 export MIRROR_UBUNTU := $(shell echo "$(MIRROR_UBUNTU_URL)" | cut -d'/' -f3 )
50 export MIRROR_UBUNTU_ROOT := $(shell echo -n '/' ; echo "$(MIRROR_UBUNTU_URL)" | cut -d'/' -f4-)
52 export LATEST_MIRROR_ID_URL := http://$(shell ./select_closest_fuel_mirror.py)
54 export MIRROR_MOS_UBUNTU := $(shell echo "$(LATEST_MIRROR_ID_URL)" | cut -d'/' -f3)
55 export LATEST_TARGET_UBUNTU := $(shell curl -sSf "$(MIRROR_MOS_UBUNTU)/mos-repos/ubuntu/8.0.target.txt" | head -1)
56 export MIRROR_MOS_UBUNTU_ROOT := /mos-repos/ubuntu/$(LATEST_TARGET_UBUNTU)
58 export LATEST_TARGET_CENTOS := $(shell curl -sSf "$(LATEST_MIRROR_ID_URL)/mos-repos/centos/mos8.0-centos7-fuel/os.target.txt" | head -1)
59 export MIRROR_FUEL := "$(LATEST_MIRROR_ID_URL)/mos-repos/centos/mos8.0-centos7-fuel/$(LATEST_TARGET_CENTOS)/x86_64"
61 # uncomment and use: make print-VARIABLE
62 #print-% : ; @echo $* = $($*)
68 # f_example is only an example of how to generate a .deb package and
69 # should not be enabled in official builds.
72 ORIGDIR := $(TOPDIR)/origiso
74 # END of variables to customize
75 #############################################################################
77 SUBCLEAN = $(addsuffix .clean,$(SUBDIRS))
81 @docker version >/dev/null 2>&1 || (echo 'No Docker installation available'; exit 1)
83 @lsb_release -a | grep Ubuntu > /dev/null 2>&1 || (echo 'Ubuntu is the only supported Linux distribution for this build system'; exit 1)
84 @KERNEL_VER=$$(uname -r); \
85 KERNEL_VER="$${KERNEL_VER%.*-*}"; \
86 KERNEL_VER="$${KERNEL_VER//.}"; \
87 [ $$KERNEL_VER -ge 319 ] || (echo 'Kernel version must be 3.19 or newer'; exit 1)
88 @docker/runcontext $(DOCKERIMG) ping -c 1 www.google.com > /dev/null 2>&1 || (echo 'No docker network connectivity or name server - check your network- and docker settings'; exit 1)
89 @docker/runcontext $(DOCKERIMG) $(MAKE) $(MAKEFLAGS) iso
92 ############################################################################
93 # BEGIN of Include definitions
98 # END Include definitions
99 #############################################################################
102 # Clone Fuel to non-persistent location and build
103 if [ ! -d /tmp/fuel-main ]; then \
104 cd /tmp && git clone $(FUEL_MAIN_REPO); \
106 cd /tmp/fuel-main && git checkout $(FUEL_MAIN_TAG)
107 @echo "fuel" `git -C /tmp/fuel-main show | grep commit | head -1 | cut -d " " -f2` >> $(VERSION_FILE)
108 # Patch for adding dosfstools, as Fuel 6.1 is running mkfs.vfat
109 cd /tmp/fuel-main && patch -f -p0 < $(TOPDIR)/fuel-main_5.patch
110 # Patch for using the Czech Fuel mirror
111 # cd /tmp/fuel-main && patch -p0 < $(TOPDIR)/fuel-main_7.patch
112 # Remove Docker optimizations, otherwise multistrap will fail during
114 sudo rm -f /etc/apt/apt.conf.d/docker*
116 # Need to replace the old Docker v. 1.5.0 with a later version to be
117 # able to access the Docker remote repository!
118 cd /tmp/fuel-main && patch -f -p0 < $(TOPDIR)/fuel-main_docker_version.patch
120 cd /tmp/fuel-main && ./prepare-build-env.sh
121 # Verify that Docker is alive
123 cd /tmp/fuel-main && make repos
124 $(REPOINFO) -r /tmp/fuel-main > gitinfo_fuel.txt
125 # Repeat build up to ten times
126 sudo -E ./fuel_build_loop
127 cp /tmp/fuel-main/build/artifacts/fuel*.iso .
128 # Store artifact in cache straight away if caching is enabled
129 # (no .cacheid will be present unless this is a cached build)
130 test -f .cacheid && $(MAKE) -f Makefile put-cache || exit 0
132 .PHONY: mount-origiso umount-origiso
133 mount-origiso: $(ISOCACHE)
134 @echo "Mounting original ISO in $(ORIGDIR)"
136 @fuseiso $(ISOCACHE) $(ORIGDIR)
139 @echo "Unmounting original ISO from $(ORIGDIR)"
140 @fusermount -u $(ORIGDIR)
145 @mkdir -p release/packages/ubuntu/pool/main release/packages/ubuntu/pool/debian-installer release/puppet/modules release/isoroot
146 $(MAKE) -C $@ -f Makefile release
148 .PHONY: patch-packages
150 ORIGISO=$(ISOCACHE) REVSTATE=$(REVSTATE) $(MAKE) -C $@ -f Makefile release
152 .PHONY: clean $(SUBCLEAN)
154 $(MAKE) -C patch-packages -f Makefile clean
160 @rm -f $(BUILD_BASE)/gitinfo_*.txt
163 deepclean: clean clean-cache
165 docker rmi opnfv.org/ubuntu-builder:14.04 &>/dev/null || exit 0
166 docker rmi opnfv.org/ubuntu-builder:latest &>/dev/null || exit 0
167 docker rmi ubuntu:14.04 &>/dev/null || exit 0
168 @if docker images | grep -q "ubuntu *14.04"; then \
169 echo "Error: ubuntu:14.04 still present!"; \
172 @if docker images | grep -q "opnfv.org/ubuntu-builder"; then \
173 echo "Error: opnfv.org/ubuntu-builder still present!"; \
177 $(SUBCLEAN): %.clean:
178 $(MAKE) -C $* -f Makefile clean
182 @if [ -f environment.mk ]; then \
183 sudo bash -c "cat environment.mk >> /etc/environment"; \
186 # Todo: Make things smarter - we shouldn't need to clean everything
187 # betwen make invocations.
189 iso: setup-env $(ISOCACHE) $(SUBDIRS) patch-packages
190 $(REPOINFO) . > gitinfo_main.txt
191 install/install.sh iso $(ISOCACHE) $(NEWISO) $(PRODNO) $(REVSTATE)
192 @printf "\n\nProduct ISO is $(NEWISO)\n\n"
194 # Start a bash shell in docker for Makefile debugging
197 @docker version >/dev/null 2>&1 || (echo 'No Docker installation available'; exit 1)
199 docker/runcontext $(DOCKERIMG) debug
201 #############################################################################
202 # Cache operations - only used when building through ci/build.sh
203 #############################################################################
205 # Create a unique hash to be used for getting and putting cache, based on:
206 # - The commit ID of the full Fuel repo structre
207 # - The contents of all local Fuel patches
209 cd /tmp && git clone $(FUEL_MAIN_REPO)
210 cd /tmp/fuel-main && git checkout $(FUEL_MAIN_TAG)
211 cd /tmp/fuel-main && make repos
212 $(REPOINFO) -r /tmp/fuel-main > .cachedata
213 sha1sum *.patch >> .cachedata
214 sha1sum fuel_build_loop >> .cachedata
215 sha1sum config.mk >> .cachedata
216 sha1sum Makefile >> .cachedata
217 $(CACHETOOL) getbiweek >> .cachedata
218 cat .cachedata | $(CACHETOOL) getid > .cacheid
219 # Not removing fuel-main as it is re-used in build
221 # Clean local data related to caching - called prior to ordinary build
223 clean-cache: $(SUBCLEANCACHE)
224 rm -f .cachedata .cacheid
226 # Try to download cache - called prior to ordinary build
229 @if $(CACHETOOL) check $(shell cat .cacheid); then \
230 $(CACHETOOL) get $(shell cat .cacheid) | tar xf -;\
235 # Store cache if not already stored - called after ordinary build
238 @tar cf - fuel*.iso gitinfo_fuel.txt | $(CACHETOOL) put $(shell cat .cacheid)