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 RSYNC_HOST := $(shell ./select_ubuntu_repo.sh)
14 DEPENDENCIES_FILE := /etc/fuel-createmirror/requirements-deb.txt
21 # If RSYNC_CONNECT_PROG is set we need to do some magic to copy the
22 # keys. Make sure to have the username set in the SSH_CONNECT_PROG
24 @if [ -n "${RSYNC_CONNECT_PROG}" -a ! -d /root/.ssh ]; then \
25 sudo mkdir -p /root/.ssh; \
26 test -d ${HOME}/.ssh && sudo find ${HOME}/.ssh -maxdepth 1 -type f -exec cp {} /root/.ssh \; ; \
27 sudo bash -c "echo StrictHostKeyChecking=no > /root/.ssh/config"; \
28 sudo chmod 700 /root/.ssh; \
30 sudo apt-get install -y rsync python python-yaml dpkg-dev openssl
33 fuseiso ${ISOCACHE} tmpiso
34 cp tmpiso/ubuntu/pool/main/f/fuel-createmirror/fuel-createmirror_*.deb .
37 sudo dpkg -i fuel-createmirror_*.deb
38 sudo sed -i 's/DOCKER_MODE=true/DOCKER_MODE=false/' /etc/fuel-createmirror/common.cfg
39 sudo sed -i 's/DEBUG="no"/DEBUG="yes"/' /etc/fuel-createmirror/ubuntu.cfg
40 sudo sed -i "s/MIRROR_UBUNTU_HOST=\".*\"/MIRROR_UBUNTU_HOST=\"$(RSYNC_HOST)\"/" /etc/fuel-createmirror/common.cfg
41 # Add dependencies from plugins. With awk help try add only unique packages.
42 sudo bash -c 'find ../ -name requirements-deb.txt -print0 | xargs -0 -I% awk '\''NR == FNR {first[$$0];next}; ! ($$0 in first)'\'' "${DEPENDENCIES_FILE}" "%" >> "${DEPENDENCIES_FILE}"'
44 sudo mkdir -p /var/www
45 sudo su - -c /opt/fuel-createmirror-*/fuel-createmirror
46 sudo chmod -R 755 /var/www/nailgun
47 cp -Rp /var/www/nailgun .
48 # Store artifact in cache straight away if caching is enabled
49 # (no .cacheid will be present unless this is a cached build)
50 test -f .cacheid && $(MAKE) -f Makefile put-cache || exit 0
54 @rm -rf ../release/opnfv/nailgun nailgun fuel-createmirror_6.1*.deb
58 @rm -Rf ../release/opnfv/nailgun
59 @mkdir -p ../release/opnfv
60 @cp -Rp nailgun ../release/opnfv/nailgun
62 #############################################################################
63 # Cache operations - only used when building through ci/build.sh
64 #############################################################################
66 # Create a unique hash to be used for getting and putting cache, based on:
67 # - Year and week (causing the cache to be rebuilt weekly)
68 # - The contents of this Makefile
70 date +"Repocache %G%V" > .cachedata
71 sha1sum Makefile >> .cachedata
72 cat .cachedata | $(CACHETOOL) getid > .cacheid
74 # Clean local data related to caching - called prior to ordinary build
77 rm -f .cachedata .cacheid
79 # Try to download cache - called prior to ordinary build
82 @if $(CACHETOOL) check $(shell cat .cacheid); then \
83 $(CACHETOOL) get $(shell cat .cacheid) | tar xf -;\
85 echo "No cache item found for $(shell cat .cacheid)" ;\
89 # Store cache if not already stored - called after ordinary build
92 @tar cf - nailgun | $(CACHETOOL) put $(shell cat .cacheid)