Merge "[BGPVPN] Do not include temporary files in plugin"
[fuel.git] / build / cache.sh
index 07361d2..7a2a063 100755 (executable)
@@ -19,7 +19,6 @@ exit_trap() {
 trap exit_trap EXIT
 
 CACHETRANSPORT=${CACHETRANSPORT:-"curl --silent"}
-CACHEBASE=${CACHEBASE:-"file://${HOME}/cache"}
 CACHEMAXAGE=${CACHEMAXAGE:-$[14*24*3600]}
 CACHEDEBUG=${CACHEDEBUG:-1}
 
@@ -34,6 +33,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 +138,19 @@ getcommitid() {
     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"