summaryrefslogtreecommitdiffstats
path: root/debian/thunderbird.postinst
blob: 0ce76864978b9918950666b2a1d0b9f2b79a8aaa (plain)
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
33
34
35
36
37
38
39
40
41
42
43
44
45
46
47
48
49
50
51
52
53
54
55
56
57
58
59
60
61
62
63
64
65
66
67
68
69
70
71
72
73
74
75
76
77
78
79
80
81
82
83
84
85
86
87
88
89
90
91
92
93
94
95
96
97
98
#!/bin/sh
# postinst script for thunderbird
#
# see: dh_installdeb(1)

set -e
#set -x
# summary of how this script can be called:
#        * <postinst> `configure' <most-recently-configured-version>
#        * <old-postinst> `abort-upgrade' <new version>
#        * <conflictor's-postinst> `abort-remove' `in-favour' <package>
#          <new-version>
#        * <postinst> `abort-remove'
#        * <deconfigured's-postinst> `abort-deconfigure' `in-favour'
#          <failed-install-package> <version> `removing'
#          <conflicting-package> <version>
# for details, see http://www.debian.org/doc/debian-policy/ or
# the debian-policy package

ICEDOVE_PREF=/etc/icedove/pref
THUNDERBIRD_PREF=/etc/thunderbird/pref
THUNDERBIRD_LIBDIR=/usr/lib/thunderbird
TO_DELETE=0

case "$1" in
    configure)
        # The users might have put some additional files/dirs into the old
        # preferences folder '/etc/icedove/pref/', we need to move those files
        # into '/etc/thunderbird/pref/' so Thunderbird is picking up those
        # configurations as well.
        if [ -d ${ICEDOVE_PREF} ]; then
            # Check if we have to move files and/or directories.
            if [ `ls -a "${ICEDOVE_PREF}" | wc -l` -gt 2 ]; then
                # Yes, we found existing data to move!
                echo "Moving old Icedove related preferences files ..."
                mv ${ICEDOVE_PREF}/* /etc/thunderbird/pref/
                if [ "$?" != "0" ]; then
                    echo "Something went wrong while moving old Icedove preferences files!"
                    echo "Please validate files at '/etc/thunderbird/pref' !"
                else
                    # Moving files went fine, we can delete ${ICEDOVE_PREF}.
                    TO_DELETE=1
                fi
            else
                # There was nothing, marking folder ${ICEDOVE_PREF} for deleting.
                TO_DELETE=1
            fi
            if [ "${TO_DELETE}" -eq 1 ]; then
                # removing old empty folder /etc/icedove/profile if still existing (last used in squeeze)
                if [ -d /etc/icedove/profile ]; then
                    rmdir /etc/icedove/profile || true
                fi
                echo "Removing old Icedove pref directory ..."
                rmdir ${ICEDOVE_PREF} || true
                rmdir /etc/icedove || true
                rm -f ${THUNDERBIRD_PREF}/icedove.js.dpkg-remove || true
                if [ -f ${THUNDERBIRD_PREF}/icedove.js ]; then
                    # If dpkg-mainthelper-script wasn't faster and hasn't already removed icedove.js ...
                    if [ "`md5sum /etc/thunderbird/pref/icedove.js`" = "f7d035193281c76a304391fb07dfd590" ] || \
                       [ "`md5sum /etc/thunderbird/pref/icedove.js`" = "049566d25ab2630db3b705197b96f47e" ] ; then
                        # Remove the file icedove.js, it's the from previous installed Icedove package.
                        # f7d035193281c76a304391fb07dfd590 <= 1:45.3.0-1
                        # 049566d25ab2630db3b705197b96f47e == 1:45.5.1-1
                        rm ${THUNDERBIRD_PREF}/icedove.js || true
                    else
                        # We have a user modified file icedove.js.
                        mv ${THUNDERBIRD_PREF}/icedove.js ${THUNDERBIRD_PREF}/icedove.js.dpkg-backup || true
                    fi
                fi
            fi
        fi
        # Disable apparmor on new installations and when we're upgrading from
        # a version that had it enabled by default
        if test -n "$2" && dpkg --compare-versions "$2" gt "1:52.5.0-1~"; then
            :   # Leave the disable/ symlink at users choice if
                # upgrading from a version that ships the symlink
        else
            mkdir -p /etc/apparmor.d/disable
            [ -f /etc/apparmor.d/disable/usr.bin.thunderbird ] || ln -s /etc/apparmor.d/usr.bin.thunderbird  /etc/apparmor.d/disable/usr.bin.thunderbird
        fi
    ;;

    configure|abort-upgrade)
        touch ${THUNDERBID_LIBDIR}/.autoreg
    ;;

    *)
        echo "postinst called with unknown argument \`$1'" >&2
        exit 1
    ;;
esac

# dh_installdeb will replace this with shell code automatically
# generated by other debhelper scripts.

#DEBHELPER#

exit 0