summaryrefslogtreecommitdiff
path: root/debian/prerm
blob: 4597b9f63ccf858e5285192057df7125dd2c0d54 (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
#
# Copyright (C) 2001,2002 Stefan Hornburg (Racke) <racke@linuxia.de>
# Copyright (C) 2011,2012 Georgios M. Zarkadas <gz@member.fsf.org>
#
# This program is free software; you can redistribute it and/or modify
# it under the terms of the GNU General Public License as published by
# the Free Software Foundation; either version 2 of the License, or
# (at your option) any later version.
#
# This program is distributed in the hope that it will be useful,
# but WITHOUT ANY WARRANTY; without even the implied warranty of
# MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE.  See the
# GNU General Public License for more details.
#
# You should have received a copy of the GNU General Public
# License along with this program; if not, write to the Free
# Software Foundation, Inc., 59 Temple Place, Suite 330, Boston,
# MA  02111-1307  USA.

set -e

#DEBHELPER#

#### Globals ####

#### Import Library ####

# If old version's prerm fails, our files (and thus the script library)
# will not be available. Thus, we need to treat this case specially.

case $1 in
failed-upgrade)
    ;;
*)
    for DHELP_LIBFILE in /usr/share/dhelp/maint-scripts/*.sh; do 
        if [ -f ${DHELP_LIBFILE} ]; then
            . ${DHELP_LIBFILE}
        else
            >&2 echo "Dhelp error: file ${DHELP_LIBFILE} was not found."
            >&2 echo "Please file a bug report at bugs.debian.org" \
                "against the dhelp package."
        fi
    done
    unset DHELP_LIBFILE || true
    ;;
esac

#### Functions ####

# Cleanup the files installed by the postinst.
#
do_removal_cleanup_actions ()
{
    # The directories themselves will be removed by dpkg;
    # cf. our debian/dirs entries.

    # Remove all cache data inside /var/lib/dhelp/tmp

    if [ -d /var/lib/dhelp/tmp ]; then
        rm --force /var/lib/dhelp/tmp/* || true
    fi

    # Remove all cache data inside /var/lib/dhelp
    # Hide the "rm: cannot remove `/var/lib/dhelp/tmp': Is a directory" error.

    if [ -d /var/lib/dhelp ]; then
        rm --force /var/lib/dhelp/* 2>&1 \
            | grep --invert-match '/var/lib/dhelp/tmp' || true
    fi

    # Remove html document index directory contents.

    if [ -d /usr/share/doc/HTML ]; then
        rm --force --recursive /usr/share/doc/HTML/*
    fi
}

#### Main script body ####

case $1 in
failed-upgrade)
    # Library is not available; confine ourselves to the bare essentials.

    do_removal_cleanup_actions
    ;;
*)
    # Disable our web server configuration snippets.

    try_chconf_apache2  "$1" disable dhelp || true
    try_chconf_lighttpd "$1" disable dhelp || true

    # Cleanup the files installed by the postinst.

    do_removal_cleanup_actions
    ;;
esac