#!/bin/sh

. ../common.sh

archive=$1
cmd=$2
sec=$3
pkg=$4

cd ..
set +e
dlpath=`grab_paths $pkg`
set -e
cd -

if [ -f "$dlpath" ]; then
    tmp=`tempfile`
    info "making $cmd($sec) ASCII man page from $dlpath"
    dpkg --fsys-tarfile ${dlpath} |
	tar -xOf - "*/man${sec}/${cmd}.${sec}.gz" | zcat > ${tmp}
    man -l ${tmp} | col -b
    rm -f ${tmp}
elif man -w $cmd > /dev/null; then
    info "making $cmd($sec) ASCII man page from local man page"
    man $sec $cmd | col -b
else
    warn "$cmd($sec) ASCII man page cannot be generated, stubbing"
    echo '** man page not found ** '
fi

exit 0
