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