Merge "Shift opendaylight role out of controller"
[fuel.git] / build / f_isoroot / f_repobuild / 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 TOP := $(shell pwd)
13 TMP_ROOT_DIR := $(shell echo "$(MIRROR_UBUNTU_ROOT)" | cut -d "/" -f2)
14
15 include ../../config.mk
16 include config.mk
17
18 export MOS_VERSION
19 export OPENSTACK_VERSION
20
21 .PHONY: all
22 all: nailgun
23
24 nailgun:
25         sudo apt-get install -y git libxml2-dev libxslt-dev python-dev  python-pip libz-dev libyaml-dev createrepo python-yaml
26         rm -Rf nailgun
27         sudo mkdir -p /var/www/nailgun
28         git clone $(FUEL_MIRROR_REPO)
29         cd fuel-mirror && git checkout -q $(FUEL_MIRROR_COMMIT)
30         sudo pip install -U -r ./fuel-mirror/requirements.txt
31         sudo pip install ./fuel-mirror
32         sudo pip install ./fuel-mirror/contrib/fuel_mirror
33         ./opnfv_mirror_conf.py
34         sudo fuel-mirror --debug --config ./opnfv-config.yaml create --group ubuntu --pattern=ubuntu
35         sudo chmod -R 755 /var/www/nailgun
36         cp -Rp /var/www/nailgun .
37         # On the end we want to have ubuntu repository in mirrors/ubuntu directory
38         -if [ "$(MIRROR_UBUNTU_ROOT)" != "/ubuntu/" ]; then \
39           mkdir -p nailgun/mirrors/ubuntu;\
40           mv nailgun/mirrors$(MIRROR_UBUNTU_ROOT)* nailgun/mirrors/ubuntu;\
41           [ "$(MIRROR_UBUNTU_ROOT)" != "/" ] && rm -rf nailgun/mirrors/$(TMP_ROOT_DIR);\
42         fi
43         # Store artifact in cache straight away if caching is enabled
44         # (no .cacheid will be present unless this is a cached build)
45         test -f .cacheid && $(MAKE) -f Makefile put-cache || exit 0
46
47 .PHONY: clean
48 clean:
49         @rm -rf ../release/opnfv/nailgun nailgun fuel-mirror opnfv-config.yaml ubuntu.yaml
50
51 .PHONY: release
52 release:nailgun
53         @rm -Rf ../release/opnfv/nailgun
54         @mkdir -p ../release/opnfv
55         @cp -Rp nailgun ../release/opnfv/nailgun
56         @cp fuel_bootstrap_cli.yaml ../release/opnfv/
57
58 #############################################################################
59 # Cache operations - only used when building through ci/build.sh
60 #############################################################################
61
62 # Create a unique hash to be used for getting and putting cache, based on:
63 #   - Year and week (causing the cache to be rebuilt weekly)
64 #   - The contents of this Makefile
65 .cacheid:
66         date +"Repocache %G%V" > .cachedata
67         sha1sum Makefile >> .cachedata
68         sha1sum config.mk >> .cachedata
69         $(CACHETOOL) packages >> .cachedata
70         echo -n $(UBUNTU_ARCH) | sha1sum | awk {'print $$1'} >> .cachedata
71         cat .cachedata | $(CACHETOOL) getid > .cacheid
72
73 # Clean local data related to caching - called prior to ordinary build
74 .PHONY: clean-cache
75 clean-cache: clean
76         rm -f .cachedata .cacheid
77
78 # Try to download cache - called prior to ordinary build
79 .PHONY: get-cache
80 get-cache: .cacheid
81         @if $(CACHETOOL) check $(shell cat .cacheid); then \
82                  $(CACHETOOL) get $(shell cat .cacheid) | tar xf -;\
83         else \
84                 echo "No cache item found for $(shell cat .cacheid)" ;\
85                 exit 0;\
86         fi
87
88 # Store cache if not already stored - called after ordinary build
89 .PHONY: put-cache
90 put-cache: .cacheid
91         @tar cf - nailgun | $(CACHETOOL) put $(shell cat .cacheid)