Unverified Commit 1e309ab1 authored by Shawn Webb's avatar Shawn Webb
Browse files

Finish the cleanup script



I really should've tackled this sooner. The cleanup script is a rather
dumb one, keeping up to a configurable number of builds.
Signed-off-by: Shawn Webb's avatarShawn Webb <shawn.webb@hardenedbsd.org>
parent a80ff7d2
......@@ -57,8 +57,8 @@ main() {
esac
done
# TODO: provide our own version of config_set_dynamic
config_set_dynamic
cleanup_set_dynamic
HBSD_LOCKFILE="${HBSD_LOCKFILE}.cleanup"
(
assert_unlocked && \
......
......@@ -57,3 +57,16 @@ config_set_dynamic() {
return 0
}
cleanup_set_dynamic() {
if [ ! -h ${HBSD_PUBDIR}/BUILD-LATEST ]; then
echo "Could not find symlink at ${HBSD_PUBDIR}/BUILD-LATEST"
HBSD_BUILDNUMBER=0
return 0
fi
HBSD_BUILDNUMBER=$(readlink ${HBSD_PUBDIR}/BUILD-LATEST)
HBSD_BUILDNUMBER=${HBSD_BUILDNUMBER##*-}
echo "[*] Build number: ${HBSD_BUILDNUMBER}"
return 0
}
......@@ -115,13 +115,12 @@ should_build() {
prune_old_builds() {
[ ${HBSD_BUILDNUMBER} -lt ${HBSD_KEEP_NBUILDS} ] && return 0
return 0
floor=$((${HBSD_BUILDNUMBER} - ${HBSD_KEEP_NBUILDS}))
for d in $(find ${HBSD_PUBDIR} -maxdepth 1 -type d | sed 1d); do
n=$(basename ${d})
if [ ${n} -lt ${floor} ]; then
echo "[*] Removing ${d}"
rm -rf ${d}
fi
done
......
Supports Markdown
0% or .
You are about to add 0 people to the discussion. Proceed with caution.
Finish editing this message first!
Please register or to comment