blob: 7261888faa065c27a3458a75655fe55debbd0482 [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.
Philipp Wollermann519d4862002-02-26 00:35:05 +000015
16LINUXDIST="Generic"
17JADEPROG="jade"
18JADETAG=
19
Francois Gouget42dcd972002-01-29 17:52:28 +000020if [ -f /etc/debian_version ]; then
John R. Sheets6a2824e2001-01-18 23:07:53 +000021 LINUXDIST="Debian"
Philipp Wollermann519d4862002-02-26 00:35:05 +000022 JADEPROG="jade"
John R. Sheets6a2824e2001-01-18 23:07:53 +000023 JADETAG=\#html
24fi
25
Francois Gouget42dcd972002-01-29 17:52:28 +000026if [ -f /etc/redhat_release ]; then
John R. Sheets6a2824e2001-01-18 23:07:53 +000027 LINUXDIST="Redhat"
Philipp Wollermann519d4862002-02-26 00:35:05 +000028 JADEPROG="jade"
John R. Sheets6a2824e2001-01-18 23:07:53 +000029 JADETAG=
30fi
31
Philipp Wollermann519d4862002-02-26 00:35:05 +000032if [ -f /usr/bin/crux ]; then
33 LINUXDIST="Crux"
34 JADEPROG="openjade"
35 JADETAG=
36fi
37
John R. Sheets6a2824e2001-01-18 23:07:53 +000038## FIXME: Add more distributions here...
39
40if [ -n "$LINUXDIST" ]; then
41 echo "Using db2html parameters for a $LINUXDIST Linux distribution..."
42fi
John R. Sheetsd9e064f2000-12-13 21:52:37 +000043
44## Use included default.dsl DSSSL stylesheet unless explicitly overridden with
45## the $WINEDOC_STYLESHEET envar.
46##
47## NOTE: The invoked DSSSL stylesheet *MUST* have an HTML-specific section
48## in it; otherwise, jade will spew everything to stdout and fail to use
49## the stated stylesheet. Something like this:
50##
51## <style-specification id="html" use="docbook">
52if [ -z "$WINEDOC_STYLESHEET" ]; then
53 DB_STYLESHEET=../default.dsl
54else
55 DB_STYLESHEET=$WINEDOC_STYLESHEET
56fi
57
58output=db2html-dir
59TMPDIR=DBTOHTML_OUTPUT_DIR$$
60
61echo TMPDIR is $TMPDIR
62
63echo "Using stylesheet: \"${DB_STYLESHEET}\""
64
65if [ $# -gt 2 ]
66then
67 echo "Usage: `basename $0` [filename.sgml]" >&2
68 exit 1
69fi
70
71if [ $# -eq 1 ]
72then
73 if [ ! -r $1 ]
74 then
75 echo Cannot read \"$1\". Exiting. >&2
76 exit 1
77 fi
78 if echo $1 | egrep -i '\.sgml$|\.sgm$' >/dev/null 2>&1
79 then
80 # now make sure that the output directory is always a subdirectory
81 # of the current directory
John R. Sheetsd9e064f2000-12-13 21:52:37 +000082 input_file=`basename $1`
83 output="`echo $input_file | sed 's,\.sgml$,,;s,\.sgm$,,'`"
84 echo "input file was called $input_file -- output will be in $output"
85 echo
86 fi
87fi
88
89mkdir $TMPDIR
90SAVE_PWD=`pwd`
91if [ $1 = `basename $1` ]; then
John R. Sheets6a2824e2001-01-18 23:07:53 +000092 EXTRA_PATH=../
John R. Sheetsd9e064f2000-12-13 21:52:37 +000093else
John R. Sheets6a2824e2001-01-18 23:07:53 +000094 EXTRA_PATH=
John R. Sheetsd9e064f2000-12-13 21:52:37 +000095fi
96
Philipp Wollermann519d4862002-02-26 00:35:05 +000097JADE_CMD="$JADEPROG -t sgml -ihtml -d ${DB_STYLESHEET}${JADETAG} ${EXTRA_PATH}$1"
John R. Sheets6a2824e2001-01-18 23:07:53 +000098echo "Invoking command '$JADE_CMD'"
99echo
100
101echo "working on ${EXTRA_PATH}$1"
102(cd $TMPDIR; $JADE_CMD; cd $SAVE_PWD)
103
John R. Sheetsd9e064f2000-12-13 21:52:37 +0000104if [ $# -eq 1 ]
105then
Andreas Mohr8c2e5732001-11-25 00:51:36 +0000106 if [ -d "${output}.junk" ]
John R. Sheetsd9e064f2000-12-13 21:52:37 +0000107 then
Andreas Mohr8c2e5732001-11-25 00:51:36 +0000108 /bin/rm -rf "${output}.junk"
John R. Sheetsd9e064f2000-12-13 21:52:37 +0000109 fi
Andreas Mohr8c2e5732001-11-25 00:51:36 +0000110 if [ -d "${output}" ]
John R. Sheetsd9e064f2000-12-13 21:52:37 +0000111 then
Andreas Mohr8c2e5732001-11-25 00:51:36 +0000112 mv "$output" "${output}.junk"
John R. Sheetsd9e064f2000-12-13 21:52:37 +0000113 fi
114 echo "about to rename temporary directory to $output"
Andreas Mohr8c2e5732001-11-25 00:51:36 +0000115 mv "${TMPDIR}" "$output"
John R. Sheetsd9e064f2000-12-13 21:52:37 +0000116else
Andreas Mohr8c2e5732001-11-25 00:51:36 +0000117 cat "$TMPDIR"/*
John R. Sheetsd9e064f2000-12-13 21:52:37 +0000118fi
119
Andreas Mohr8c2e5732001-11-25 00:51:36 +0000120rm -rf "$TMPDIR"
John R. Sheetsd9e064f2000-12-13 21:52:37 +0000121
122exit 0