test: Fix a mem leak reported by Coverity
[tor.git] / doc / asciidoc-helper.sh
bloba3e2f8f9bf29f22eeb1588a4caa2b2746cbeb1e6
1 #!/bin/sh
3 # Copyright (c) The Tor Project, Inc.
4 # See LICENSE for licensing information
5 # Run this to generate .html.in or .1.in files from asciidoc files.
6 # Arguments:
7 # html|man asciidocpath outputfile
9 set -e
11 if [ $# != 3 ]; then
12 exit 1
15 SOURCE_DATE_EPOCH="$(git -C "$(dirname "$0")" show --no-patch --format='%ct')"
16 export SOURCE_DATE_EPOCH
18 output=$3
20 if [ "$1" = "html" ]; then
21 input=${output%%.html.in}.1.txt
22 base=${output%%.html.in}
24 if [ "$2" != none ]; then
25 TZ=UTC "$2" -f "$(dirname "$0")/nofooter.conf" -d manpage -o "$output" "$input";
26 else
27 echo "=================================="
28 echo
29 echo "You need asciidoc installed to be able to build the manpage."
30 echo "To build without manpages, use the --disable-asciidoc argument"
31 echo "when calling configure."
32 echo
33 echo "=================================="
34 exit 1
36 elif [ "$1" = "man" ]; then
37 input=${output%%.1.in}.1.txt
38 base=${output%%.1.in}
40 if test "$2" = none; then
41 echo "=================================="
42 echo
43 echo "You need asciidoc installed to be able to build the manpage."
44 echo "To build without manpages, use the --disable-asciidoc argument"
45 echo "when calling configure."
46 echo
47 echo "=================================="
48 exit 1
50 if "$2" -f manpage "$input"; then
51 mv "$base.1" "$output"
52 else
53 cat<<EOF
54 ==================================
55 You need a working asciidoc installed to be able to build the manpage.
57 a2x is installed, but for some reason it isn't working. Sometimes
58 this happens because required docbook support files are missing.
59 Please install docbook-xsl, docbook-xml, and xmlto (Debian) or
60 similar. If you use homebrew on Mac OS X, install the docbook formula
61 and add "export XML_CATALOG_FILES=/usr/local/etc/xml/catalog" to your
62 .bashrc file.
64 Alternatively, to build without manpages, use the --disable-asciidoc
65 argument when calling configure.
66 ==================================
67 EOF
68 exit 1