3 # Copyright (C) 2010 Red Hat Inc.
6 # This program is free software; you can redistribute it and/or modify
7 # it under the terms of the GNU General Public License as published by
8 # the Free Software Foundation; either version 2 of the License, or
9 # (at your option) any later version.
11 # This program is distributed in the hope that it will be useful,
12 # but WITHOUT ANY WARRANTY; without even the implied warranty of
13 # MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the
14 # GNU General Public License for more details.
16 # You should have received a copy of the GNU General Public License
17 # along with this program; if not, write to the Free Software
18 # Foundation, Inc., 675 Mass Ave, Cambridge, MA 02139, USA.
20 # Wrapper script around POD utilities which can include files in the
21 # POD and controls HTML generation.
28 PACKAGE_NAME="@PACKAGE_NAME@"
29 PACKAGE_VERSION="@PACKAGE_VERSION@"
41 --long section:,name:,man:,text:,html:,insert:,verbatim: \
42 -n podwrapper.sh -- "$@"`
44 echo "podwrapper.sh: problem parsing the command line arguments"
58 [ -z "$man_output" ] || {
59 echo "podwrapper.sh: --text option specified more than once"
65 [ -z "$text_output" ] || {
66 echo "podwrapper.sh: --text option specified more than once"
72 [ -z "$html_output" ] || {
73 echo "podwrapper.sh: --html option specified more than once"
79 inserts[$nr_inserts]=`echo "$2" | awk -F: '{print $1}'`
80 pattern[$nr_inserts]=`echo "$2" | awk -F: '{print $2}'`
81 indent[$nr_inserts]=no
85 inserts[$nr_inserts]=`echo "$2" | awk -F: '{print $1}'`
86 pattern[$nr_inserts]=`echo "$2" | awk -F: '{print $2}'`
87 indent[$nr_inserts]=yes
93 echo "podwrapper.sh: internal error in option parsing"
98 # The remaining argument is the input POD file.
100 echo "podwrapper.sh [--options] input.pod"
106 #echo "man_output=$man_output"
107 #echo "text_output=$text_output"
108 #echo "html_output=$html_output"
109 #for i in `seq 0 $(($nr_inserts-1))`; do
110 # echo "insert $i: ${inserts[$i]} (pattern: ${pattern[$i]} indent: ${indent[$i]})"
113 # Should be at least one sort of output.
114 [ -z "$man_output" -a -z "$text_output" -a -z "$html_output" ] && {
115 echo "podwrapper.sh: no output specified"
119 # If name and section are not set, make some sensible defaults.
120 [ -z "$section" ] && section=1
121 [ -z "$name" ] && name=$(basename "$input" .pod)
123 # Perform the insertions to produce a temporary POD file.
124 tmpdir="$(mktemp -d)"
125 trap "rm -rf $tmpdir; exit $?" EXIT
127 if [ $nr_inserts -gt 0 ]; then
130 for i in `seq 0 $(($nr_inserts-1))`; do
131 if [ "${indent[$i]}" = "yes" ]; then
132 sed 's/^/ /' < "${inserts[$i]}" > $tmpdir/$i
134 cp "${inserts[$i]}" $tmpdir/$i
137 cmd="$cmd -e /${pattern[$i]}/r$tmpdir/$i -e s/${pattern[$i]}//"
140 $cmd < "$input" > $tmpdir/full.pod
142 cp "$input" $tmpdir/full.pod
145 # Now generate the final output format(s).
146 if [ -n "$man_output" ]; then
147 "$POD2MAN" --stderr -u \
148 --section "$section" -c "Virtualization Support" --name "$name" \
149 --release "$PACKAGE_NAME-$PACKAGE_VERSION" \
150 < $tmpdir/full.pod > "$man_output".tmp
151 mv "$man_output".tmp "$man_output"
154 if [ -n "$text_output" ]; then
155 "$POD2TEXT" --stderr -u \
156 < $tmpdir/full.pod > "$text_output".tmp
157 mv "$text_output".tmp "$text_output"
160 if [ -n "$html_output" ]; then
162 --css "pod.css" --htmldir "$builddir/html" \
163 < $tmpdir/full.pod > "$html_output".tmp
164 mv "$html_output".tmp "$html_output"