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 ##############################################################################
12 ############################################################################
13 # BEGIN of variables to customize
16 export ISOSRC = file:$(shell pwd)/fuel-7.0.iso
17 export ISOCACHE = $(shell pwd)/$(shell basename $(ISOSRC))
18 export PRODNO = "OPNFV_BGS"
19 export REVSTATE = "P0000"
20 export NEWISO = $(shell pwd)/release/opnfv-${REVSTATE}.iso
22 # Note! Invoke with "make REVSTATE=RXXXX all" to make release build!
23 # Invoke with ICOCACHE=/full/path/to/iso if cached ISO is in non-standard location.
26 export BUILD_BASE := $(shell pwd)
27 export DEB_DEST := $(BUILD_BASE)/release/packages/ubuntu/pool/main
28 export UDEB_DEST := $(BUILD_BASE)/release/packages/ubuntu/pool/debian-installer
29 export PUPPET_DEST := $(BUILD_BASE)/release/puppet/modules
30 export VERSION_FILE := $(BUILD_BASE)/.versions
31 export DOCKERIMG = opnfv.org/ubuntu-builder:14.04
32 export TOPDIR := $(shell pwd)
33 export REPOINFO := $(BUILD_BASE)/repo_info.sh
39 # f_example is only an example of how to generate a .deb package and
40 # should not be enabled in official builds.
43 ORIGDIR := $(TOPDIR)/origiso
45 # END of variables to customize
46 #############################################################################
48 SUBCLEAN = $(addsuffix .clean,$(SUBDIRS))
52 @docker version >/dev/null 2>&1 || (echo 'No Docker installation available'; exit 1)
54 @docker/runcontext $(DOCKERIMG) $(MAKE) $(MAKEFLAGS) iso
57 ############################################################################
58 # BEGIN of Include definitions
63 # END Include definitions
64 #############################################################################
67 # Clone Fuel to non-persistent location and build
68 if [ ! -d /tmp/fuel-main ]; then \
69 cd /tmp && git clone $(FUEL_MAIN_REPO); \
71 cd /tmp/fuel-main && git checkout $(FUEL_MAIN_TAG)
72 @echo "fuel" `git -C /tmp/fuel-main show | grep commit | head -1 | cut -d " " -f2` >> $(VERSION_FILE)
73 # Setup cgroups for docker-in-docker
74 sudo /root/enable_dockerx2
75 # Patch for adding dosfstools, as Fuel 6.1 is running mkfs.vfat
76 cd /tmp/fuel-main && patch -p0 < $(TOPDIR)/fuel-main_5.patch
77 # Remove Docker optimizations, otherwise multistrap will fail during
79 sudo rm -f /etc/apt/apt.conf.d/docker*
81 cd /tmp/fuel-main && ./prepare-build-env.sh
82 cd /tmp/fuel-main && make repos
83 $(REPOINFO) -r /tmp/fuel-main > gitinfo_fuel.txt
85 cd /tmp/fuel-main && make iso
86 mv /tmp/fuel-main/build/artifacts/fuel*.iso .
88 .PHONY: mount-origiso umount-origiso
89 mount-origiso: $(ISOCACHE)
90 @echo "Mounting original ISO in $(ORIGDIR)"
92 @fuseiso $(ISOCACHE) $(ORIGDIR)
95 @echo "Unmounting original ISO from $(ORIGDIR)"
96 @fusermount -u $(ORIGDIR)
101 @mkdir -p release/packages/ubuntu/pool/main release/packages/ubuntu/pool/debian-installer release/puppet/modules release/isoroot
102 $(MAKE) -C $@ -f Makefile release
104 .PHONY: patch-packages
106 ORIGISO=$(ISOCACHE) REVSTATE=$(REVSTATE) $(MAKE) -C $@ -f Makefile release
108 .PHONY: clean $(SUBCLEAN)
110 $(MAKE) -C patch-packages -f Makefile clean
115 @rm -f $(BUILD_BASE)/gitinfo_*.txt
117 $(SUBCLEAN): %.clean:
118 $(MAKE) -C $* -f Makefile clean
120 # Todo: Make things smarter - we shouldn't need to clean everything
121 # betwen make invocations.
123 iso: $(ISOCACHE) $(SUBDIRS) patch-packages
124 $(REPOINFO) . > gitinfo_main.txt
125 install/install.sh iso $(ISOCACHE) $(NEWISO) $(PRODNO) $(REVSTATE)
126 @printf "\n\nProduct ISO is $(NEWISO)\n\n"
128 # Start a bash shell in docker for Makefile debugging
131 @docker version >/dev/null 2>&1 || (echo 'No Docker installation available'; exit 1)
132 docker/runcontext $(DOCKERIMG) bash
134 #############################################################################
135 # Cache operations - only used when building through ci/build.sh
136 #############################################################################
138 # Create a unique hash to be used for getting and putting cache, based on:
139 # - The commit ID of the full Fuel repo structre
140 # - The contents of all local Fuel patches
142 cd /tmp && git clone $(FUEL_MAIN_REPO)
143 cd /tmp/fuel-main && git checkout $(FUEL_MAIN_TAG)
144 cd /tmp/fuel-main && make repos
145 $(REPOINFO) -r /tmp/fuel-main > .cachedata
146 sha1sum fuel-main*.patch >> .cachedata
147 cat .cachedata | $(CACHETOOL) getid > .cacheid
148 # Not removing fuel-main as it is re-used in build
150 # Clean local data related to caching - called prior to ordinary build
153 rm -f .cachedata .cacheid
155 # Try to download cache - called prior to ordinary build
158 @if $(CACHETOOL) check $(shell cat .cacheid); then \
159 $(CACHETOOL) get $(shell cat .cacheid) | tar xf -;\
164 # Store cache if not already stored - called after ordinary build
167 @tar cf - fuel*.iso gitinfo_fuel.txt | $(CACHETOOL) put $(shell cat .cacheid)