Imported Debian patch 0.2-1~karmic
[pysam.git] / debian / pysam.prerm.debhelper
1 # Automatically added by dh_pycentral
2 case "$1" in remove|upgrade)
3         pkgremove=y
4 esac
5 if [ -f /var/lib/pycentral/pysam.pkgremove ] || [ -f /var/lib/pycentral/pkgremove ]; then
6         pkgremove=y
7 fi
8 if [ "$pkgremove" = y ]; then
9 if which python >/dev/null 2>&1 && which pycentral >/dev/null 2>&1; then
10         pycentral pkgremove pysam
11 else
12         flist=$(tempfile)
13         slist=$(tempfile)
14         dpkg -L pysam | tee $flist | \
15         while read n; do
16           case "$n" in
17             /usr/share/pyshared/*)
18               n2=${n#/usr/share/pyshared/*}
19               case "$n" in
20                 *.py) echo "p $n";;
21                 *) [ -d "$n" ] && echo "d $n2" || echo "f $n2"
22               esac
23               ;;
24             *) continue
25           esac
26         done > $slist
27         if [ -s $slist ]; then
28             for d in /usr/lib/python[0-9].[0-9]/????-packages; do
29                 case "$d" in */python2.1/*|*/python2.2/*) continue; esac
30                 while read t n; do
31                     case "$t" in
32                         p) rm -f $d/$n $d/${n}[co];;
33                         d) rmdir $d/$n 2>/dev/null || true;;
34                         *) rm -f $d/$n
35                     esac
36                 done < $slist
37             done
38         fi
39         awk '/\/usr\/share\/pyshared/ {next} /\.py$/ {print $0"c\n" $0"o"}' $flist \
40             | xargs -r rm -f >&2
41         rm -f $flist $slist
42 fi
43 rm -f /var/lib/pycentral/pysam.pkgremove
44 fi
45 # End automatically added section