#!/bin/sh
#
# Prior versions of the "gcc" package would install a corrupted
# info entry for "chill", which would foil subsequent installations.
# This script attempts to clean up that entry.

if [ $# -ne 2 -o ! -d "${PKG_PREFIX}" -o ! -w "${PKG_PREFIX}/info/dir" ]
# Script was called improperly.
then
    exit 1
fi

if [ "$2" != "PRE-INSTALL" ]
# No problem
then
    exit 0
fi

if [ ! -x /bin/ed ]
# Who knows? Give up.
then
    exit 0
fi

echo Fixing up infodir from previous installation\.\.\.
/bin/ed "${PKG_PREFIX}/info/dir" 2> /dev/null << END
/^* Chill/d
w
q
END
if [ $? -eq 0 ]
then
    echo \.\.\.fixed\.
    exit 0
fi
echo \.\.\.nothing to fix\.
exit 0