blob: 8d2e681e948fd3fc8216ae688b4c32a6baec8cc7 [file] [log] [blame]
John R. Sheetsd9e064f2000-12-13 21:52:37 +00001#! /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. Sheets6a2824e2001-01-18 23:07:53 +00009## 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.
15if [ -a /etc/debian_version ]; then
16 LINUXDIST="Debian"
17 JADETAG=\#html
18fi
19
20if [ -a /etc/redhat_release ]; then
21 LINUXDIST="Redhat"
22 JADETAG=
23fi
24
25## FIXME: Add more distributions here...
26
27if [ -n "$LINUXDIST" ]; then
28 echo "Using db2html parameters for a $LINUXDIST Linux distribution..."
29fi
John R. Sheetsd9e064f2000-12-13 21:52:37 +000030
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">
39if [ -z "$WINEDOC_STYLESHEET" ]; then
40 DB_STYLESHEET=../default.dsl
41else
42 DB_STYLESHEET=$WINEDOC_STYLESHEET
43fi
44
45output=db2html-dir
46TMPDIR=DBTOHTML_OUTPUT_DIR$$
47
48echo TMPDIR is $TMPDIR
49
50echo "Using stylesheet: \"${DB_STYLESHEET}\""
51
52if [ $# -gt 2 ]
53then
54 echo "Usage: `basename $0` [filename.sgml]" >&2
55 exit 1
56fi
57
58if [ $# -eq 1 ]
59then
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. Sheetsd9e064f2000-12-13 21:52:37 +000069 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
74fi
75
76mkdir $TMPDIR
77SAVE_PWD=`pwd`
78if [ $1 = `basename $1` ]; then
John R. Sheets6a2824e2001-01-18 23:07:53 +000079 EXTRA_PATH=../
John R. Sheetsd9e064f2000-12-13 21:52:37 +000080else
John R. Sheets6a2824e2001-01-18 23:07:53 +000081 EXTRA_PATH=
John R. Sheetsd9e064f2000-12-13 21:52:37 +000082fi
83
John R. Sheets6a2824e2001-01-18 23:07:53 +000084JADE_CMD="jade -t sgml -ihtml -d ${DB_STYLESHEET}${JADETAG} ${EXTRA_PATH}$1"
85echo "Invoking command '$JADE_CMD'"
86echo
87
88echo "working on ${EXTRA_PATH}$1"
89(cd $TMPDIR; $JADE_CMD; cd $SAVE_PWD)
90
John R. Sheetsd9e064f2000-12-13 21:52:37 +000091if [ $# -eq 1 ]
92then
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
103else
104 cat $TMPDIR/*
105fi
106
107rm -rf $TMPDIR
108
109exit 0