X-Git-Url: https://gerrit.opnfv.org/gerrit/gitweb?a=blobdiff_plain;f=build%2Fcache.sh;h=d4b2c45ddb8bc5d44856156c2d284a905880fb5d;hb=4412a834b3c82d38a97bf65d096acab72980e9f4;hp=07361d28adaba8641c403b44038e2afdab8f090e;hpb=23e7333bb4e4ec228596d994bec18dc8d0670b2e;p=fuel.git diff --git a/build/cache.sh b/build/cache.sh index 07361d28a..d4b2c45dd 100755 --- a/build/cache.sh +++ b/build/cache.sh @@ -19,9 +19,9 @@ exit_trap() { trap exit_trap EXIT CACHETRANSPORT=${CACHETRANSPORT:-"curl --silent"} -CACHEBASE=${CACHEBASE:-"file://${HOME}/cache"} CACHEMAXAGE=${CACHEMAXAGE:-$[14*24*3600]} CACHEDEBUG=${CACHEDEBUG:-1} +PLUGINS_MATCH="${BUILD_BASE}/f_isoroot/*/" debugmsg () { if [ "$CACHEDEBUG" -eq 1 ]; then @@ -34,6 +34,13 @@ errorexit () { exit 1 } +# Generate a unique number every two weeks - a service routine that +# can be used when generating the SHA1 to make sure that the cache is +# rebuilt bi-weekly even if no pruning of the cache is taking place. +getbiweek () { + echo "$(date +'%G')$[10#$(date +'%V')/2]" +} + # Get a SHA1 based on what's piped into the cache command getid() { debugmsg "Generating sha1sum" @@ -132,7 +139,34 @@ getcommitid() { fi } +packages() { + local PLUGINS_SHA1='' + + # globbing expansion is alphabetical + for plugin in $PLUGINS_MATCH ; do + if [ -f "${plugin}packages.yaml" ] + then + PLUGINS_SHA1+=$(sha1sum ${plugin}packages.yaml) + fi + done + + if [ -n "${PLUGINS_SHA1}" ] + then + echo -n $PLUGINS_SHA1 | sha1sum + fi +} + +if [ -z "$CACHEBASE" ]; then + errorexit "CACHEBASE not set - exiting..." +fi + case $1 in + getbiweek) + if [ $# -ne 1 ]; then + errorexit "No arguments can be given to getbiweek!" + fi + getbiweek + ;; getcommitid) if [ $# -ne 3 ]; then errorexit "Arg 1 needs to be URI and arg 2 tag/branch/commit" @@ -158,6 +192,12 @@ case $1 in $1 $2 exit $rc ;; + packages) + if [ $# -ne 1 ]; then + errorexit "No arguments can be given to packages!" + fi + packages + ;; *) errorexit "I only know about getcommitid, getid, check, get and put!" esac