summaryrefslogtreecommitdiff
path: root/debian/postinst
blob: 758f43241770b6ef627ded519f2de5599e12dc10 (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
#!/bin/sh -e 
#
# Copyright 2001,2002 by Stefan Hornburg (Racke) <racke@linuxia.de>
#
# 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.

# create /var/lib/dhelp if necessary
if [ ! -d /var/lib/dhelp ]; then
    mkdir /var/lib/dhelp
fi

# remove /usr/doc/HTML2 if upgrading from old dhelp package
if [ "$1" = configure -a -d /usr/doc/HTML2 ]; then
    rm -rf /usr/doc/HTML2
fi

# remove old /var/lib/dhelp/swish++.index (versions older than 0.6)
rm -f /var/lib/dhelp/swish++.index

# hack to be able to tell if the package is configured, so 3rd party packages
# that call dhelp don't barf (from scrollkeeper package)
touch /var/lib/dhelp/configured

DHELP_INDEXER=/usr/share/dhelp/scripts/index-deferred
DHELP_APTHOOK=/etc/apt/apt.conf.d/35dhelp

# create and register with ucf our dpkg post-invoke hook

DHELP_POSTCMD="\"if test -x ${DHELP_INDEXER}; then ${DHELP_INDEXER}; fi\""
DHELP_TMP_APTHOOK=`mktemp 2>/dev/null`
if [ $? -ne 0 ]; then
    >&2 echo "Error: unable to create temporary file"
    exit 1
fi
if ! chmod 644 ${DHELP_TMP_APTHOOK}; then
    >&2 echo "Error: unable to change mode of temporary file"
    exit 2
fi
echo "Dpkg::Post-Invoke { ${DHELP_POSTCMD}; };" > ${DHELP_TMP_APTHOOK}

ucf --debconf-ok --three-way ${DHELP_TMP_APTHOOK} ${DHELP_APTHOOK}
rm -f ${DHELP_TMP_APTHOOK}
ucfr dhelp ${DHELP_APTHOOK}

# create /var/www/doc if necessary
if [ ! -d /var/www/doc ]; then
    mkdir /var/www/doc
fi

# 'dhelp_parse -r', among other actions, produces the pending list.
echo -n "Building HTML tree..."
dhelp_parse -r
echo " done."

# symlink /usr/share/doc/{dhelp,HTML} from /var/www/doc
ln -s /usr/share/doc/dhelp /var/www/doc/dhelp
ln -s /usr/share/doc/HTML /var/www/doc/HTML

# Thus, if index file does not exist, it suffices to do incremental indexing.
if [ ! -f /var/lib/dhelp/documents.index ]; then
    echo "Reindexing documentation in the background"
    if [ -x ${DHELP_INDEXER} ]; then
        ${DHELP_INDEXER}
    else
        >&2 echo "Error: ${DHELP_INDEXER} does not exist or is not executable"
        exit 3
    fi
fi

unset DHELP_INDEXER DHELP_POSTCMD DHELP_APTHOOK DHELP_TMP_APTHOOK || true

#DEBHELPER#