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 ##############################################################################
13 TMP_ROOT_DIR := $(shell echo "$(MIRROR_UBUNTU_ROOT)" | cut -d "/" -f2)
14 # Enable use of exact repo commit if defined, else use Fuel main branch
15 FUEL_MIRROR_REPO?=https://github.com/openstack/fuel-mirror
16 FUEL_MIRROR_COMMIT?=$(FUEL_MAIN_TAG)
18 include ../../config.mk
21 export OPENSTACK_VERSION
27 sudo apt-get install -y git libxml2-dev libxslt-dev python-dev python-pip libz-dev libyaml-dev createrepo python-yaml
29 sudo mkdir -p /var/www/nailgun
30 git clone $(FUEL_MIRROR_REPO)
31 cd fuel-mirror && git checkout -q $(FUEL_MIRROR_COMMIT)
32 sudo pip install -U -r ./fuel-mirror/requirements.txt
33 sudo pip install ./fuel-mirror
34 sudo pip install ./fuel-mirror/contrib/fuel_mirror
35 ./opnfv_mirror_conf.py
36 sudo fuel-mirror --debug --config ./opnfv-config.yaml create --group ubuntu --pattern=ubuntu
37 sudo chmod -R 755 /var/www/nailgun
38 cp -Rp /var/www/nailgun .
39 # On the end we want to have ubuntu repository in mirrors/ubuntu directory
40 -if [ "$(MIRROR_UBUNTU_ROOT)" != "/ubuntu/" ]; then \
41 mkdir -p nailgun/mirrors/ubuntu;\
42 mv nailgun/mirrors$(MIRROR_UBUNTU_ROOT)* nailgun/mirrors/ubuntu;\
43 [ "$(MIRROR_UBUNTU_ROOT)" != "/" ] && rm -rf nailgun/mirrors/$(TMP_ROOT_DIR);\
45 # Store artifact in cache straight away if caching is enabled
46 # (no .cacheid will be present unless this is a cached build)
47 test -f .cacheid && $(MAKE) -f Makefile put-cache || exit 0
51 @rm -rf ../release/opnfv/nailgun nailgun fuel-mirror opnfv-config.yaml ubuntu.yaml
55 @rm -Rf ../release/opnfv/nailgun
56 @mkdir -p ../release/opnfv
57 @cp -Rp nailgun ../release/opnfv/nailgun
58 @cp fuel_bootstrap_cli.yaml ../release/opnfv/
60 #############################################################################
61 # Cache operations - only used when building through ci/build.sh
62 #############################################################################
64 # Create a unique hash to be used for getting and putting cache, based on:
65 # - Year and week (causing the cache to be rebuilt weekly)
66 # - The contents of this Makefile
68 date +"Repocache %G%V" > .cachedata
69 sha1sum Makefile >> .cachedata
70 cat .cachedata | $(CACHETOOL) getid > .cacheid
72 # Clean local data related to caching - called prior to ordinary build
75 rm -f .cachedata .cacheid
77 # Try to download cache - called prior to ordinary build
80 @if $(CACHETOOL) check $(shell cat .cacheid); then \
81 $(CACHETOOL) get $(shell cat .cacheid) | tar xf -;\
83 echo "No cache item found for $(shell cat .cacheid)" ;\
87 # Store cache if not already stored - called after ordinary build
90 @tar cf - nailgun | $(CACHETOOL) put $(shell cat .cacheid)