Commit | Line | Data |
---|---|---|
d9e064fd JS |
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 | ||
6a2824ef JS |
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. | |
519d4864 PW |
15 | |
16 | LINUXDIST="Generic" | |
17 | JADEPROG="jade" | |
18 | JADETAG= | |
19 | ||
42dcd97e | 20 | if [ -f /etc/debian_version ]; then |
6a2824ef | 21 | LINUXDIST="Debian" |
519d4864 | 22 | JADEPROG="jade" |
6a2824ef JS |
23 | JADETAG=\#html |
24 | fi | |
25 | ||
42dcd97e | 26 | if [ -f /etc/redhat_release ]; then |
6a2824ef | 27 | LINUXDIST="Redhat" |
519d4864 | 28 | JADEPROG="jade" |
6a2824ef JS |
29 | JADETAG= |
30 | fi | |
31 | ||
519d4864 PW |
32 | if [ -f /usr/bin/crux ]; then |
33 | LINUXDIST="Crux" | |
34 | JADEPROG="openjade" | |
35 | JADETAG= | |
36 | fi | |
37 | ||
6a2824ef JS |
38 | ## FIXME: Add more distributions here... |
39 | ||
40 | if [ -n "$LINUXDIST" ]; then | |
41 | echo "Using db2html parameters for a $LINUXDIST Linux distribution..." | |
42 | fi | |
d9e064fd JS |
43 | |
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"> | |
52 | if [ -z "$WINEDOC_STYLESHEET" ]; then | |
53 | DB_STYLESHEET=../default.dsl | |
54 | else | |
55 | DB_STYLESHEET=$WINEDOC_STYLESHEET | |
56 | fi | |
57 | ||
58 | output=db2html-dir | |
59 | TMPDIR=DBTOHTML_OUTPUT_DIR$$ | |
60 | ||
61 | echo TMPDIR is $TMPDIR | |
62 | ||
63 | echo "Using stylesheet: \"${DB_STYLESHEET}\"" | |
64 | ||
65 | if [ $# -gt 2 ] | |
66 | then | |
67 | echo "Usage: `basename $0` [filename.sgml]" >&2 | |
68 | exit 1 | |
69 | fi | |
70 | ||
71 | if [ $# -eq 1 ] | |
72 | then | |
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 | |
d9e064fd JS |
82 | 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 | |
87 | fi | |
88 | ||
89 | mkdir $TMPDIR | |
90 | SAVE_PWD=`pwd` | |
91 | if [ $1 = `basename $1` ]; then | |
6a2824ef | 92 | EXTRA_PATH=../ |
d9e064fd | 93 | else |
6a2824ef | 94 | EXTRA_PATH= |
d9e064fd JS |
95 | fi |
96 | ||
519d4864 | 97 | JADE_CMD="$JADEPROG -t sgml -ihtml -d ${DB_STYLESHEET}${JADETAG} ${EXTRA_PATH}$1" |
6a2824ef JS |
98 | echo "Invoking command '$JADE_CMD'" |
99 | echo | |
100 | ||
101 | echo "working on ${EXTRA_PATH}$1" | |
102 | (cd $TMPDIR; $JADE_CMD; cd $SAVE_PWD) | |
103 | ||
d9e064fd JS |
104 | if [ $# -eq 1 ] |
105 | then | |
8c2e573f | 106 | if [ -d "${output}.junk" ] |
d9e064fd | 107 | then |
8c2e573f | 108 | /bin/rm -rf "${output}.junk" |
d9e064fd | 109 | fi |
8c2e573f | 110 | if [ -d "${output}" ] |
d9e064fd | 111 | then |
8c2e573f | 112 | mv "$output" "${output}.junk" |
d9e064fd JS |
113 | fi |
114 | echo "about to rename temporary directory to $output" | |
8c2e573f | 115 | mv "${TMPDIR}" "$output" |
d9e064fd | 116 | else |
8c2e573f | 117 | cat "$TMPDIR"/* |
d9e064fd JS |
118 | fi |
119 | ||
8c2e573f | 120 | rm -rf "$TMPDIR" |
d9e064fd JS |
121 | |
122 | exit 0 |