]> git.ipfire.org Git - people/ms/nightly-builds.git/commitdiff
Keep the latest two successful builds
authorMichael Tremer <michael.tremer@ipfire.org>
Tue, 24 Nov 2015 09:33:00 +0000 (10:33 +0100)
committerMichael Tremer <michael.tremer@ipfire.org>
Tue, 24 Nov 2015 09:33:00 +0000 (10:33 +0100)
Signed-off-by: Michael Tremer <michael.tremer@ipfire.org>
server-scripts/ipfire-cleanup-nightly-builds.sh

index cd65a9548779d667d498b055b07a23945d7a3882..711a8525d31e16aa1ec0970a584bb29f35961766 100755 (executable)
@@ -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