From c0b6165d5b4cad19eee70b1cdbf85fd8d2a24c95 Mon Sep 17 00:00:00 2001 From: Nikolas Hermanns Date: Wed, 31 Aug 2016 09:21:53 +0200 Subject: [PATCH] Adding caching possiblity The user has now 2 new variables to control a cache. CACHE true -> use cache if exsist and create cash false -> do not use cache RENEW -> Only makes sense when cache is true true -> renews the cache false -> use the old cache Change-Id: I8da91f6ec2937e6b6e0c66eabdfd41fac6a490b5 --- pre_build_hook | 19 +++++++++++++++++++ 1 file changed, 19 insertions(+) diff --git a/pre_build_hook b/pre_build_hook index aef0b59..c3ac564 100755 --- a/pre_build_hook +++ b/pre_build_hook @@ -4,7 +4,18 @@ # like packages building, packages downloading from mirrors and so on. # The script should return 0 if there were no errors. set -eux +CACHE=${CACHE:-false} +RENEW=${RENEW:-false} +DIR="$(dirname `readlink -f $0`)" +if [ "$CACHE" == true ];then + export cache_dir=$DIR/.cache/; + if [ -e $cache_dir ] && [[ "$RENEW" == false ]];then + export OPNFV_QUAGGE_PACKAGING_REPO=$cache_dir/opnfv-quagga/; + export NETWORKING_ODL_REPO=$cache_dir/networking_odl/; + export ODL_TARBALL_LOCATION=$cache_dir/karaf-odl.tar.gz; + fi +fi # Where we can find odl karaf distribution tarball # can be http(s) url or absolute path ODL_TARBALL_LOCATION=${ODL_TARBALL_LOCATION:-https://nexus.opendaylight.org/content/repositories/public/org/opendaylight/integration/distribution-karaf/0.4.3-Beryllium-SR3/distribution-karaf-0.4.3-Beryllium-SR3.tar.gz} @@ -225,6 +236,14 @@ do build_pkg $system done +if [ "$CACHE" == true ];then + if [ ! -e $cache_dir ] || [[ "$RENEW" == true ]];then + rm -rf $cache_dir + mkdir -p $cache_dir + cp -r ${DIR}/tmp/* $cache_dir/ + fi +fi + if [ "$CLEANUP" != false ];then cleanup fi