From af2db33a0ebab98700c3c03ea84a6ba9b987c5b5 Mon Sep 17 00:00:00 2001 From: Jonas Bjurel Date: Fri, 30 Sep 2016 20:28:22 +0200 Subject: Preparing the experimental branch for improved Danube CI/CD experiments Fast forwarded to commit:cf93e6ee11c96de090b04196cc96b4a6b0948928 Change-Id: I13d10d870e8ffc7317ab03f8810592d5b2205875 Signed-off-by: Jonas Bjurel --- ci/clean_cache.sh | 38 ++++++++++++++++++++++++++++++++++++++ 1 file changed, 38 insertions(+) create mode 100755 ci/clean_cache.sh (limited to 'ci/clean_cache.sh') diff --git a/ci/clean_cache.sh b/ci/clean_cache.sh new file mode 100755 index 000000000..177fe821b --- /dev/null +++ b/ci/clean_cache.sh @@ -0,0 +1,38 @@ +#!/bin/bash +############################################################################## +# Copyright (c) 2016 Ericsson AB and others. +# stefan.k.berg@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 +############################################################################## + +# Clean the build cache according to its expiry date. Invoke with the cache +# directory as the first argument. + +if [ -z "$1" ]; then + echo "No cache directory specified, exiting..." + exit 1 +else + CACHEDIR=$1 + echo "Operating on cache $CACHEDIR" +fi + +NOW=$(date '+%s') + +cd $CACHEDIR +echo "Step 1, cleaning orphaned meta and blob files" +ls *.meta *.blob | sed 's/\..*//' | sort | uniq -u | xargs -n 1 -I {} sh -c "rm -vf {}.*" +echo "Step 2, cleaning expired files" +for cache in $(ls -1 *.meta | sed 's/\..*//') +do + blob=${cache}.blob + meta=${cache}.meta + expiry=$(grep Expires: $meta | sed 's/Expires: *//') + if [ $expiry -le $NOW ]; then + echo "$cache expired $(date -d "@$expiry"), removing..." + rm -f $blob $meta + fi +done + -- cgit 1.2.3-korg