From: Michael Tremer Date: Tue, 24 Nov 2015 09:33:00 +0000 (+0100) Subject: Keep the latest two successful builds X-Git-Url: http://git.ipfire.org/?a=commitdiff_plain;h=375fb42848fc061083d91732f11a88ca2a3fd05d;p=people%2Fms%2Fnightly-builds.git Keep the latest two successful builds Signed-off-by: Michael Tremer --- diff --git a/server-scripts/ipfire-cleanup-nightly-builds.sh b/server-scripts/ipfire-cleanup-nightly-builds.sh index cd65a95..711a852 100755 --- a/server-scripts/ipfire-cleanup-nightly-builds.sh +++ b/server-scripts/ipfire-cleanup-nightly-builds.sh @@ -1,11 +1,31 @@ #!/bin/bash -l BASEDIR="/pub/nightly" +declare -A ARCHES +ARCHES["master"]="x86_64 i586" +ARCHES["next"]="x86_64 i586 armv5tel" MAX_AGE=$(( 7 * 24 * 3600 )) # 7 days NOW="$(date +"%s")" +all_successful() { + local branch="${1}" + local release="${2}" + + local arches="${ARCHES[${branch}]}" + [ -z "${arches}" ] && return 0 + + local arch + for arch in ${arches}; do + if [ ! -e "${release}/${arch}/.success" ]; then + return 1 + fi + done + + return 0 +} + for branch in $(find "${BASEDIR}" -mindepth 1 -maxdepth 1 -type d); do counter=0 @@ -14,7 +34,7 @@ for branch in $(find "${BASEDIR}" -mindepth 1 -maxdepth 1 -type d); do [ "${time}" = "latest" ] && continue # Never delete the last two builds - if [ "${counter}" -lt 2 ]; then + if [ "${counter}" -lt 2 ] && all_successful "$(basename ${branch})" "${build}"; then counter=$(( ${counter} + 1 )) continue fi