105efa3ce67be3cb024367d5ef72e3ccf81aa086
[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 UBUNTU_DIR := $(shell dirname $(MIRROR_UBUNTU_ROOT))
14 TMP_ROOT_DIR := $(shell echo "$(UBUNTU_DIR)" | cut -d "/" -f2)
15
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 -b $(FUEL_MAIN_TAG) https://github.com/openstack/fuel-mirror
29         sudo pip install -U -r ./fuel-mirror/requirements.txt
30         sudo pip install ./fuel-mirror
31         sudo pip install ./fuel-mirror/contrib/fuel_mirror
32         ./opnfv_mirror_conf.py
33         sudo fuel-mirror --debug --config ./opnfv-config.yaml create --group mos ubuntu --pattern=ubuntu
34         sudo chmod -R 755 /var/www/nailgun
35         cp -Rp /var/www/nailgun .
36         mv nailgun/mirrors$(MIRROR_MOS_UBUNTU_ROOT) nailgun/mirrors/mos-repos/ubuntu/$(MOS_VERSION)
37         rmdir nailgun/mirrors/mos-repos/ubuntu/snapshots
38         if [ "$(UBUNTU_DIR)" != "/" ]; then \
39           mv nailgun/mirrors$(UBUNTU_DIR)/ubuntu nailgun/mirrors/ubuntu;\
40           rm -rf nailgun/mirrors/$(TMP_ROOT_DIR);\
41         fi
42         # Store artifact in cache straight away if caching is enabled
43         # (no .cacheid will be present unless this is a cached build)
44         test -f .cacheid && $(MAKE) -f Makefile put-cache || exit 0
45
46 .PHONY: clean
47 clean:
48         @rm -rf ../release/opnfv/nailgun nailgun fuel-mirror
49
50 .PHONY: release
51 release:nailgun
52         @rm -Rf ../release/opnfv/nailgun
53         @mkdir -p ../release/opnfv
54         @cp -Rp nailgun ../release/opnfv/nailgun
55         @cp fuel_bootstrap_cli.yaml ../release/opnfv/
56
57 #############################################################################
58 # Cache operations - only used when building through ci/build.sh
59 #############################################################################
60
61 # Create a unique hash to be used for getting and putting cache, based on:
62 #   - Year and week (causing the cache to be rebuilt weekly)
63 #   - The contents of this Makefile
64 .cacheid:
65         date +"Repocache %G%V" > .cachedata
66         sha1sum Makefile >> .cachedata
67         cat .cachedata | $(CACHETOOL) getid > .cacheid
68
69 # Clean local data related to caching - called prior to ordinary build
70 .PHONY: clean-cache
71 clean-cache: clean
72         rm -f .cachedata .cacheid
73
74 # Try to download cache - called prior to ordinary build
75 .PHONY: get-cache
76 get-cache: .cacheid
77         @if $(CACHETOOL) check $(shell cat .cacheid); then \
78                  $(CACHETOOL) get $(shell cat .cacheid) | tar xf -;\
79         else \
80                 echo "No cache item found for $(shell cat .cacheid)" ;\
81                 exit 0;\
82         fi
83
84 # Store cache if not already stored - called after ordinary build
85 .PHONY: put-cache
86 put-cache: .cacheid
87         @tar cf - nailgun | $(CACHETOOL) put $(shell cat .cacheid)