Rebase to ovs 2.6.x and NSH
[fuel.git] / build / cache.sh
index b5f0902..d4b2c45 100755 (executable)
@@ -21,6 +21,7 @@ trap exit_trap EXIT
 CACHETRANSPORT=${CACHETRANSPORT:-"curl --silent"}
 CACHEMAXAGE=${CACHEMAXAGE:-$[14*24*3600]}
 CACHEDEBUG=${CACHEDEBUG:-1}
+PLUGINS_MATCH="${BUILD_BASE}/f_isoroot/*/"
 
 debugmsg () {
     if [ "$CACHEDEBUG" -eq 1 ]; then
@@ -37,7 +38,7 @@ errorexit () {
 # 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')$[$(date +'%V')/2]"
+  echo "$(date +'%G')$[10#$(date +'%V')/2]"
 }
 
 # Get a SHA1 based on what's piped into the cache command
@@ -138,7 +139,22 @@ 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..."
@@ -176,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