tor

The Tor anonymity network
git clone https://git.dasho.dev/tor.git
Log | Files | Refs | README | LICENSE

asciidoc-helper.sh (2154B)


      1 #!/bin/sh
      2 
      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
      8 
      9 set -e
     10 
     11 if [ $# != 3 ]; then
     12    exit 1
     13 fi
     14 
     15 if [ -z "$SOURCE_DATE_EPOCH" ]; then
     16    SOURCE_DATE_EPOCH="$(git -C "$(dirname "$0")" show --no-patch --format='%ct')"
     17    export SOURCE_DATE_EPOCH
     18 fi
     19 
     20 output=$3
     21 
     22 if [ "$1" = "html" ]; then
     23    input=${output%%.html.in}.1.txt
     24    base=${output%%.html.in}
     25 
     26    if [ "$2" != none ]; then
     27        TZ=UTC "$2" -f "$(dirname "$0")/nofooter.conf" -d manpage -o "$output" "$input";
     28    else
     29        echo "=================================="
     30        echo
     31        echo "You need asciidoc installed to be able to build the manpage."
     32        echo "To build without manpages, use the --disable-asciidoc argument"
     33        echo "when calling configure."
     34        echo
     35        echo "=================================="
     36        exit 1
     37    fi
     38 elif [ "$1" = "man" ]; then
     39    input=${output%%.1.in}.1.txt
     40    base=${output%%.1.in}
     41 
     42    if test "$2" = none; then
     43        echo "=================================="
     44        echo
     45        echo "You need asciidoc installed to be able to build the manpage."
     46        echo "To build without manpages, use the --disable-asciidoc argument"
     47        echo "when calling configure."
     48        echo
     49        echo "=================================="
     50        exit 1
     51    fi
     52    if "$2" -f manpage "$input"; then
     53        mv "$base.1" "$output"
     54    else
     55        cat<<EOF
     56 ==================================
     57 You need a working asciidoc installed to be able to build the manpage.
     58 
     59 a2x is installed, but for some reason it isn't working.  Sometimes
     60 this happens because required docbook support files are missing.
     61 Please install docbook-xsl, docbook-xml, and xmlto (Debian) or
     62 similar.  If you use homebrew on Mac OS X, install the docbook formula
     63 and add "export XML_CATALOG_FILES=/usr/local/etc/xml/catalog" to your
     64 .bashrc file.
     65 
     66 Alternatively, to build without manpages, use the --disable-asciidoc
     67 argument when calling configure.
     68 ==================================
     69 EOF
     70        exit 1
     71    fi
     72 fi