John R. Sheets | d9e064f | 2000-12-13 21:52:37 +0000 | [diff] [blame] | 1 | #! /bin/sh |
| 2 | |
| 3 | ## Customized version of db2html to make it easier to use alternate |
| 4 | ## stylesheets. Some versions of db2html support a '-d' option to |
| 5 | ## specify this, but not all. We'll explicitly specify that here. |
| 6 | ## |
| 7 | ## John R. Sheets <jsheets@codeweavers.com> |
| 8 | |
John R. Sheets | 6a2824e | 2001-01-18 23:07:53 +0000 | [diff] [blame] | 9 | ## The DocBook installations behave differently for the various Linux |
| 10 | ## distributions. Try to make some sense out of it all.... |
| 11 | ## |
| 12 | ## $LINUXDIST holds the name of the distribution |
| 13 | ## $JADETAG adds "/#html" to the stylesheet-specification in the Jade |
| 14 | ## command line (see comments below), if necessary for that dist. |
| 15 | if [ -a /etc/debian_version ]; then |
| 16 | LINUXDIST="Debian" |
| 17 | JADETAG=\#html |
| 18 | fi |
| 19 | |
| 20 | if [ -a /etc/redhat_release ]; then |
| 21 | LINUXDIST="Redhat" |
| 22 | JADETAG= |
| 23 | fi |
| 24 | |
| 25 | ## FIXME: Add more distributions here... |
| 26 | |
| 27 | if [ -n "$LINUXDIST" ]; then |
| 28 | echo "Using db2html parameters for a $LINUXDIST Linux distribution..." |
| 29 | fi |
John R. Sheets | d9e064f | 2000-12-13 21:52:37 +0000 | [diff] [blame] | 30 | |
| 31 | ## Use included default.dsl DSSSL stylesheet unless explicitly overridden with |
| 32 | ## the $WINEDOC_STYLESHEET envar. |
| 33 | ## |
| 34 | ## NOTE: The invoked DSSSL stylesheet *MUST* have an HTML-specific section |
| 35 | ## in it; otherwise, jade will spew everything to stdout and fail to use |
| 36 | ## the stated stylesheet. Something like this: |
| 37 | ## |
| 38 | ## <style-specification id="html" use="docbook"> |
| 39 | if [ -z "$WINEDOC_STYLESHEET" ]; then |
| 40 | DB_STYLESHEET=../default.dsl |
| 41 | else |
| 42 | DB_STYLESHEET=$WINEDOC_STYLESHEET |
| 43 | fi |
| 44 | |
| 45 | output=db2html-dir |
| 46 | TMPDIR=DBTOHTML_OUTPUT_DIR$$ |
| 47 | |
| 48 | echo TMPDIR is $TMPDIR |
| 49 | |
| 50 | echo "Using stylesheet: \"${DB_STYLESHEET}\"" |
| 51 | |
| 52 | if [ $# -gt 2 ] |
| 53 | then |
| 54 | echo "Usage: `basename $0` [filename.sgml]" >&2 |
| 55 | exit 1 |
| 56 | fi |
| 57 | |
| 58 | if [ $# -eq 1 ] |
| 59 | then |
| 60 | if [ ! -r $1 ] |
| 61 | then |
| 62 | echo Cannot read \"$1\". Exiting. >&2 |
| 63 | exit 1 |
| 64 | fi |
| 65 | if echo $1 | egrep -i '\.sgml$|\.sgm$' >/dev/null 2>&1 |
| 66 | then |
| 67 | # now make sure that the output directory is always a subdirectory |
| 68 | # of the current directory |
John R. Sheets | d9e064f | 2000-12-13 21:52:37 +0000 | [diff] [blame] | 69 | input_file=`basename $1` |
| 70 | output="`echo $input_file | sed 's,\.sgml$,,;s,\.sgm$,,'`" |
| 71 | echo "input file was called $input_file -- output will be in $output" |
| 72 | echo |
| 73 | fi |
| 74 | fi |
| 75 | |
| 76 | mkdir $TMPDIR |
| 77 | SAVE_PWD=`pwd` |
| 78 | if [ $1 = `basename $1` ]; then |
John R. Sheets | 6a2824e | 2001-01-18 23:07:53 +0000 | [diff] [blame] | 79 | EXTRA_PATH=../ |
John R. Sheets | d9e064f | 2000-12-13 21:52:37 +0000 | [diff] [blame] | 80 | else |
John R. Sheets | 6a2824e | 2001-01-18 23:07:53 +0000 | [diff] [blame] | 81 | EXTRA_PATH= |
John R. Sheets | d9e064f | 2000-12-13 21:52:37 +0000 | [diff] [blame] | 82 | fi |
| 83 | |
John R. Sheets | 6a2824e | 2001-01-18 23:07:53 +0000 | [diff] [blame] | 84 | JADE_CMD="jade -t sgml -ihtml -d ${DB_STYLESHEET}${JADETAG} ${EXTRA_PATH}$1" |
| 85 | echo "Invoking command '$JADE_CMD'" |
| 86 | echo |
| 87 | |
| 88 | echo "working on ${EXTRA_PATH}$1" |
| 89 | (cd $TMPDIR; $JADE_CMD; cd $SAVE_PWD) |
| 90 | |
John R. Sheets | d9e064f | 2000-12-13 21:52:37 +0000 | [diff] [blame] | 91 | if [ $# -eq 1 ] |
| 92 | then |
| 93 | if [ -d ${output}.junk ] |
| 94 | then |
| 95 | /bin/rm -rf ${output}.junk |
| 96 | fi |
| 97 | if [ -d ${output} ] |
| 98 | then |
| 99 | mv $output ${output}.junk |
| 100 | fi |
| 101 | echo "about to rename temporary directory to $output" |
| 102 | mv ${TMPDIR} $output |
| 103 | else |
| 104 | cat $TMPDIR/* |
| 105 | fi |
| 106 | |
| 107 | rm -rf $TMPDIR |
| 108 | |
| 109 | exit 0 |