Codebase list debian-goodies / b976263
add dman command from manpages.ubuntu.com this command can fetch manpages from an online site even if they are unavailable locally Antoine Beaupré 6 years ago
1 changed file(s) with 65 addition(s) and 0 deletion(s). Raw diff Collapse all Expand all
0 #!/bin/sh -e
1
2 ###############################################################################
3 # This is the Ubuntu manpage repository generator and interface.
4 #
5 # Copyright (C) 2008 Canonical Ltd.
6 #
7 # This code was originally written by Dustin Kirkland <kirkland@ubuntu.com>,
8 # based on a framework by Kees Cook <kees@ubuntu.com>.
9 #
10 # This program is free software: you can redistribute it and/or modify
11 # it under the terms of the GNU General Public License as published by
12 # the Free Software Foundation, either version 3 of the License, or
13 # (at your option) any later version.
14 #
15 # This program is distributed in the hope that it will be useful,
16 # but WITHOUT ANY WARRANTY; without even the implied warranty of
17 # MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the
18 # GNU General Public License for more details.
19 #
20 # You should have received a copy of the GNU General Public License
21 # along with this program. If not, see <http://www.gnu.org/licenses/>.
22 #
23 # On Debian-based systems, the complete text of the GNU General Public
24 # License can be found in /usr/share/common-licenses/GPL-3
25 ###############################################################################
26
27
28 . /etc/lsb-release
29 while true; do
30 case "$1" in
31 --release)
32 DISTRIB_CODENAME="$2"
33 shift 2
34 ;;
35 *)
36 break
37 ;;
38 esac
39 done
40 PAGE=`echo "$@" | awk '{print $NF}'`
41 MAN_ARGS=`echo "$@" | sed "s/\$PAGE$//"`
42
43 # Mirror support of man's languages
44 if [ ! -z "$LANG" ]; then
45 LOCALE="$LANG"
46 fi
47 if [ ! -z "$LC_MESSAGES" ]; then
48 LOCALE="$LC_MESSAGES"
49 fi
50 if echo $LOCALE | grep -q "^en"; then
51 LOCALE=""
52 fi
53
54 URL="http://manpages.ubuntu.com/manpages.gz/"
55
56 mandir=`mktemp -d dman.XXXXXX`
57 trap "rm -rf $mandir" EXIT HUP INT QUIT TERM
58 for i in `seq 1 9`; do
59 man="$mandir/$i"
60 if wget -O "$man" "$URL/$DISTRIB_CODENAME/$LOCALE/man$i/$PAGE.$i.gz" 2>/dev/null; then
61 man $MAN_ARGS -l "$man" || true
62 fi
63 rm -f "$man"
64 done