]> git.deb.at Git - pkg/blosxom.git/blob - debian/preinst
Added preinst script to cleanup flavour symlinks which aren't shipped anymore, remove...
[pkg/blosxom.git] / debian / preinst
1 #!/bin/sh -e
2 # preinst script for blosxom
3 # copyright 2007-2008 by Gerfried Fuchs <rhonda@debian.at>
4 # Licenced in the same way as blosxom itself
5
6 rm_conffile() {
7         PKGNAME="$1"
8         CONFFILE="$2"
9         if [ -e "$CONFFILE" ]; then
10                 md5sum="`md5sum \"$CONFFILE\" | sed -e \"s/ .*//\"`"
11                 old_md5sum="`dpkg-query -W -f='${Conffiles}' $PKGNAME | sed -n -e \"\\\\' $CONFFILE '{s/ obsolete$//;s/.* //p}\"`"
12                 if [ "$md5sum" != "$old_md5sum" ]; then
13                         echo "Obsolete conffile $CONFFILE has been modified by you."
14                         echo "Saving as $CONFFILE.dpkg-bak ..."
15                         mv -f "$CONFFILE" "$CONFFILE".dpkg-bak
16                 else
17                         echo "Removing obsolete conffile $CONFFILE ..."
18                         rm -f "$CONFFILE"
19                 fi
20         fi
21 }
22
23
24 # cleanup for old flavors that got installed by packages prior to 2.1.0
25 case "$1" in
26 install|upgrade)
27         if dpkg --compare-versions "$2" le-nl "2.1.0-1"; then
28                 for i in content_type.1993 content_type.html content_type.index \
29                         date.1993  date.html  date.index \
30                         foot.1993  foot.html  foot.index \
31                         head.1993  head.html  head.index \
32                         story.1993 story.html story.index ; do
33                         rm_conffile blosxom "/etc/blosxom/flavours/$i"
34                 done
35         fi
36         if [ -d /var/lib/blosxom/data/flavours ] ; then
37                 cd /var/lib/blosxom/data/flavours
38                 for i in content_type.1993 content_type.html content_type.index \
39                         date.1993  date.html  date.index \
40                         foot.1993  foot.html  foot.index \
41                         head.1993  head.html  head.index \
42                         story.1993 story.html story.index ; do
43                         test ! -L $i || test ! -f $i || rm $i
44                 done
45         fi
46 esac
47
48 exit 0