#!/bin/sh
# postinst for doc-base

# Abort if any command returns an error value
set -e

package=doc-base

if [ "$DEBUG" ]; then
    echo entering $package postinst
    set -x
fi

compat_symlink ( ) {
    if [ -d /usr/doc ]; then
	if [ ! -e /usr/doc/$package -a -d /usr/share/doc/$package ]; then
	    ln -s ../share/doc/$package /usr/doc/$package
	fi
    fi
}

case "$1" in
  configure)
    compat_symlink
    ##
    # install all the existing doc-base control files;
    # this seems a little wasteful, instead of running the more minimal
    #     install-docs -i /usr/share/$package/$package
    #     install-docs -i /usr/share/$package/install-docs-man
    # but what the hell -- we could only do this is version last configure is < 0.7.9
    ##
    num=`ls -1 /usr/share/$package/* | wc -l`
    echo "registering $num documents from /usr/share/$package ..."
    for file in /usr/share/$package/*; do
        install-docs -i $file || true  # don't abort on failure
    done
    ;;
  install)
    compat_symlink
    ;;
esac

exit 0
