]> git.pld-linux.org Git - projects/cleanbuild.git/blob - bin/cleanpoldekcache
Add verbosity to build output what script is doing
[projects/cleanbuild.git] / bin / cleanpoldekcache
1 #!/usr/bin/sudo /bin/sh
2
3 CACHEDIR="$PWD/poldekcache"
4
5 ignore() { }
6 [ -r .cleanbuildrc ] && . ./.cleanbuildrc
7
8 export LC_ALL=C
9 unset LANGUAGE
10 unset LANG
11
12 cd "$CACHEDIR" || exit 1
13 SIZE_IN=$(du -s . | sed 's/\t.*//')
14
15 cleandir()
16 {
17         DIR="$1"
18         /usr/bin/poldek --skip-installed -s "$DIR" --cachedir="$CACHEDIR" \
19                 --shcmd="ls" > cleanpoldekcache.pkgs
20         for PKG in $(ls $DIR); do
21                 case "$PKG" in
22                         dirindex.pndir.tndb* | packages.ndir.*)
23                                 ;;
24                         *)
25                                 if ! grep -q "${PKG%%.rpm}" cleanpoldekcache.pkgs; then
26                                         rm -v $DIR/$PKG
27                                 fi
28                                 ;;
29                 esac
30         done
31         rm cleanpoldekcache.pkgs
32 }
33
34 for FILE in *; do
35         case "$FILE" in
36                 ftp*.packages.i|http*.packages.i)
37                         echo "removing $FILE if empty"
38                         rmdir -v "$FILE"
39                         ;;
40                 ftp*|http*)
41                         echo "cleaning inside $FILE"
42                         cleandir "$FILE"
43                         ;;
44                 _* | tmpmd)
45                         echo "removing $FILE"
46                         rm -rv "$FILE"
47                         ;;
48                 *)
49                         echo "removing $FILE"
50                         rm -v "$FILE"
51                         ;;
52         esac
53 done
54
55 SIZE_OUT=$(du -s . | sed 's/\t.*//')
56 echo "Removed $(expr $SIZE_IN - $SIZE_OUT) kilobytes of data from poldek cache"
57
58 # vim: ts=4 sw=4 filetype=sh
This page took 0.046411 seconds and 3 git commands to generate.