Version 0.0.1 of /fuel-bild
[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
16
17 ISOSRC = file:$(shell pwd)/fuel-5.1.1.iso
18 ISOCACHE = $(shell pwd)/$(shell basename $(ISOSRC))
19 PRODUCT_NAME = "OPNFV_BGS"
20 VERSION = "P0000"
21 NEWISO = $(shell pwd)/release/opnfv-${VERSION}.iso
22 DOCKERIMG = opnfv.org/ubuntu-builder:12.04
23 # Note! Invoke with "make VERSION=RXXXX iso" to make release build!
24 # Invoke with ICOCACHE=/full/path/to/iso if cached ISO is in non-standard location.
25 #
26 # END of variables to customize
27 #############################################################################
28 ORIGDIR = $(shell pwd)/origiso
29
30 SUBDIRS := f_isoroot
31 SUBDIRS += f_opnfv_puppet
32 SUBDIRS += f_osnaily
33 SUBDIRS += f_l23network
34 SUBDIRS += f_resolvconf
35 SUBDIRS += f_ntp
36
37 # f_example is only an example of how to generate a .deb package and
38 # should not be enabled in official builds.
39 #SUBDIRS += f_example
40
41 SUBCLEAN = $(addsuffix .clean,$(SUBDIRS))
42
43 .PHONY: all
44 all:    
45         @docker version >/dev/null 2>&1 || (echo 'No Docker installation available'; exit 1)
46         make -C docker
47         @docker/runcontext $(DOCKERIMG) $(MAKE) $(MAKEFLAGS) iso
48
49 $(ISOCACHE):
50         # Clone Fuel
51         sudo rm -rf fuel-main
52         git clone https://github.com/stackforge/fuel-main
53         cd fuel-main && git checkout 5.1.1
54         # Setup cgroups for docker-in-docker
55         sudo /root/enable_dockerx2
56         # Need to patch to fix race condition in build
57         cd fuel-main && patch -p1 < ../fuel-main.patches
58         #
59         cd fuel-main && ./prepare-build-env.sh
60         # Need to patch not supported start-stop-daemon argument
61         sudo sed -i 's/--no-close//' /etc/init.d/docker
62         sudo /etc/init.d/docker start
63         cd fuel-main && make iso
64         mv fuel-main/build/artifacts/fuel*.iso .
65         # Remove Fuel
66         sudo rm -rf fuel-main
67
68 # Used the "docker" target to build within the context of the Docker
69 # container created by the Makefile in the docker subdirectory.
70 .PHONY: docker
71 docker: /.dockerinit
72
73 /.dockerinit:
74         docker/runcontext $(DOCKERIMG) $(MAKE) $(MAKEFLAGS)
75
76 .PHONY: get-iso mount-origiso umount-origiso
77 mount-origiso:
78         @echo "Mounting original ISO in $(ORIGDIR)"
79         @mkdir -p $(ORIGDIR)
80         @fuseiso $(ISOCACHE) $(ORIGDIR)
81
82 umount-origiso:
83         @echo "Unmounting original ISO from $(ORIGDIR)"
84         @fusermount -u $(ORIGDIR)
85         @rmdir $(ORIGDIR)
86
87 get-iso:
88         wget $(ISOSRC) -O $(ISOCACHE)
89
90
91         @echo "ISO data of source ISO:" >> release/.isodata
92         @isoinfo -d -i $(ISOCACHE) >> release/.isodata
93
94 .PHONY: $(SUBDIRS)
95 $(SUBDIRS):
96         @mkdir -p release/packages/ubuntu/pool/main release/puppet/modules release/isoroot
97         $(MAKE) -C $@ -f Makefile release
98
99 .PHONY: patch-packages
100 patch-packages:
101         ORIGISO=$(ISOCACHE) VERSION=$(VERSION) $(MAKE) -C $@ -f Makefile release
102
103 .PHONY: clean $(SUBCLEAN)
104 clean: $(SUBCLEAN)
105         $(MAKE) -C patch-packages -f Makefile clean
106         @rm -Rf release
107         @rm -Rf newiso
108         @rm -f $(NEWISO)
109
110 $(SUBCLEAN): %.clean:
111         $(MAKE) -C $* -f Makefile clean
112
113 .PHONY: install
114 install:$(SUBDIRS) patch-packages
115         install/install.sh live
116
117 .PHONY: uninstall
118 uninstall:
119         install/uninstall.sh
120
121 # Todo: Make things smarter - we shouldn't need to clean everything
122 # betwen make invocations.
123 .PHONY: iso
124 iso:    clean $(ISOCACHE) $(SUBDIRS) patch-packages
125         install/install.sh iso $(ISOCACHE) $(NEWISO) $(PRODUCT_NAME) $(VERSION)
126         @printf "\n\nProduct ISO is $(NEWISO)\n\n"