summaryrefslogtreecommitdiffstats
path: root/contrib/mock-cleanup
blob: bf31f30446effca21568b504d3ab441211702891 (plain)
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
#! /bin/sh
#
# mock-cleanup
#
# clean packages in mock's cache directories
#

NEWCACHEDIR=/var/cache/mock
OLDCACHEDIR=/var/lib/mock/cache

dirs=
for d in $NEWCACHEDIR $OLDCACHEDIR
do
    if [ -d $d -a ! -z "$d/*/yum_cache" ]
    then
	dirs="$dirs $d/*/yum_cache"
    fi
done

for d in $dirs
do
    echo -n "Clean in $d:"
    cd $d
    for r in */packages
    do
	echo -n " `dirname $r`"
	repomanage --old --nocheck $r 2>/dev/null | xargs --no-run-if-empty rm
    done
    echo " done"
done