3 # debman - read a man page from an uninstalled Debian package file (.deb)
5 # Copyright (C) 2003 Colin Watson <cjwatson@debian.org>
7 # This program is free software; you can redistribute it and/or modify
8 # it under the terms of the GNU General Public License as published by
9 # the Free Software Foundation; either version 2, or (at your option)
12 # This program is distributed in the hope that it will be useful,
13 # but WITHOUT ANY WARRANTY; without even the implied warranty of
14 # MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the
15 # GNU General Public License for more details.
17 # You should have received a copy of the GNU General Public License
18 # along with this program; if not, write to the Free Software
19 # Foundation, Inc., 59 Temple Place - Suite 330, Boston, MA
22 USAGE='Usage: debman <package.deb> [man options] <man page name> ...'
31 if test $# -lt 2; then
36 # Directory names are duplicated with and without ./ in order to cope with
37 # old .debs whose data.tar.gz components had a slightly different format.
38 MANDIRS='usr/share/man usr/X11R6/man ./usr/share/man ./usr/X11R6/man'
40 TEMPDIR=`mktemp -dt debman.XXXXXXXXXX`
41 trap 'rm -rf "$TEMPDIR"' EXIT ERR HUP INT QUIT TERM
43 # Ignore errors from tar (though not dpkg). They'll generally just be of the
44 # form "tar: usr/share/man: Not found in archive". If they're something
45 # else, then man will fail to find the page anyway.
47 dpkg --fsys-tarfile "$1" | \
48 (tar -C "$TEMPDIR" -xf - $MANDIRS 2>/dev/null || true)
51 MANPATH="$TEMPDIR/usr/share/man:$TEMPDIR/usr/X11R6/man" man "$@"