Adding LICENSE file
[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 ISOSRC = file:$(shell pwd)/fuel-6.0.1.iso
16 ISOCACHE = $(shell pwd)/$(shell basename $(ISOSRC))
17 PRODUCT_NAME = "OPNFV_BGS"
18 VERSION = "P0000"
19 NEWISO = $(shell pwd)/release/opnfv-${VERSION}.iso
20 DOCKERIMG = opnfv.org/ubuntu-builder:14.04
21 # Note! Invoke with "make VERSION=RXXXX iso" to make release build!
22 # Invoke with ICOCACHE=/full/path/to/iso if cached ISO is in non-standard location.
23 #
24 # END of variables to customize
25 #############################################################################
26 TOPDIR := $(shell pwd)
27 ORIGDIR := $(TOPDIR)/origiso
28
29 SUBDIRS := f_isoroot
30 SUBDIRS += f_opnfv_puppet
31 SUBDIRS += f_osnaily
32 SUBDIRS += f_l23network
33 SUBDIRS += f_resolvconf
34 SUBDIRS += f_ntp
35
36 # f_example is only an example of how to generate a .deb package and
37 # should not be enabled in official builds.
38 #SUBDIRS += f_example
39
40 SUBCLEAN = $(addsuffix .clean,$(SUBDIRS))
41
42 .PHONY: all
43 all:
44         @docker version >/dev/null 2>&1 || (echo 'No Docker installation available'; exit 1)
45         @make -C docker
46         @docker/runcontext $(DOCKERIMG) $(MAKE) $(MAKEFLAGS) iso
47
48 $(ISOCACHE):
49         # Clone Fuel to non-persistent location and build
50         cd /tmp && git clone https://github.com/stackforge/fuel-main
51         cd /tmp/fuel-main && git checkout stable/6.0
52         # Setup cgroups for docker-in-docker
53         sudo /root/enable_dockerx2
54         # Patch to fix race condition when doing "Docker-in-Docker" build
55         cd /tmp/fuel-main && patch -p1 < $(TOPDIR)/fuel-main_1.patch
56         # Patch to make the sandbox chroot in Fuel succeed with package
57         # installation in a Docker build
58         cd /tmp/fuel-main && patch -p1 < $(TOPDIR)/fuel-main_2.patch
59         # Remove Docker optimizations, otherwise multistrap will fail during
60         # Fuel build.
61         sudo rm -f /etc/apt/apt.conf.d/docker*
62         #
63         cd /tmp/fuel-main && ./prepare-build-env.sh
64         cd /tmp/fuel-main && make iso
65         mv /tmp/fuel-main/build/artifacts/fuel*.iso .
66
67 .PHONY: mount-origiso umount-origiso
68 mount-origiso: $(ISOCACHE)
69         @echo "Mounting original ISO in $(ORIGDIR)"
70         @mkdir -p $(ORIGDIR)
71         @fuseiso $(ISOCACHE) $(ORIGDIR)
72
73 umount-origiso:
74         @echo "Unmounting original ISO from $(ORIGDIR)"
75         @fusermount -u $(ORIGDIR)
76         @rmdir $(ORIGDIR)
77
78 .PHONY: $(SUBDIRS)
79 $(SUBDIRS):
80         @mkdir -p release/packages/ubuntu/pool/main release/puppet/modules release/isoroot
81         $(MAKE) -C $@ -f Makefile release
82
83 .PHONY: patch-packages
84 patch-packages:
85         ORIGISO=$(ISOCACHE) VERSION=$(VERSION) $(MAKE) -C $@ -f Makefile release
86
87 .PHONY: clean $(SUBCLEAN)
88 clean: $(SUBCLEAN)
89         $(MAKE) -C patch-packages -f Makefile clean
90         @rm -Rf release
91         @rm -Rf newiso
92         @rm -f $(NEWISO)
93
94 $(SUBCLEAN): %.clean:
95         $(MAKE) -C $* -f Makefile clean
96
97 # Todo: Make things smarter - we shouldn't need to clean everything
98 # betwen make invocations.
99 .PHONY: iso
100 iso:    clean $(ISOCACHE) $(SUBDIRS) patch-packages
101         install/install.sh iso $(ISOCACHE) $(NEWISO) $(PRODUCT_NAME) $(VERSION)
102         @printf "\n\nProduct ISO is $(NEWISO)\n\n"