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 .
51 @rm -rf ../release/opnfv/nailgun nailgun fuel-createmirror_6.1*.deb
55 @rm -Rf ../release/opnfv/nailgun
56 @mkdir -p ../release/opnfv
57 @cp -Rp nailgun ../release/opnfv/nailgun
59 #############################################################################
60 # Cache operations - only used when building through ci/build.sh
61 #############################################################################
63 # Create a unique hash to be used for getting and putting cache, based on:
64 # - Year and week (causing the cache to be rebuilt weekly)
65 # - The contents of this Makefile
67 date +"Repocache %G%V" > .cachedata
68 sha1sum Makefile >> .cachedata
69 cat .cachedata | $(CACHETOOL) getid > .cacheid
71 # Clean local data related to caching - called prior to ordinary build
74 rm -f .cachedata .cacheid
76 # Try to download cache - called prior to ordinary build
79 @if $(CACHETOOL) check $(shell cat .cacheid); then \
80 $(CACHETOOL) get $(shell cat .cacheid) | tar xf -;\
82 echo "No cache item found for $(shell cat .cacheid)" ;\
86 # Store cache if not already stored - called after ordinary build
89 @tar cf - nailgun | $(CACHETOOL) put $(shell cat .cacheid)