c61d1adf5bdcbef62628ca09dbecfb7d7891fae5
[fuel.git] / build / f_isoroot / f_repobuild / Makefile
1 ##############################################################################
2 # Copyright (c) 2015,2016 Ericsson AB, Enea AB and others.
3 # stefan.k.berg@ericsson.com
4 # jonas.bjurel@ericsson.com
5 # Alexandru.Avadanii@enea.com
6 # All rights reserved. This program and the accompanying materials
7 # are made available under the terms of the Apache License, Version 2.0
8 # which accompanies this distribution, and is available at
9 # http://www.apache.org/licenses/LICENSE-2.0
10 ##############################################################################
11
12 SHELL := /bin/bash
13 TOP := $(shell pwd)
14
15 include ../../config.mk
16 include config.mk
17
18 export MOS_VERSION
19 export MIRROR_UBUNTU_OPNFV_PATH:=$(TOP)/nailgun/mirrors/ubuntu
20
21 .PHONY: all
22 all: nailgun
23
24 nailgun:
25         sudo apt-get install -y createrepo git libxml2-dev libxslt1-dev \
26                 python-dev zlib1g-dev
27         rm -Rf nailgun packetary opnfv_config && mkdir opnfv_config
28         # We will analyze fuel-web's fixture files for package lists
29         ln -sf ${F_SUBMOD_DIR}/fuel-web fuel-web
30         # Same for fuel-agent's bootstrap package list
31         ln -sf ${F_SUBMOD_DIR}/fuel-agent fuel-agent
32         git clone --quiet $(PACKETARY_REPO)
33         if [ -n $(PACKETARY_COMMIT) ]; then \
34                 git -C packetary checkout $(PACKETARY_COMMIT); \
35         fi
36         sudo pip install -U -r ./packetary/requirements.txt
37         sudo pip install -U ./packetary
38         # Handle config and mirror build in one place
39         ./opnfv_mirror_ubuntu.py
40         # Store artifact in cache straight away if caching is enabled
41         # (no .cacheid will be present unless this is a cached build)
42         test -f .cacheid && $(MAKE) -f Makefile put-cache || exit 0
43
44 .PHONY: clean
45 clean:
46         @rm -rf ../release/opnfv/nailgun nailgun packetary fuel-web opnfv_config
47
48 .PHONY: release
49 release:nailgun
50         @rm -Rf ../release/opnfv/nailgun
51         @mkdir -p ../release/opnfv
52         @cp -Rp nailgun ../release/opnfv/nailgun
53
54 ############################################################################
55 # Cache operations - only used when building through ci/build.sh
56 ############################################################################
57
58 # Create a unique hash to be used for getting and putting cache, based on:
59 #   - Year and week (causing the cache to be rebuilt weekly)
60 #   - The contents of this Makefile + all sh,mk,py,yaml files in CWD
61 #   - repo packages fingerprint
62 #   - repo arch list
63 .cacheid:
64         date +"Repocache %G%V" > .cachedata
65         sha1sum Makefile *.{sh,mk,py,yaml} >> .cachedata
66         $(CACHETOOL) packages >> .cachedata
67         echo -n $(UBUNTU_ARCH) | sha1sum | awk {'print $$1'} >> .cachedata
68         cat .cachedata | $(CACHETOOL) getid > .cacheid
69
70 # Clean local data related to caching - called prior to ordinary build
71 .PHONY: clean-cache
72 clean-cache: clean
73         rm -f .cachedata .cacheid
74
75 # Try to download cache - called prior to ordinary build
76 .PHONY: get-cache
77 get-cache: .cacheid
78         @if $(CACHETOOL) check $(shell cat .cacheid); then \
79                  $(CACHETOOL) get $(shell cat .cacheid) | tar xf -;\
80         else \
81                 echo "No cache item found for $(shell cat .cacheid)" ;\
82                 exit 0;\
83         fi
84
85 # Store cache if not already stored - called after ordinary build
86 .PHONY: put-cache
87 put-cache: .cacheid
88         @tar cf - nailgun | $(CACHETOOL) put $(shell cat .cacheid)