Update debian/control file
[rrq/maintain_lilo.git] / debian / manpages / pod2manpage
1 #!/bin/sh
2 #
3 #       pod2manpage  -  convert pod file into manual page
4 #       
5 #       Copyright 2009-2014 Joachim Wiedorn <joodevel at joonet.de>
6 #       
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 of the License, or
10 #       (at your option) any later version.
11 #       
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.
16 #       
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., 51 Franklin Street, Fifth Floor, Boston,
20 #       MA 02110-1301, USA.
21
22 set -e
23
24 if ! test /usr/bin/pod2man; then
25         echo "$0: Programm pod2man not found on the system!"
26         echo "$0: Please install perl (>= 5.6.0) on your system."
27         exit 1
28 fi
29
30 if test -z "$1"; then
31         echo "Usage: $0 <manpage.pod>"
32         echo ""
33         echo "       The file manpage.pod needs a header with six lines:"
34         echo "       =for header"
35         echo "       manpage: <program name>"
36         echo "       section: <manpage section>"
37         echo "       title:   <title string>"
38         echo "       version: <version number>"
39         echo "       datum:   <modification date>"
40         echo ""
41         exit 0
42 fi
43
44 if ! test -e "$1"; then
45         echo "$0: File $1 not found - Abort!"
46         exit 1
47 fi
48
49 NAME=`echo "$1" | sed -e 's/\.pod$//g'`
50 if ! test -e "${NAME}.pod"; then
51         echo "$0: File $1 is not a podfile - Abort!"
52         exit 1
53 fi
54
55 # read file header
56 SUCH=manpage
57 manpage=$(head -n7 "$1" | grep $SUCH | sed -e "s/\.*${SUCH}\:\ *\(.*\)/\1/")
58 SUCH=section
59 section=$(head -n7 "$1" | grep $SUCH | sed -e "s/\.*${SUCH}\:\ *\(.*\)/\1/")
60 SUCH=title
61 title=$(head -n7 "$1" | grep $SUCH | sed -e "s/\.*${SUCH}\:\ *\(.*\)/\1/")
62 SUCH=version
63 version=$(head -n7 "$1" | grep $SUCH | sed -e "s/\.*${SUCH}\:\ *\(.*\)/\1/")
64 SUCH=datum
65 datum=$(head -n7 "$1" | grep $SUCH | sed -e "s/\.*${SUCH}\:\ *\(.*\)/\1/")
66
67 # check for utf8 encoding
68 mycoding=""
69 if [ `head -n20 $1 | grep ^=encoding | grep -c -i utf` -eq 1 ]; then
70         mycoding="--utf8"
71 fi
72
73 # convert pod to manpage
74 pod2man --section="$section" --center "$title" \
75         --release="$version" --date="$datum" ${mycoding} \
76         ${NAME}.pod  ${NAME}.${section}
77
78 #man ./${NAME}.${section}
79 echo "Manpage ${NAME}.${section} created."
80