Updates docs for SR1 with final revision
[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 SHELL = /bin/bash
12 ############################################################################
13 # BEGIN of variables to customize
14 #
15 #Input args
16 export UNIT_TEST = FALSE
17 export INTERACTIVE = TRUE
18 export ISOSRC = file:$(shell pwd)/fuel-6.1.iso
19 export ISOCACHE = $(shell pwd)/$(shell basename $(ISOSRC))
20 export PRODNO = "OPNFV_BGS"
21 export REVSTATE = "P0000"
22 export NEWISO = $(shell pwd)/release/opnfv-${REVSTATE}.iso
23
24 # Note! Invoke with "make REVSTATE=RXXXX all" to make release build!
25 # Invoke with ICOCACHE=/full/path/to/iso if cached ISO is in non-standard location.
26
27 #Build variables
28 export BUILD_BASE := $(shell pwd)
29 export DEB_DEST := $(BUILD_BASE)/release/packages/ubuntu/pool/main
30 export UDEB_DEST := $(BUILD_BASE)/release/packages/ubuntu/pool/debian-installer
31 export PUPPET_DEST := $(BUILD_BASE)/release/puppet/modules
32 export CACHE_DIR := $(BUILD_BASE)/cache
33 export VERSION_FILE := $(BUILD_BASE)/.versions
34 export DOCKERIMG = opnfv.org/ubuntu-builder:14.04
35 export TOPDIR := $(shell pwd)
36
37 #Build subclasses
38
39 SUBDIRS := f_isoroot
40
41 # f_example is only an example of how to generate a .deb package and
42 # should not be enabled in official builds.
43 #SUBDIRS += f_example
44
45 ORIGDIR := $(TOPDIR)/origiso
46 #
47 # END of variables to customize
48 #############################################################################
49
50 SUBCLEAN = $(addsuffix .clean,$(SUBDIRS))
51
52
53 .PHONY: all
54 all:
55         @docker version >/dev/null 2>&1 || (echo 'No Docker installation available'; exit 1)
56         @echo "Versions of cached build results built by" $(shell hostname) "at" $(shell date -u) > $(VERSION_FILE)
57         @echo "cache.mk" $(shell md5sum $(BUILD_BASE)/cache.mk | cut -f1 -d " ") >> $(VERSION_FILE)
58         @echo "config.mk" $(shell md5sum $(BUILD_BASE)/config.mk | cut -f1 -d " ") >> $(VERSION_FILE)
59         @make -C docker
60         @docker/runcontext $(DOCKERIMG) $(MAKE) $(MAKEFLAGS) iso
61
62 ############################################################################
63 # BEGIN of Include definitions
64 #
65 include config.mk
66 include cache.mk
67 #
68 # END Include definitions
69 #############################################################################
70
71 $(ISOCACHE):
72         # Clone Fuel to non-persistent location and build
73         cd /tmp && git clone $(FUEL_MAIN_REPO)
74         cd /tmp/fuel-main && git checkout $(FUEL_MAIN_TAG)
75         @echo "fuel" `git -C /tmp/fuel-main show | grep commit | head -1 | cut -d " " -f2` >> $(VERSION_FILE)
76         # Setup cgroups for docker-in-docker
77         sudo /root/enable_dockerx2
78         # Temporary patch to accomodate for new Ubuntu trusty devops keys not yet
79         # backported to fuel 6.0 or 6.1
80         cd /tmp/fuel-main && patch -p0 < $(TOPDIR)/fuel-main_3.patch
81         # Patch for adding dosfstools, as Fuel 6.1 is running mkfs.vfat
82         cd /tmp/fuel-main && patch -p0 < $(TOPDIR)/fuel-main_5.patch
83         # Remove Docker optimizations, otherwise multistrap will fail during
84         # Fuel build.
85         sudo rm -f /etc/apt/apt.conf.d/docker*
86         #
87         cd /tmp/fuel-main && ./prepare-build-env.sh
88         cd /tmp/fuel-main && make repos
89         # Patch for speeding up image creation in virtual environments,
90         # https://review.openstack.org/#/c/197943/
91         cd /tmp/fuel-main && patch -p0 < $(TOPDIR)/fuel-agent_1.patch
92         cd /tmp/fuel-main/build/repos/nailgun && git config --global user.email "build$opnfv.org"
93         cd /tmp/fuel-main/build/repos/nailgun && git config --global user.name "OPNFV build"
94         cd /tmp/fuel-main/build/repos/nailgun && git add -u .
95         cd /tmp/fuel-main/build/repos/nailgun && git commit -m "Added patch"
96         #
97         cd /tmp/fuel-main && make iso
98         mv /tmp/fuel-main/build/artifacts/fuel*.iso .
99
100 .PHONY: mount-origiso umount-origiso
101 mount-origiso: $(ISOCACHE)
102         @echo "Mounting original ISO in $(ORIGDIR)"
103         @mkdir -p $(ORIGDIR)
104         @fuseiso $(ISOCACHE) $(ORIGDIR)
105
106 umount-origiso:
107         @echo "Unmounting original ISO from $(ORIGDIR)"
108         @fusermount -u $(ORIGDIR)
109         @rmdir $(ORIGDIR)
110
111 .PHONY: $(SUBDIRS)
112 $(SUBDIRS):
113         @mkdir -p release/packages/ubuntu/pool/main release/packages/ubuntu/pool/debian-installer release/puppet/modules release/isoroot
114         $(MAKE) -C $@ -f Makefile release
115
116 .PHONY: patch-packages
117 patch-packages:
118         ORIGISO=$(ISOCACHE) REVSTATE=$(REVSTATE) $(MAKE) -C $@ -f Makefile release
119
120 .PHONY: build-clean $(SUBCLEAN)
121 build-clean: $(SUBCLEAN)
122         $(MAKE) -C patch-packages -f Makefile clean
123         @rm -Rf release
124         @rm -Rf newiso
125         @rm -f $(NEWISO)
126
127 .PHONY: clean $(SUBCLEAN)
128 clean:  clean-cache $(SUBCLEAN)
129         $(MAKE) -C patch-packages -f Makefile clean
130         @rm -f *.iso
131         @rm -Rf release
132         @rm -Rf newiso
133         @rm -f $(NEWISO)
134         @rm -f $(BUILD_BASE)/.versions
135
136 $(SUBCLEAN): %.clean:
137         $(MAKE) -C $* -f Makefile clean
138
139 # Todo: Make things smarter - we shouldn't need to clean everything
140 # betwen make invocations.
141 .PHONY: iso
142 iso:    build-clean $(ISOCACHE) $(SUBDIRS) patch-packages
143         install/install.sh iso $(ISOCACHE) $(NEWISO) $(PRODNO) $(REVSTATE)
144         @printf "\n\nProduct ISO is $(NEWISO)\n\n"
145
146 # Start a bash shell in docker for Makefile debugging
147 .PHONY: debug
148 debug:
149         @docker version >/dev/null 2>&1 || (echo 'No Docker installation available'; exit 1)
150         docker/runcontext $(DOCKERIMG) bash