Modified cache naming. Now the cache name comprises an xor of the following: 01/1801/2
authorJonas Bjurel <jonas.bjurel@ericsson.com>
Sat, 19 Sep 2015 16:53:42 +0000 (18:53 +0200)
committerJonas Bjurel <jonas.bjurel@ericsson.com>
Mon, 21 Sep 2015 08:48:17 +0000 (08:48 +0000)
- config.mk
- cache.mk
- Upstream fuel commit-id

This should avoid any cache flapping, and insted produce a unique cache for any permutation of the above identities.

Change-Id: Ieb28748ae9075725e54f6a5e87740281bf81116e
Signed-off-by: Jonas Bjurel <jonas.bjurel@ericsson.com>
fuel/ci/build.sh

index 0f544b4..f8e164a 100755 (executable)
@@ -79,6 +79,32 @@ EOF
 # END of usage description
 ############################################################################
 
+############################################################################
+# Begin of string xor function
+#
+function  xor()
+{
+      local res=(`echo "$1" | sed "s/../0x& /g"`)
+      shift 1
+      while [[ "$1" ]]; do
+            local one=(`echo "$1" | sed "s/../0x& /g"`)
+            local count1=${#res[@]}
+            if [ $count1 -lt ${#one[@]} ]
+            then
+                  count1=${#one[@]}
+            fi
+            for (( i = 0; i < $count1; i++ ))
+            do
+                  res[$i]=$((${one[$i]:-0} ^ ${res[$i]:-0}))
+            done
+            shift 1
+      done
+       printf "%02x" "${res[@]}"
+}
+#
+# END of string xor function
+############################################################################
+
 ############################################################################
 # BEGIN of variables to customize
 #
@@ -87,7 +113,7 @@ RESULT_DIR="${BUILD_BASE}/release"
 BUILD_SPEC="${BUILD_BASE}/config.mk"
 CACHE_DIR="cache"
 LOCAL_CACHE_ARCH_NAME="fuel-cache"
-REMOTE_CACHE_ARCH_NAME="fuel_cache-$(md5sum ${BUILD_SPEC}| cut -f1 -d " ")"
+
 REMOTE_ACCESS_METHD=curl
 INCLUDE_DIR=../include
 #
@@ -117,6 +143,14 @@ BUILD_DIR=
 BUILD_LOG=
 BUILD_VERSION=
 MAKE_ARGS=
+FUEL_GIT_SRC="$(make -f ../build/config.mk get-fuel-repo | cut -d " " -f1)"
+FUEL_GIT_BRANCH="$(make -f ../build/config.mk get-fuel-repo | cut -d " " -f2)"
+CACHE_MD5=$(md5sum ../build/cache.mk | cut -f1 -d " ")
+CONFIG_MD5=$(md5sum ../build/config.mk | cut -f1 -d " ")
+FUEL_COMMIT_ID=$(git ls-remote $FUEL_GIT_SRC -t $FUEL_GIT_BRANCH | cut -d $'\t' -f1)
+REMOTE_CACHE_ARCH_HASH_TMP="$(xor $CACHE_MD5 $CONFIG_MD5)"
+REMOTE_CACHE_ARCH_HASH="$(xor $REMOTE_CACHE_ARCH_HASH_TMP $FUEL_COMMIT_ID)"
+REMOTE_CACHE_ARCH_NAME="fuel_cache-$REMOTE_CACHE_ARCH_HASH"
 #
 # END of script assigned variables
 ############################################################################