From 3f42e219d2b2e531a9aa9722ee795cb3a686a017 Mon Sep 17 00:00:00 2001 From: Jonas Bjurel Date: Sat, 19 Sep 2015 18:53:42 +0200 Subject: [PATCH] Modified cache naming. Now the cache name comprises an xor of the following: - 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 --- fuel/ci/build.sh | 36 +++++++++++++++++++++++++++++++++++- 1 file changed, 35 insertions(+), 1 deletion(-) diff --git a/fuel/ci/build.sh b/fuel/ci/build.sh index 0f544b4..f8e164a 100755 --- a/fuel/ci/build.sh +++ b/fuel/ci/build.sh @@ -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 ############################################################################ -- 2.16.6