~ubuntu-branches/ubuntu/saucy/tipa/saucy

« back to all changes in this revision

Viewing changes to debian/tipa.preinst

  • Committer: Bazaar Package Importer
  • Author(s): Rafael Laboissiere
  • Date: 2008-03-19 01:41:02 UTC
  • mfrom: (2.1.8 hardy)
  • Revision ID: james.westby@ubuntu.com-20080319014102-kei8nmuiqm94khxx
Tags: 2:1.3-12
* debian/control: Append trunk to the Vcs-Svn URL
* tipa-doc.doc-base.tipa-{manual,typefaces,vowel}: Set Section to Text

Show diffs side-by-side

added added

removed removed

Lines of Context:
 
1
#!/bin/sh -e
 
2
 
 
3
# preinst script for the tipa package
 
4
# GNU Copyright (c) 2007  Rafael Labossiere
 
5
 
 
6
# Remove a no-longer used conffile
 
7
# (code taken from http://wiki.debian.org/DpkgConffileHandling)
 
8
rm_conffile() {
 
9
    PKGNAME="$1"
 
10
    CONFFILE="$2"
 
11
 
 
12
    if [ -e "$CONFFILE" ]; then
 
13
        md5sum="`md5sum \"$CONFFILE\" | sed -e \"s/ .*//\"`"
 
14
        old_md5sum="`dpkg-query -W -f='${Conffiles}' $PKGNAME | sed -n -e \"\\\\' $CONFFILE's/.* //p\"`"
 
15
        if [ "$md5sum" != "$old_md5sum" ]; then
 
16
            echo "Obsolete conffile $CONFFILE has been modified by you."
 
17
            echo "Saving as $CONFFILE.dpkg-bak ..."
 
18
            mv -f "$CONFFILE" "$CONFFILE".dpkg-bak
 
19
        else
 
20
            echo "Removing obsolete conffile $CONFFILE ..."
 
21
            rm -f "$CONFFILE"
 
22
        fi
 
23
    fi
 
24
}
 
25
 
 
26
#
 
27
# we have to move the map and dvips config file into /u/s/texmf
 
28
# but want to preserve changes done by the user!
 
29
#
 
30
dpkg_md5sum(){
 
31
  dpkg-query -f'${Conffiles}' --show tipa | grep $1 | cut -f 3 -d ' '
 
32
}
 
33
 
 
34
config_move ()
 
35
{
 
36
    oldfile=$1
 
37
    newloc=$2
 
38
    oldmd5sum=`dpkg_md5sum $oldfile`
 
39
 
 
40
    if ! [ -r $oldfile ] ; then
 
41
        return 0
 
42
    fi
 
43
    oldloc=`dirname $1`
 
44
    newmd5sum=`md5sum $oldfile |  cut -d ' ' -f 1`
 
45
    if [ "$newmd5sum" = "$oldmd5sum" ] ; then
 
46
        echo "Removing obsolete, unchanged conffile $oldfile"
 
47
        rm $oldfile
 
48
    else
 
49
        if [ "X$newloc" = "X" ] ; then
 
50
            echo "Conffile $oldfile was changed, leaving it at the same place"
 
51
        else
 
52
            echo "Conffile $oldfile was changed, moving it to new location $newloc"
 
53
            mkdir -p $newloc
 
54
            mv $oldfile $newloc
 
55
        fi
 
56
    fi
 
57
    test -d $oldloc && rmdir --ignore-fail-on-non-empty $oldloc || true
 
58
}
 
59
 
 
60
 
 
61
 
 
62
case "$1" in
 
63
    upgrade|install)
 
64
        set -e
 
65
        config_move /etc/texmf/dvips/tipa.map /etc/texmf/fonts/map/dvips
 
66
        if dpkg --compare-versions "$2" le 2:1.3-4 ; then
 
67
            rm_conffile tipa /etc/texmf/updmap.d/10tipa.cfg
 
68
        fi
 
69
    ;;
 
70
 
 
71
    abort-upgrade)
 
72
    ;;
 
73
 
 
74
    *)
 
75
        echo "preinst called with unknown argument \`$1'" >&2
 
76
        exit 1
 
77
    ;;
 
78
esac
 
79
 
 
80
 
 
81
#DEBHELPER#
 
82
 
 
83
exit 0