blob: 098123093c95c5bae46b7ae525ef66663f6c9302 [file] [log] [blame]
david_williamse5298172007-12-20 03:30:54 +00001#!/bin/sh
2
3
david_williams53f9de12008-01-02 19:31:06 +00004# remember to leave no slashes on filename in source command,
david_williamse5298172007-12-20 03:30:54 +00005# (the commonVariations.shsource file, that is)
6# so that users path is used to find it (first)
david_williams5dc46da2008-01-13 06:39:38 +00007if [ -z $BUILD_INITIALIZED ]
david_williamse5298172007-12-20 03:30:54 +00008then
david_williams53f9de12008-01-02 19:31:06 +00009 source commonVariations.shsource
10 source ${BUILD_HOME}/releng.control/commonComputedVariables.shsource
david_williamse5298172007-12-20 03:30:54 +000011fi
12
13# remove artifacts over n days old
david_williams53f9de12008-01-02 19:31:06 +000014# (where hours = 24 + (n * 24), basically, so that
david_williamse5298172007-12-20 03:30:54 +000015# even n=0 means "1 day")
16
david_williams53f9de12008-01-02 19:31:06 +000017# set at 10 days, under assumption that before that time,
david_williamse0f67a32007-12-20 03:39:17 +000018# artifacts will be "saved" elsewhere, if needed.
david_williams53f9de12008-01-02 19:31:06 +000019# if more cleanup is needed, we should take time, and
david_williamsfd4706f2007-12-20 03:40:47 +000020# existence of more recent builds into account, so we never
david_williams53f9de12008-01-02 19:31:06 +000021# delete the last existing build (even if "old").
david_williamseececc12007-12-20 04:36:02 +000022
david_williams5dc46da2008-01-13 06:39:38 +000023ndays=4;
david_williamsad915d12008-01-07 22:22:20 +000024artifactsDir=${PROJECT_ARTIFACTS};
david_williamse5298172007-12-20 03:30:54 +000025
david_williamseececc12007-12-20 04:36:02 +000026echo;
david_williams5dc46da2008-01-13 06:39:38 +000027echo " Removing artifact directories older than ${ndays} days";
david_williamsdd190e12007-12-20 04:37:14 +000028echo " (from ${artifactsDir})";
david_williamseececc12007-12-20 04:36:02 +000029before=`find ${artifactsDir} -mindepth 2 -maxdepth 2 | wc -l`;
30echo " number of directories before cleaning: ${before}";
david_williamse5298172007-12-20 03:30:54 +000031
david_williams5dc46da2008-01-13 06:39:38 +000032# empty directories often result from "bad builds". We remove those no matter how old
david_williams42a883e2008-01-07 22:37:54 +000033find ${artifactsDir} -mindepth 2 -maxdepth 3 -type d -empty -exec rm -fr '{}' \;
david_williams2a47e172008-01-07 22:27:12 +000034# now remove old ones
david_williams5dc46da2008-01-13 06:39:38 +000035find ${artifactsDir} -mindepth 2 -maxdepth 2 -ctime +$ndays -execdir ${BUILD_HOME}/releng.control/removeIf.sh '{}' \;
david_williamse5298172007-12-20 03:30:54 +000036
david_williamseececc12007-12-20 04:36:02 +000037after=`find ${artifactsDir} -mindepth 2 -maxdepth 2 | wc -l`;
38echo " number of directories after cleaning: ${after}";
39echo;