david_williams | e529817 | 2007-12-20 03:30:54 +0000 | [diff] [blame] | 1 | #!/bin/sh |
| 2 | |
| 3 | |
david_williams | 53f9de1 | 2008-01-02 19:31:06 +0000 | [diff] [blame] | 4 | # remember to leave no slashes on filename in source command, |
david_williams | e529817 | 2007-12-20 03:30:54 +0000 | [diff] [blame] | 5 | # (the commonVariations.shsource file, that is) |
| 6 | # so that users path is used to find it (first) |
david_williams | 53f9de1 | 2008-01-02 19:31:06 +0000 | [diff] [blame] | 7 | if [ -n $BUILD_INITIALIZED ] |
david_williams | e529817 | 2007-12-20 03:30:54 +0000 | [diff] [blame] | 8 | then |
david_williams | 53f9de1 | 2008-01-02 19:31:06 +0000 | [diff] [blame] | 9 | source commonVariations.shsource |
| 10 | source ${BUILD_HOME}/releng.control/commonComputedVariables.shsource |
david_williams | e529817 | 2007-12-20 03:30:54 +0000 | [diff] [blame] | 11 | fi |
| 12 | |
| 13 | # remove artifacts over n days old |
david_williams | 53f9de1 | 2008-01-02 19:31:06 +0000 | [diff] [blame] | 14 | # (where hours = 24 + (n * 24), basically, so that |
david_williams | e529817 | 2007-12-20 03:30:54 +0000 | [diff] [blame] | 15 | # even n=0 means "1 day") |
| 16 | |
david_williams | 53f9de1 | 2008-01-02 19:31:06 +0000 | [diff] [blame] | 17 | # set at 10 days, under assumption that before that time, |
david_williams | e0f67a3 | 2007-12-20 03:39:17 +0000 | [diff] [blame] | 18 | # artifacts will be "saved" elsewhere, if needed. |
david_williams | 53f9de1 | 2008-01-02 19:31:06 +0000 | [diff] [blame] | 19 | # if more cleanup is needed, we should take time, and |
david_williams | fd4706f | 2007-12-20 03:40:47 +0000 | [diff] [blame] | 20 | # existence of more recent builds into account, so we never |
david_williams | 53f9de1 | 2008-01-02 19:31:06 +0000 | [diff] [blame] | 21 | # delete the last existing build (even if "old"). |
david_williams | eececc1 | 2007-12-20 04:36:02 +0000 | [diff] [blame] | 22 | |
david_williams | e0f67a3 | 2007-12-20 03:39:17 +0000 | [diff] [blame] | 23 | n=10; |
david_williams | ad915d1 | 2008-01-07 22:22:20 +0000 | [diff] [blame] | 24 | artifactsDir=${PROJECT_ARTIFACTS}; |
david_williams | e529817 | 2007-12-20 03:30:54 +0000 | [diff] [blame] | 25 | |
david_williams | eececc1 | 2007-12-20 04:36:02 +0000 | [diff] [blame] | 26 | echo; |
| 27 | echo " Removing artifact directories older than ${n} days"; |
david_williams | dd190e1 | 2007-12-20 04:37:14 +0000 | [diff] [blame] | 28 | echo " (from ${artifactsDir})"; |
david_williams | eececc1 | 2007-12-20 04:36:02 +0000 | [diff] [blame] | 29 | before=`find ${artifactsDir} -mindepth 2 -maxdepth 2 | wc -l`; |
| 30 | echo " number of directories before cleaning: ${before}"; |
david_williams | e529817 | 2007-12-20 03:30:54 +0000 | [diff] [blame] | 31 | |
david_williams | 2a47e17 | 2008-01-07 22:27:12 +0000 | [diff] [blame] | 32 | # empty directories often result from "bad builds" |
david_williams | 42a883e | 2008-01-07 22:37:54 +0000 | [diff] [blame^] | 33 | find ${artifactsDir} -mindepth 2 -maxdepth 3 -type d -empty -exec rm -fr '{}' \; |
david_williams | 2a47e17 | 2008-01-07 22:27:12 +0000 | [diff] [blame] | 34 | # now remove old ones |
david_williams | eececc1 | 2007-12-20 04:36:02 +0000 | [diff] [blame] | 35 | find ${artifactsDir} -mindepth 2 -maxdepth 2 -ctime +$n -exec rm -fr '{}' \; |
david_williams | e529817 | 2007-12-20 03:30:54 +0000 | [diff] [blame] | 36 | |
david_williams | eececc1 | 2007-12-20 04:36:02 +0000 | [diff] [blame] | 37 | after=`find ${artifactsDir} -mindepth 2 -maxdepth 2 | wc -l`; |
| 38 | echo " number of directories after cleaning: ${after}"; |
| 39 | echo; |