diff options
author | Stefan K. Berg <stefan.k.berg@ericsson.com> | 2015-11-19 13:39:59 +0100 |
---|---|---|
committer | Stefan K. Berg <stefan.k.berg@ericsson.com> | 2015-11-19 13:40:15 +0100 |
commit | 095442c4bdf437531eae2aecd364e74d756757fd (patch) | |
tree | 35d9473bfab5cf8dd1ea532306e6ae995602d20c /fuel/build/cache.sh | |
parent | b13de8d8c1afb3d1106d839385572dee4e2077bf (diff) |
Cleaning up the experimental branch
Should not be used any more!
Change-Id: I38fd1ea34aaa12c5d7d060bca47d1866bc97d185
Signed-off-by: Stefan K. Berg <stefan.k.berg@ericsson.com>
Diffstat (limited to 'fuel/build/cache.sh')
-rwxr-xr-x | fuel/build/cache.sh | 112 |
1 files changed, 0 insertions, 112 deletions
diff --git a/fuel/build/cache.sh b/fuel/build/cache.sh deleted file mode 100755 index c8cd1b03d..000000000 --- a/fuel/build/cache.sh +++ /dev/null @@ -1,112 +0,0 @@ -#!/bin/bash -############################################################################## -# Copyright (c) 2015 Ericsson AB and others. -# stefan.k.berg@ericsson.com -# jonas.bjurel@ericsson.com -# All rights reserved. This program and the accompanying materials -# are made available under the terms of the Apache License, Version 2.0 -# which accompanies this distribution, and is available at -# http://www.apache.org/licenses/LICENSE-2.0 -############################################################################## - -CACHETRANSPORT=${CACHETRANSPORT:-"curl --silent"} -CACHEBASE=${CACHEBASE:-"file://${HOME}/cache"} -CACHEMAXAGE=${CACHEMAXAGE:-$[14*24*3600]} -CACHEDEBUG=${CACHEDEBUG:-1} - -debugmsg () { - if [ "$CACHEDEBUG" -eq 1 ]; then - echo "$@" >&2 - fi -} - -errormsg () { - echo "$@" >&2 -} - -# Get a SHA1 based on what's piped into the cache command -getid() { - debugmsg "Generating sha1sum" - sha1sum | sed 's/ .*//' -} - - -# Put in cache -put() { - if check $1; then - debugmsg "SHA1 $1 already in cache, skipping storage" - else - debugmsg "Storing SHA1 $1 in cache" - ${CACHETRANSPORT} -T - ${CACHEBASE}/$1.blob - echo "Expires: $[`date +"%s"` + $CACHEMAXAGE]" | ${CACHETRANSPORT} -T - ${CACHEBASE}/$1.meta - fi - exit 0 -} - -# Get from cache -get() { - local rc - - ${CACHETRANSPORT} -o - ${CACHEBASE}/$1.blob 2>/dev/null - rc=$? - - if [ $rc -eq 0 ]; then - echo "Got SHA1 $1 from cache" 2>/dev/null - else - echo "Tried to get SHA1 $1 from cache but failed" 2>/dev/null - fi - - return $? -} - -# Check if in cache -check() { - local rc - - ${CACHETRANSPORT} ${CACHEBASE}/$1.meta &>/dev/null - rc=$? - - if [ $rc -eq 0 ]; then - debugmsg "Checking for SHA1 $1 in cache and found it, rc = $rc" - else - debugmsg "Checking for SHA1 $1 in cache and failed, rc = $rc" - fi - - return $rc -} - -# Verify that SHA1 seems to be a SHA1... -validSHA1() { - if [ $(echo $1 | wc -c) -ne 41 ]; then - return 1 - else - return 0 - fi -} - -case $1 in - getid) - if [ $# -ne 1 ]; then - errormsg "No arguments can be given to getid!" - exit 1 - fi - getid - ;; - get|check|put) - if [ $# -ne 2 ]; then - errormsg "Only one argument, the SHA1 sum, can be given to getid!" - exit 1 - else - if ! validSHA1 $2; then - errormsg "Invalid SHA1 format!" - exit 1 - fi - fi - - $1 $2 - exit $rc - ;; - *) - errormsg "I only know about getid, check, get and put!" - exit 1 -esac |