aboutsummaryrefslogtreecommitdiffstats
path: root/fuel/build
diff options
context:
space:
mode:
authorStefan K. Berg <stefan.k.berg@ericsson.com>2015-10-15 12:51:26 +0200
committerStefan K. Berg <stefan.k.berg@ericsson.com>2015-10-15 17:01:59 +0200
commite532d93d6fef7f23f3f227eaf855fff2be846ae7 (patch)
tree0c278a94ac8d7b15147255d3b213a6eba26160e5 /fuel/build
parent66fae447879604849beb2108242e33cc0c6fc867 (diff)
Improved caching functionality and tracability
In order to enable the caching of more build artifacts than the Fuel iso during CI builds, the caching functionality and the CI build frontend "build.sh" has been rewritten. The build.sh script will now rely on the "make cache" functionality of the top Makefile to make sure that the build is using cache handling. The underlying cache logic is implemented in "cache.mk" for the top makefile and those recursive levels that do not produce cachable artifacts themselves in that they are only calling the SUBDIRS of their lower level (like f_isoroot). All "leaf" Makefiles will however need to implement three cache targets in their top Makefile (for visibility): clean-cache: Clean all files relating to the handling of caches. get-cache: Attempt to fetch a cached artifact using a SHA1 key. put-cache: Store a built artifact into the cache. They can just implement a simple "no-op" functionality for thes targets if they do not have any use of the caching functionality. If they are to use the caching functionality, they must make sure to implement a logic that produces a SHA1 hash based on the source of the data they are to cache - for upstream repos one suggestion is to use the commit ID of the used upstream HEAD. For examples, see the top Makefile that implements this logic for the Fuel ISO build, taking into consideration the commit IDs of all the upstream repositories used. To improve tracability, the root directory of the ISO will contain the file gitinfo.txt, which is meant to detail the upstream repo and commit ID used for all upstream dependencies of a build. If you are adding additional upstream dependencies, make sure to use the repo_info.sh tool to add this data. The cache tool cache.sh has no notion of the cache data it is storing - from the tools perspective, cache data is just a binary blob piped in or out of the tool. This blob is stored by the cache tool at the cache location as <SHA1>.blob, together with an associated meta file <SHA1>.meta. The cache meta file currently holds just one line: Expires: <epoch time> This file is expected to be used to iterate through the cache objects and retire those who's expiry date has passed. Currently objects will always have an expiry date of two weeks into the future, but down the road the "cache put" functionality may be amended with an optional "age" argument that can set a different expiration time. New tools in this commit: cache.sh - the cache logic repo_info.sh - the (optionally recursive) repo information logger Change-Id: I8a40546c21febeecc9de6d82c0ceb6bc60b04205 Signed-off-by: Stefan K. Berg <stefan.k.berg@ericsson.com>
Diffstat (limited to 'fuel/build')
-rw-r--r--fuel/build/Makefile65
-rw-r--r--fuel/build/cache.mk111
-rwxr-xr-xfuel/build/cache.sh112
-rw-r--r--fuel/build/config.mk5
-rwxr-xr-xfuel/build/docker/runcontext10
-rw-r--r--fuel/build/f_isoroot/Makefile8
-rw-r--r--fuel/build/f_isoroot/cache.mk37
-rw-r--r--fuel/build/f_isoroot/f_bootstrap/Makefile19
-rw-r--r--fuel/build/f_isoroot/f_kscfg/Makefile19
-rw-r--r--fuel/build/f_isoroot/f_odlpluginbuild/Makefile48
-rw-r--r--fuel/build/f_isoroot/f_repobuild/Makefile45
-rwxr-xr-xfuel/build/install/install.sh6
-rwxr-xr-xfuel/build/repo_info.sh63
13 files changed, 423 insertions, 125 deletions
diff --git a/fuel/build/Makefile b/fuel/build/Makefile
index 437b793b1..767b930d7 100644
--- a/fuel/build/Makefile
+++ b/fuel/build/Makefile
@@ -13,8 +13,6 @@ SHELL = /bin/bash
# BEGIN of variables to customize
#
#Input args
-export UNIT_TEST = FALSE
-export INTERACTIVE = TRUE
export ISOSRC = file:$(shell pwd)/fuel-6.1.iso
export ISOCACHE = $(shell pwd)/$(shell basename $(ISOSRC))
export PRODNO = "OPNFV_BGS"
@@ -24,15 +22,15 @@ export NEWISO = $(shell pwd)/release/opnfv-${REVSTATE}.iso
# Note! Invoke with "make REVSTATE=RXXXX all" to make release build!
# Invoke with ICOCACHE=/full/path/to/iso if cached ISO is in non-standard location.
-#Build variables
+# Build variables
export BUILD_BASE := $(shell pwd)
export DEB_DEST := $(BUILD_BASE)/release/packages/ubuntu/pool/main
export UDEB_DEST := $(BUILD_BASE)/release/packages/ubuntu/pool/debian-installer
export PUPPET_DEST := $(BUILD_BASE)/release/puppet/modules
-export CACHE_DIR := $(BUILD_BASE)/cache
export VERSION_FILE := $(BUILD_BASE)/.versions
export DOCKERIMG = opnfv.org/ubuntu-builder:14.04
export TOPDIR := $(shell pwd)
+export REPOINFO := $(BUILD_BASE)/repo_info.sh
#Build subclasses
@@ -49,16 +47,13 @@ ORIGDIR := $(TOPDIR)/origiso
SUBCLEAN = $(addsuffix .clean,$(SUBDIRS))
-
.PHONY: all
all:
@docker version >/dev/null 2>&1 || (echo 'No Docker installation available'; exit 1)
- @echo "Versions of cached build results built by" $(shell hostname) "at" $(shell date -u) > $(VERSION_FILE)
- @echo "cache.mk" $(shell md5sum $(BUILD_BASE)/cache.mk | cut -f1 -d " ") >> $(VERSION_FILE)
- @echo "config.mk" $(shell md5sum $(BUILD_BASE)/config.mk | cut -f1 -d " ") >> $(VERSION_FILE)
@make -C docker
@docker/runcontext $(DOCKERIMG) $(MAKE) $(MAKEFLAGS) iso
+
############################################################################
# BEGIN of Include definitions
#
@@ -70,7 +65,9 @@ include cache.mk
$(ISOCACHE):
# Clone Fuel to non-persistent location and build
- cd /tmp && git clone $(FUEL_MAIN_REPO)
+ if [ ! -d /tmp/fuel-main ]; then \
+ cd /tmp && git clone $(FUEL_MAIN_REPO); \
+ fi
cd /tmp/fuel-main && git checkout $(FUEL_MAIN_TAG)
@echo "fuel" `git -C /tmp/fuel-main show | grep commit | head -1 | cut -d " " -f2` >> $(VERSION_FILE)
# Setup cgroups for docker-in-docker
@@ -86,6 +83,7 @@ $(ISOCACHE):
#
cd /tmp/fuel-main && ./prepare-build-env.sh
cd /tmp/fuel-main && make repos
+ $(REPOINFO) -r /tmp/fuel-main > gitinfo_fuel.txt
#
cd /tmp/fuel-main && make iso
mv /tmp/fuel-main/build/artifacts/fuel*.iso .
@@ -110,21 +108,14 @@ $(SUBDIRS):
patch-packages:
ORIGISO=$(ISOCACHE) REVSTATE=$(REVSTATE) $(MAKE) -C $@ -f Makefile release
-.PHONY: build-clean $(SUBCLEAN)
-build-clean: $(SUBCLEAN)
- $(MAKE) -C patch-packages -f Makefile clean
- @rm -Rf release
- @rm -Rf newiso
- @rm -f $(NEWISO)
-
.PHONY: clean $(SUBCLEAN)
-clean: clean-cache $(SUBCLEAN)
+clean: $(SUBCLEAN)
$(MAKE) -C patch-packages -f Makefile clean
@rm -f *.iso
@rm -Rf release
@rm -Rf newiso
@rm -f $(NEWISO)
- @rm -f $(BUILD_BASE)/.versions
+ @rm -f $(BUILD_BASE)/gitinfo_*.txt
$(SUBCLEAN): %.clean:
$(MAKE) -C $* -f Makefile clean
@@ -132,7 +123,8 @@ $(SUBCLEAN): %.clean:
# Todo: Make things smarter - we shouldn't need to clean everything
# betwen make invocations.
.PHONY: iso
-iso: build-clean $(ISOCACHE) $(SUBDIRS) patch-packages
+iso: $(ISOCACHE) $(SUBDIRS) patch-packages
+ $(REPOINFO) . > gitinfo_main.txt
install/install.sh iso $(ISOCACHE) $(NEWISO) $(PRODNO) $(REVSTATE)
@printf "\n\nProduct ISO is $(NEWISO)\n\n"
@@ -141,3 +133,38 @@ iso: build-clean $(ISOCACHE) $(SUBDIRS) patch-packages
debug:
@docker version >/dev/null 2>&1 || (echo 'No Docker installation available'; exit 1)
docker/runcontext $(DOCKERIMG) bash
+
+#############################################################################
+# Cache operations - only used when building through ci/build.sh
+#############################################################################
+
+# Create a unique hash to be used for getting and putting cache, based on:
+# - The commit ID of the full Fuel repo structre
+# - The contents of all local Fuel patches
+.cacheid:
+ cd /tmp && git clone $(FUEL_MAIN_REPO)
+ cd /tmp/fuel-main && git checkout $(FUEL_MAIN_TAG)
+ cd /tmp/fuel-main && make repos
+ $(REPOINFO) -r /tmp/fuel-main > .cachedata
+ sha1sum fuel-main*.patch >> .cachedata
+ cat .cachedata | $(CACHETOOL) getid > .cacheid
+ # Not removing fuel-main as it is re-used in build
+
+# Clean local data related to caching - called prior to ordinary build
+.PHONY: clean-cache
+clean-cache:
+ rm -f .cachedata .cacheid
+
+# Try to download cache - called prior to ordinary build
+.PHONY: get-cache
+get-cache: .cacheid
+ @if $(CACHETOOL) check $(shell cat .cacheid); then \
+ $(CACHETOOL) get $(shell cat .cacheid) | tar xf -;\
+ else \
+ exit 0;\
+ fi
+
+# Store cache if not already stored - called after ordinary build
+.PHONY: put-cache
+put-cache: .cacheid
+ @tar cf - fuel*.iso gitinfo_fuel.txt | $(CACHETOOL) put $(shell cat .cacheid)
diff --git a/fuel/build/cache.mk b/fuel/build/cache.mk
index b88ac2fc4..f6db01797 100644
--- a/fuel/build/cache.mk
+++ b/fuel/build/cache.mk
@@ -1,4 +1,4 @@
-#############################################################################
+##############################################################################
# Copyright (c) 2015 Ericsson AB and others.
# stefan.k.berg@ericsson.com
# jonas.bjurel@ericsson.com
@@ -8,87 +8,48 @@
# http://www.apache.org/licenses/LICENSE-2.0
##############################################################################
-SHELL = /bin/bash
-CACHEVALIDATE := $(addsuffix .validate,$(SUBDIRS))
-CACHECLEAN := $(addsuffix .clean,$(CACHEFILES) $(CACHEDIRS))
-
-############################################################################
-# BEGIN of variables to customize
-#
-#CACHEDIRS := foo/bar
-
-CACHEFILES += .versions
-CACHEFILES += $(shell basename $(ISOSRC))
+#############################################################################
+# Cache operations - only used when building through ci/build.sh
#
-# END of variables to customize
-############################################################################
-
-.PHONY: prepare-cache
-prepare-cache: make-cache-dir $(CACHEDIRS) $(CACHEFILES)
+# This is the global cache implementation, providing the main target "cache"
+# which is called from ci/build.sh, and recursively calling the cache
+# operations clean-cache, get-cache and put-cache on all $(SUBDIRS).
+#############################################################################
-.PHONY: make-cache-dir
-make-cache-dir:
- @rm -rf ${CACHE_DIR}
- @mkdir ${CACHE_DIR}
-.PHONY: clean-cache
-clean-cache: $(CACHECLEAN)
- @rm -rf ${CACHE_DIR}
+export CACHETOOL := $(BUILD_BASE)/cache.sh
-.PHONY: $(CACHEDIRS)
-$(CACHEDIRS):
- @mkdir -p $(dir $(CACHE_DIR)/$@)
- @if [ ! -d $(BUILD_BASE)/$@ ]; then\
- mkdir -p $(BUILD_BASE)/$@;\
- fi
- @ln -s $(BUILD_BASE)/$@ $(CACHE_DIR)/$@
+# Call sub caches
+SUBGETCACHE = $(addsuffix .getcache,$(SUBDIRS))
+$(SUBGETCACHE): %.getcache:
+ $(MAKE) -C $* -f Makefile get-cache
-.PHONY: $(CACHEFILES)
-$(CACHEFILES):
- @mkdir -p $(dir $(CACHE_DIR)/$@)
- @if [ ! -d $(dir $(BUILD_BASE)/$@) ]; then\
- mkdir -p $(dir $(BUILD_BASE)/$@);\
- fi
+SUBPUTCACHE = $(addsuffix .putcache,$(SUBDIRS))
+$(SUBPUTCACHE): %.putcache:
+ $(MAKE) -C $* -f Makefile put-cache
- @if [ ! -f $(BUILD_BASE)/$@ ]; then\
- echo " " > $(BUILD_BASE)/$@;\
- ln -s $(BUILD_BASE)/$@ $(CACHE_DIR)/$@;\
- rm -f $(BUILD_BASE)/$@;\
- else\
- ln -s $(BUILD_BASE)/$@ $(CACHE_DIR)/$@;\
- fi
+SUBCLEANCACHE = $(addsuffix .cleancache,$(SUBDIRS))
+$(SUBCLEANCACHE): %.cleancache:
+ $(MAKE) -C $* -f Makefile clean-cache
-.PHONY: validate-cache
-validate-cache: $(CACHEVALIDATE)
- @if [ "$(shell md5sum $(BUILD_BASE)/config.mk | cut -f1 -d " ")" != "$(shell cat $(VERSION_FILE) | grep config.mk | awk '{print $$NF}')" ]; then\
- echo "Cache does not match current config.mk definition, cache must be rebuilt";\
- exit 1;\
- fi;
+# Overlay implementation:
+# - clean
+# - clean cache identities
+# - get caches
+# - build iso
+# - store caches
+.PHONY: cached-all
+cached-all: clean clean-cache $(SUBCLEANCACHE) get-cache $(SUBGETCACHE) iso put-cache $(SUBPUTCACHE)
+ @echo "Cached build is complete"
- @if [ "$(shell md5sum $(BUILD_BASE)/cache.mk | cut -f1 -d " ")" != "$(shell cat $(VERSION_FILE) | grep cache.mk | awk '{print $$NF}')" ]; then\
- echo "Cache does not match current cache.mk definition, cache must be rebuilt";\
- exit 1;\
- fi;
-# Once the Make structure is refactored, this should go in as a validate-cache
-# taget in the fuel Makefile
-
- @REMOTE_ID=$(shell git ls-remote $(FUEL_MAIN_REPO) $(FUEL_MAIN_TAG)^{} | awk '{print $$(NF-1)}'); \
- if [ -z $$REMOTE_ID ] || [ $$REMOTE_ID = " " ]; \
- then \
- REMOTE_ID=$(shell git ls-remote $(FUEL_MAIN_REPO) $(FUEL_MAIN_TAG) | awk '{print $$(NF-1)}'); \
- fi; \
- if [[ $$REMOTE_ID != $(shell cat $(VERSION_FILE) | grep fuel | awk '{print $$NF}') ]]; \
- then \
- echo "Cache does not match upstream Fuel, cache must be rebuilt!"; \
- exit 1; \
+# cache: The target for ci/build.sh
+.PHONY: cache
+cache:
+ @if [ -z "${CACHEBASE}" ]; then \
+ echo "CACHEBASE not set, are you really building through build.sh?"; \
+ exit 1; \
fi
-
-.PHONY: $(CACHEVALIDATE)
-$(CACHEVALIDATE): %.validate:
- @echo VALIDATE $(CACHEVALIDATE)
- $(MAKE) -C $* -f Makefile validate-cache
-
-.PHONY: $(CACHECLEAN)
-$(CACHECLEAN): %.clean:
- rm -rf ${CACHE_DIR}/$*
+ @docker version >/dev/null 2>&1 || (echo 'No Docker installation available'; exit 1)
+ @make -C docker
+ docker/runcontext $(DOCKERIMG) $(MAKE) $(MAKEFLAGS) cached-all
diff --git a/fuel/build/cache.sh b/fuel/build/cache.sh
new file mode 100755
index 000000000..c8cd1b03d
--- /dev/null
+++ b/fuel/build/cache.sh
@@ -0,0 +1,112 @@
+#!/bin/bash
+##############################################################################
+# Copyright (c) 2015 Ericsson AB and others.
+# stefan.k.berg@ericsson.com
+# jonas.bjurel@ericsson.com
+# All rights reserved. This program and the accompanying materials
+# are made available under the terms of the Apache License, Version 2.0
+# which accompanies this distribution, and is available at
+# http://www.apache.org/licenses/LICENSE-2.0
+##############################################################################
+
+CACHETRANSPORT=${CACHETRANSPORT:-"curl --silent"}
+CACHEBASE=${CACHEBASE:-"file://${HOME}/cache"}
+CACHEMAXAGE=${CACHEMAXAGE:-$[14*24*3600]}
+CACHEDEBUG=${CACHEDEBUG:-1}
+
+debugmsg () {
+ if [ "$CACHEDEBUG" -eq 1 ]; then
+ echo "$@" >&2
+ fi
+}
+
+errormsg () {
+ echo "$@" >&2
+}
+
+# Get a SHA1 based on what's piped into the cache command
+getid() {
+ debugmsg "Generating sha1sum"
+ sha1sum | sed 's/ .*//'
+}
+
+
+# Put in cache
+put() {
+ if check $1; then
+ debugmsg "SHA1 $1 already in cache, skipping storage"
+ else
+ debugmsg "Storing SHA1 $1 in cache"
+ ${CACHETRANSPORT} -T - ${CACHEBASE}/$1.blob
+ echo "Expires: $[`date +"%s"` + $CACHEMAXAGE]" | ${CACHETRANSPORT} -T - ${CACHEBASE}/$1.meta
+ fi
+ exit 0
+}
+
+# Get from cache
+get() {
+ local rc
+
+ ${CACHETRANSPORT} -o - ${CACHEBASE}/$1.blob 2>/dev/null
+ rc=$?
+
+ if [ $rc -eq 0 ]; then
+ echo "Got SHA1 $1 from cache" 2>/dev/null
+ else
+ echo "Tried to get SHA1 $1 from cache but failed" 2>/dev/null
+ fi
+
+ return $?
+}
+
+# Check if in cache
+check() {
+ local rc
+
+ ${CACHETRANSPORT} ${CACHEBASE}/$1.meta &>/dev/null
+ rc=$?
+
+ if [ $rc -eq 0 ]; then
+ debugmsg "Checking for SHA1 $1 in cache and found it, rc = $rc"
+ else
+ debugmsg "Checking for SHA1 $1 in cache and failed, rc = $rc"
+ fi
+
+ return $rc
+}
+
+# Verify that SHA1 seems to be a SHA1...
+validSHA1() {
+ if [ $(echo $1 | wc -c) -ne 41 ]; then
+ return 1
+ else
+ return 0
+ fi
+}
+
+case $1 in
+ getid)
+ if [ $# -ne 1 ]; then
+ errormsg "No arguments can be given to getid!"
+ exit 1
+ fi
+ getid
+ ;;
+ get|check|put)
+ if [ $# -ne 2 ]; then
+ errormsg "Only one argument, the SHA1 sum, can be given to getid!"
+ exit 1
+ else
+ if ! validSHA1 $2; then
+ errormsg "Invalid SHA1 format!"
+ exit 1
+ fi
+ fi
+
+ $1 $2
+ exit $rc
+ ;;
+ *)
+ errormsg "I only know about getid, check, get and put!"
+ exit 1
+esac
diff --git a/fuel/build/config.mk b/fuel/build/config.mk
index 16354d578..e9a5320f4 100644
--- a/fuel/build/config.mk
+++ b/fuel/build/config.mk
@@ -8,11 +8,6 @@
# http://www.apache.org/licenses/LICENSE-2.0
##############################################################################
-# Change the below value with "uuidgen" to force a full cache rebuild - a
-# temporary as we work with improving the caching functionality for the next
-# release.
-CACHE_RND := 73b88a88-9714-4010-888e-e7cd4b26d5e4
-
FUEL_MAIN_REPO := https://github.com/stackforge/fuel-main
FUEL_MAIN_TAG = stable/6.1
diff --git a/fuel/build/docker/runcontext b/fuel/build/docker/runcontext
index 77e4921e1..341612b4e 100755
--- a/fuel/build/docker/runcontext
+++ b/fuel/build/docker/runcontext
@@ -42,11 +42,15 @@ EOF`
GITROOT=`git rev-parse --show-toplevel`
IID=`echo $res | sed 's/.* //'`
CID_FILE=`mktemp -u -t runcontext.XXXXXXXXXX`
-RUN_CONTEXT_OPT="--cidfile $CID_FILE --privileged=true --rm -i -e HOME=$HOME -u $USER -w $PWD -v ${HOME}/.ssh:${HOME}/.ssh -v $GITROOT:$GITROOT"
-if [ "${INTERACTIVE}" != "FALSE" ]; then
- RUN_CONTEXT_OPT+=" -t"
+# Evaluate the need for bind mounting the cache directory
+if [ -n "$CACHEBASE" ]; then
+ if echo $CACHEBASE | grep -q '^file://'; then
+ CACHEMOUNT="-v $(echo $CACHEBASE | sed 's;file://;;'):$(echo $CACHEBASE | sed 's;file://;;')"
+ fi
fi
+RUN_CONTEXT_OPT="--cidfile $CID_FILE --privileged=true --rm -e HOME=$HOME -e CACHEDEBUG -e CACHETRANSPORT -e CACHEMAXAGE -e CACHEBASE -u $USER -w $PWD -v ${HOME}/.ssh:${HOME}/.ssh -v $GITROOT:$GITROOT $CACHEMOUNT"
+
echo command: docker run ${RUN_CONTEXT_OPT} $IID "$@"
docker run ${RUN_CONTEXT_OPT} $IID "$@"
diff --git a/fuel/build/f_isoroot/Makefile b/fuel/build/f_isoroot/Makefile
index a9b12d927..3831a09f0 100644
--- a/fuel/build/f_isoroot/Makefile
+++ b/fuel/build/f_isoroot/Makefile
@@ -26,10 +26,8 @@ clean: $(SUBCLEAN)
$(SUBCLEAN): %.clean:
$(MAKE) -C $* -f Makefile clean
-validate-cache:
- @echo "No cache validation schema available for $(shell pwd)"
- @echo "Continuing ..."
-
.PHONY: release
-release:clean $(SUBDIRS)
+release: $(SUBDIRS)
@cp -Rvp release/* ../release/isoroot
+
+include cache.mk
diff --git a/fuel/build/f_isoroot/cache.mk b/fuel/build/f_isoroot/cache.mk
new file mode 100644
index 000000000..2df3b6bd1
--- /dev/null
+++ b/fuel/build/f_isoroot/cache.mk
@@ -0,0 +1,37 @@
+##############################################################################
+# stefan.k.berg@ericsson.com
+# jonas.bjurel@ericsson.com
+# All rights reserved. This program and the accompanying materials
+# are made available under the terms of the Apache License, Version 2.0
+# which accompanies this distribution, and is available at
+# http://www.apache.org/licenses/LICENSE-2.0
+##############################################################################
+
+#############################################################################
+# Cache operations - only used when building through ci/build.sh
+#
+# This file is only meant for a top Makefile which is only calling its
+# own SUBDIRS, without building any cachable artifact by itself.
+#############################################################################
+
+# Call sub caches
+SUBGETCACHE = $(addsuffix .getcache,$(SUBDIRS))
+$(SUBGETCACHE): %.getcache:
+ $(MAKE) -C $* -f Makefile get-cache
+
+SUBPUTCACHE = $(addsuffix .putcache,$(SUBDIRS))
+$(SUBPUTCACHE): %.putcache:
+ $(MAKE) -C $* -f Makefile put-cache
+
+SUBCLEANCACHE = $(addsuffix .cleancache,$(SUBDIRS))
+$(SUBCLEANCACHE): %.cleancache:
+ $(MAKE) -C $* -f Makefile clean-cache
+
+.PHONY: get-cache
+get-cache: $(SUBGETCACHE)
+
+.PHONY: put-cache
+put-cache: $(SUBPUTCACHE)
+
+.PHONY: clean-cache
+clean-cache: $(SUBCLEANCACHE)
diff --git a/fuel/build/f_isoroot/f_bootstrap/Makefile b/fuel/build/f_isoroot/f_bootstrap/Makefile
index 7404319d9..a958aa2d6 100644
--- a/fuel/build/f_isoroot/f_bootstrap/Makefile
+++ b/fuel/build/f_isoroot/f_bootstrap/Makefile
@@ -27,3 +27,22 @@ clean:
.PHONY: release
release:all
@cp -Rvp release/* ../release
+
+#############################################################################
+# Cache operations - only used when building through ci/build.sh
+#############################################################################
+
+# Clean local data related to caching - called prior to ordinary build
+.PHONY: clean-cache
+clean-cache: clean
+ @echo "clean-cache not implemented"
+
+# Try to download cache - called prior to ordinary build
+.PHONY: get-cache
+get-cache:
+ @echo "get-cache not implemented"
+
+# Store cache if not already stored - called after ordinary build
+.PHONY: put-cache
+put-cache:
+ @echo "put-cache not implemented"
diff --git a/fuel/build/f_isoroot/f_kscfg/Makefile b/fuel/build/f_isoroot/f_kscfg/Makefile
index 38305fd50..fe740418d 100644
--- a/fuel/build/f_isoroot/f_kscfg/Makefile
+++ b/fuel/build/f_isoroot/f_kscfg/Makefile
@@ -23,3 +23,22 @@ clean:
.PHONY: release
release: all
@cp -Rvp release/* ../release
+
+#############################################################################
+# Cache operations - only used when building through ci/build.sh
+#############################################################################
+
+# Clean local data related to caching - called prior to ordinary build
+.PHONY: clean-cache
+clean-cache: clean
+ @echo "clean-cache not implemented"
+
+# Try to download cache - called prior to ordinary build
+.PHONY: get-cache
+get-cache:
+ @echo "get-cache not implemented"
+
+# Store cache if not already stored - called after ordinary build
+.PHONY: put-cache
+put-cache:
+ @echo "put-cache not implemented"
diff --git a/fuel/build/f_isoroot/f_odlpluginbuild/Makefile b/fuel/build/f_isoroot/f_odlpluginbuild/Makefile
index ce9cd73e1..bc925e087 100644
--- a/fuel/build/f_isoroot/f_odlpluginbuild/Makefile
+++ b/fuel/build/f_isoroot/f_odlpluginbuild/Makefile
@@ -8,9 +8,7 @@
##############################################################################
TOP := $(shell pwd)
-DOCKNAME = fuelrepo
-DOCKVERSION = 1.0
-ODL_BRANCH="juno/lithium-sr1"
+ODL_BRANCH=juno/lithium-sr1
ODL_REPO="https://github.com/stackforge/fuel-plugin-opendaylight.git"
.PHONY: all
@@ -18,21 +16,57 @@ all: .odlbuild
.PHONY: clean
clean:
- # Deliberately not cleaning nailgun directory to speed up multiple builds
- @rm -f ../release/opnfv/opendaylight*.rpm
+ @rm -f .odlbuild ../release/opnfv/opendaylight*.rpm opendaylight*.rpm
+ @rm -f $(BUILD_BASE)/gitinfo_odlplugin.txt
.PHONY: release
release:.odlbuild
@rm -f ../release/opnfv/opendaylight*.rpm
@mkdir -p ../release/opnfv
- @cp opendaylight*.rpm ../release/opnfv/
+ @cp opendaylight*.rpm ../release/opnfv/
+ cp gitinfo_odlplugin.txt $(BUILD_BASE)
.odlbuild:
rm -rf fuel-plugin-opendaylight
sudo apt-get -y install build-essential ruby-dev rubygems-integration python-pip git rpm createrepo dpkg-dev
sudo gem install fpm
sudo pip install fuel-plugin-builder
- git clone -b ${ODL_BRANCH} ${ODL_REPO}
+ git clone -b $(ODL_BRANCH) $(ODL_REPO)
INCLUDE_DEPENDENCIES=true fpb --debug --build fuel-plugin-opendaylight/
mv fuel-plugin-opendaylight/opendaylight*.rpm .
+ $(REPOINFO) -r . > gitinfo_odlplugin.txt
rm -rf fuel-plugin-opendaylight
+ touch .odlbuild
+
+#############################################################################
+# Cache operations - only used when building through ci/build.sh
+#############################################################################
+
+
+# Create a unique hash to be used for getting and putting cache, based on:
+# - The SHA1 hash of the HEAD on the plugin repo's $(ODL_BRANCH)
+# - The contents of this Makefile
+.cacheid:
+ git ls-remote --heads $(ODL_REPO) | grep $(ODL_BRANCH) > .cachedata
+ sha1sum Makefile >> .cachedata
+ cat .cachedata | $(CACHETOOL) getid > .cacheid
+
+# Clean local data related to caching - called prior to ordinary build
+.PHONY: clean-cache
+clean-cache: clean
+ rm -f .cachedata .cacheid
+
+# Try to download cache - called prior to ordinary build
+.PHONY: get-cache
+get-cache: .cacheid
+ @if $(CACHETOOL) check $(shell cat .cacheid); then \
+ $(CACHETOOL) get $(shell cat .cacheid) | tar xf -;\
+ else \
+ echo "No cache item found for $(shell cat .cacheid)" ;\
+ exit 0;\
+ fi
+
+# Store cache if not already stored - called after ordinary build
+.PHONY: put-cache
+put-cache: .cacheid
+ @tar cf - .odlbuild opendaylight*.rpm gitinfo_odlplugin.txt | $(CACHETOOL) put $(shell cat .cacheid)
diff --git a/fuel/build/f_isoroot/f_repobuild/Makefile b/fuel/build/f_isoroot/f_repobuild/Makefile
index 03e4caecb..ad40d0b9a 100644
--- a/fuel/build/f_isoroot/f_repobuild/Makefile
+++ b/fuel/build/f_isoroot/f_repobuild/Makefile
@@ -10,17 +10,13 @@
SHELL := /bin/bash
TOP := $(shell pwd)
-DOCKNAME = fuelrepo
-DOCKVERSION = 1.0
RSYNC_HOST := $(shell ./select_ubuntu_repo.sh)
.PHONY: all
-all: .nailgun
+all: nailgun
-.nailgun:
- sudo apt-get update
- sudo apt-get upgrade -y
+nailgun:
sudo apt-get install -y rsync python python-yaml dpkg-dev openssl
rm -rf tmpiso tmpdir
mkdir tmpiso
@@ -37,16 +33,45 @@ all: .nailgun
sudo su - -c /opt/fuel-createmirror-6.1/fuel-createmirror
sudo chmod -R 755 /var/www/nailgun
cp -Rp /var/www/nailgun .
- touch .nailgun
.PHONY: clean
clean:
- # Deliberately not cleaning nailgun directory to speed up multiple builds
- @rm -rf ../release/opnfv/nailgun fuel-createmirror_6.1*.deb
+ @rm -rf ../release/opnfv/nailgun nailgun fuel-createmirror_6.1*.deb
.PHONY: release
-release:.nailgun
+release:nailgun
@rm -Rf ../release/opnfv/nailgun
@mkdir -p ../release/opnfv
@cp -Rp nailgun ../release/opnfv/nailgun
+#############################################################################
+# Cache operations - only used when building through ci/build.sh
+#############################################################################
+
+# Create a unique hash to be used for getting and putting cache, based on:
+# - Year and week (causing the cache to be rebuilt weekly)
+# - The contents of this Makefile
+.cacheid:
+ date +"Repocache %G%V" > .cachedata
+ sha1sum Makefile >> .cachedata
+ cat .cachedata | $(CACHETOOL) getid > .cacheid
+
+# Clean local data related to caching - called prior to ordinary build
+.PHONY: clean-cache
+clean-cache: clean
+ rm -f .cachedata .cacheid
+
+# Try to download cache - called prior to ordinary build
+.PHONY: get-cache
+get-cache: .cacheid
+ @if $(CACHETOOL) check $(shell cat .cacheid); then \
+ $(CACHETOOL) get $(shell cat .cacheid) | tar xf -;\
+ else \
+ echo "No cache item found for $(shell cat .cacheid)" ;\
+ exit 0;\
+ fi
+
+# Store cache if not already stored - called after ordinary build
+.PHONY: put-cache
+put-cache: .cacheid
+ @tar cf - nailgun | $(CACHETOOL) put $(shell cat .cacheid)
diff --git a/fuel/build/install/install.sh b/fuel/build/install/install.sh
index f0bb84914..6155a4162 100755
--- a/fuel/build/install/install.sh
+++ b/fuel/build/install/install.sh
@@ -252,6 +252,10 @@ iso_modify_image () {
cd $TOP/release/isoroot
cp -Rvp . $DEST
+
+ # Add all Git info files
+ sort $TOP/gitinfo*.txt > $DEST/gitinfo.txt
+ cp $DEST/gitinfo.txt $REPORTFILE
}
make_iso() {
@@ -465,7 +469,7 @@ if [ $MODE = "iso" ]; then
echo "Opening reportfile at $REPORTFILE"
touch $REPORTFILE
if [ ! -f $ORIGISO ]; then
- echo "Can't find original MOS 5.1 iso at $ORIGISO"
+ echo "Can't find original iso at $ORIGISO"
rm $CONF
exit 1
fi
diff --git a/fuel/build/repo_info.sh b/fuel/build/repo_info.sh
new file mode 100755
index 000000000..347ede7f7
--- /dev/null
+++ b/fuel/build/repo_info.sh
@@ -0,0 +1,63 @@
+#!/bin/bash
+##############################################################################
+# Copyright (c) 2015 Ericsson AB and others.
+# stefan.k.berg@ericsson.com
+# jonas.bjurel@ericsson.com
+# All rights reserved. This program and the accompanying materials
+# are made available under the terms of the Apache License, Version 2.0
+# which accompanies this distribution, and is available at
+# http://www.apache.org/licenses/LICENSE-2.0
+##############################################################################
+
+usage() {
+ cat <<EOF
+Usage: `basename $0` [-r] <path>
+
+ -r
+ Recursively list all repos found starting at <path>
+ -h
+ Display help text
+EOF
+}
+
+repoinfo() {
+ repotop=$(git -C $1 rev-parse --show-toplevel)
+ origin=$(git -C $repotop config --get remote.origin.url)
+ sha1=$(git -C $repotop rev-parse HEAD)
+ echo "$origin: $sha1"
+}
+
+
+if [ $# -eq 2 ]; then
+ case $1 in
+ -r)
+ RECURSE=1
+ shift
+ ;;
+ -h)
+ usage
+ exit 0
+ ;;
+ *)
+ echo "Error, argument $1 not known" >&2
+ usage
+ exit 1
+ esac
+fi
+
+if [ $# -gt 1 ]; then
+ echo "Error, too many arguments" >&2
+ usage
+ exit 1
+fi
+
+abspath=$(readlink -f $1)
+
+if [ -n "$RECURSE" ]; then
+ for dir in $(find $abspath -type d -name .git)
+ do
+ repoinfo $(readlink -f $dir/..)
+ done
+else
+ repoinfo $abspath
+fi