X-Git-Url: https://gerrit.opnfv.org/gerrit/gitweb?a=blobdiff_plain;f=build%2Fcache.sh;h=4c530b02de307e0c9f20b9c3be554808f56344f5;hb=a32ab67813d8e33c359a5205d221e71ca9409091;hp=0c2da399fc3514531ef77102212255efc6cd7431;hpb=9131b0a81c22e713b4d4798d7ff32254be3b99e3;p=apex.git diff --git a/build/cache.sh b/build/cache.sh index 0c2da399..4c530b02 100644 --- a/build/cache.sh +++ b/build/cache.sh @@ -7,9 +7,7 @@ # which accompanies this distribution, and is available at # http://www.apache.org/licenses/LICENSE-2.0 ############################################################################## - -CACHE_DIR="$(pwd)/.cache" -CACHE_HISTORY=".cache_history" +source ./variables.sh # Make sure the cache dir exists function cache_dir { @@ -19,10 +17,6 @@ function cache_dir { echo "Cache Dir: $CACHE_DIR" } -function cache_git_tar { - echo "cache_git_tar git ls-remote" -} - # $1 = download url # $2 = filename to write to function curl_file { @@ -52,22 +46,22 @@ function populate_cache { # check if the cache file exists # and if it has an md5 compare that - echo "Checking cache file exists: ${filename}" + echo "Checking if cache file exists: ${filename}" if [ ! -f $CACHE_DIR/${filename} ]; then echo "Cache file: ${CACHE_DIR}/${filename} missing...will download..." curl_file $1 $filename else echo "Cache file exists...comparing MD5 checksum" - if [ -z $remote_md5 ]; then + if [ -z "$remote_md5" ]; then remote_md5="$(curl -sf -L ${1}.md5 | awk {'print $1'})" fi if [ -z "$remote_md5" ]; then echo "Got empty MD5 from remote for $filename, skipping MD5 check" curl_file $1 $filename else - my_md5=$(grep ${filename} $CACHE_HISTORY | awk {'print $1'}) + my_md5=$(grep ${filename} ${CACHE_DIR}/${CACHE_HISTORY} | awk {'print $1'}) if [ -z "$my_md5" ]; then - echo "${filename} missing in $CACHE_HISTORY file. Caculating md5..." + echo "${filename} missing in ${CACHE_HISTORY} file. Caculating md5..." my_md5=$(md5sum ${CACHE_DIR}/${filename} | awk {'print $1'}) fi if [ "$remote_md5" != "$my_md5" ]; then @@ -81,16 +75,3 @@ function populate_cache { fi fi } - -# $1 = filename to get from cache -# $2 = destintation -function get_cached_file { - if [ ! -f $CACHE_DIR/$1 ]; then - echo "Cache file: ${CACHE_DIR}/$1 is not in cache." - else - echo "Cache file: Using cached file ${CACHE_DIR}/$1." - dest='.' - if [ -n $2 ]; then dest=$2; fi - cp -f $CACHE_DIR/$1 $dest - fi -}