~ubuntu-branches/ubuntu/wily/duply/wily-proposed

1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
33
34
35
36
37
38
39
40
41
42
43
44
45
46
47
48
49
50
51
52
53
54
55
56
57
58
59
60
61
62
63
64
65
66
67
68
69
70
71
72
73
74
75
76
77
78
79
80
#!/bin/sh
#
#       pod2manpage  -  convert pod file into manual page
#       
#       Copyright 2009-2015 Joachim Wiedorn <joodebian at joonet.de>
#       
#       This program is free software; you can redistribute it and/or modify
#       it under the terms of the GNU General Public License as published by
#       the Free Software Foundation; either version 2 of the License, or
#       (at your option) any later version.
#       
#       This program is distributed in the hope that it will be useful,
#       but WITHOUT ANY WARRANTY; without even the implied warranty of
#       MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE.  See the
#       GNU General Public License for more details.
#       
#       You should have received a copy of the GNU General Public License
#       along with this program; if not, write to the Free Software
#       Foundation, Inc., 51 Franklin Street, Fifth Floor, Boston,
#       MA 02110-1301, USA.

set -e

if ! test /usr/bin/pod2man; then
	echo "$0: Programm pod2man not found on the system!"
	echo "$0: Please install perl (>= 5.6.0) on your system."
	exit 1
fi

if test -z "$1"; then
	echo "Usage: $0 <manpage.pod>"
	echo ""
	echo "       The file manpage.pod needs a header with six lines:"
	echo "       =for header"
	echo "       manpage: <program name>"
	echo "       section: <manpage section>"
	echo "       title:   <title string>"
	echo "       version: <version number>"
	echo "       datum:   <modification date>"
	echo ""
	exit 0
fi

if ! test -e "$1"; then
	echo "$0: File $1 not found - Abort!"
	exit 1
fi

NAME=`echo "$1" | sed -e 's/\.pod$//g'`
if ! test -e "${NAME}.pod"; then
	echo "$0: File $1 is not a podfile - Abort!"
	exit 1
fi

# read file header
SUCH=manpage
manpage=$(head -n7 "$1" | grep $SUCH | sed -e "s/\.*${SUCH}\:\ *\(.*\)/\1/")
SUCH=section
section=$(head -n7 "$1" | grep $SUCH | sed -e "s/\.*${SUCH}\:\ *\(.*\)/\1/")
SUCH=title
title=$(head -n7 "$1" | grep $SUCH | sed -e "s/\.*${SUCH}\:\ *\(.*\)/\1/")
SUCH=version
version=$(head -n7 "$1" | grep $SUCH | sed -e "s/\.*${SUCH}\:\ *\(.*\)/\1/")
SUCH=datum
datum=$(head -n7 "$1" | grep $SUCH | sed -e "s/\.*${SUCH}\:\ *\(.*\)/\1/")

# check for utf8 encoding
mycoding=""
if [ `head -n20 $1 | grep ^=encoding | grep -c -i utf` -eq 1 ]; then
	mycoding="--utf8"
fi

# convert pod to manpage
pod2man --section="$section" --center "$title" \
	--release="$version" --date="$datum" ${mycoding} \
	${NAME}.pod  ${NAME}.${section}

#man ./${NAME}.${section}
echo "Manpage ${NAME}.${section} created."