--- /dev/null
+#!/bin/bash
+
+max_lifetime="$1"
+
+tree_birth="$(date --reference=tree.timestamp +%s 2>/dev/null)"
+tree_age="$(( $(date +%s) - ${tree_birth:-0} ))"
+
+if [ $max_lifetime -le 0 ]; then
+ echo "No tree expiry set."
+
+elif [ $tree_age -ge $max_lifetime ]; then
+ echo "The build tree reached its maximum lifetime, cleaning up."
+ find . -mindepth 1 -maxdepth 1 -print0 | xargs -r -0 rm -vrf | while read entry do
+ printf "."
+ done
+
+ echo ""
+ echo "Writing new timestamp"
+ date +%s > tree.timestamp
+
+else
+ echo "The build tree is not expired."
+fi
+
+exit 0
####### CHANGESOURCES
home_dir = os.path.abspath(ini.get("general", "homedir"))
+tree_expire = 0
+
+if ini.has_option("general", "expire"):
+ tree_expire = ini.getint("general", "expire")
repo_url = ini.get("repo", "url")
description = "Finding number of CPUs",
command = ["nproc"]))
+ # expire tree if needed
+ if tree_expire > 0:
+ factory.addStep(FileDownload(
+ mastersrc = "expire.sh",
+ slavedest = "expire.sh",
+ mode = 0755))
+
+ factory.addStep(ShellCommand(
+ name = "expire",
+ description = "Checking for build tree expiry",
+ command = ["./expire.sh", tree_expire],
+ workdir = ".",
+ haltOnFailure = True,
+ timeout = 2400))
+
# check out the source
factory.addStep(Git(repourl=repo_url, mode='update'))