File: mk_ascman

package info (click to toggle)
gridengine 8.1.9%2Bdfsg-10
  • links: PTS, VCS
  • area: main
  • in suites: bookworm
  • size: 56,880 kB
  • sloc: ansic: 432,689; java: 87,068; cpp: 31,958; sh: 29,429; jsp: 7,757; perl: 6,336; xml: 5,828; makefile: 4,701; csh: 3,928; ruby: 2,221; tcl: 1,676; lisp: 669; yacc: 519; python: 503; lex: 361; javascript: 200
file content (221 lines) | stat: -rwxr-xr-x 8,264 bytes parent folder | download | duplicates (6)
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
33
34
35
36
37
38
39
40
41
42
43
44
45
46
47
48
49
50
51
52
53
54
55
56
57
58
59
60
61
62
63
64
65
66
67
68
69
70
71
72
73
74
75
76
77
78
79
80
81
82
83
84
85
86
87
88
89
90
91
92
93
94
95
96
97
98
99
100
101
102
103
104
105
106
107
108
109
110
111
112
113
114
115
116
117
118
119
120
121
122
123
124
125
126
127
128
129
130
131
132
133
134
135
136
137
138
139
140
141
142
143
144
145
146
147
148
149
150
151
152
153
154
155
156
157
158
159
160
161
162
163
164
165
166
167
168
169
170
171
172
173
174
175
176
177
178
179
180
181
182
183
184
185
186
187
188
189
190
191
192
193
194
195
196
197
198
199
200
201
202
203
204
205
206
207
208
209
210
211
212
213
214
215
216
217
218
219
220
221
#!/bin/sh
#
# Creates ASCII manual pages in ASCMAN/man/man{1,...} sudirectories from
# nroff manual pages in SEDMAN/man/man{1,...} subdirectories.
# The ASCMAN/man/man{1,...} sudirectories are created if they do not exist.
# Also can create HTML version of the manpages.
#
# Requires groff to be installed and accessible.
#
# $1 = directory where aimk is installed
# $2 = "ge" or "sge"
# $3 = 0 or 1 - flag if man pages in ASCII format should be created
# $4 = 0 or 1 - flag if man pages in HTML format  should be created
# $5 = 0 or 1 - checkout man pages with "-kv" flag
# $6 = name of the cvs module which will be checked out (default gridengine/doc/man) (not used)
# $7 = directory where the man pages will be built (default  <source dir>/MANSBUILD_<product name>)
#
#___INFO__MARK_BEGIN__
##########################################################################
#
#  The Contents of this file are made available subject to the terms of
#  the Sun Industry Standards Source License Version 1.2
#
#  Sun Microsystems Inc., March, 2001
#
#
#  Sun Industry Standards Source License Version 1.2
#  =================================================
#  The contents of this file are subject to the Sun Industry Standards
#  Source License Version 1.2 (the "License"); You may not use this file
#  except in compliance with the License. You may obtain a copy of the
#  License at http://gridengine.sunsource.net/Gridengine_SISSL_license.html
#
#  Software provided under this License is provided on an "AS IS" basis,
#  WITHOUT WARRANTY OF ANY KIND, EITHER EXPRESSED OR IMPLIED, INCLUDING,
#  WITHOUT LIMITATION, WARRANTIES THAT THE SOFTWARE IS FREE OF DEFECTS,
#  MERCHANTABLE, FIT FOR A PARTICULAR PURPOSE, OR NON-INFRINGING.
#  See the License for the specific provisions governing your rights and
#  obligations concerning the Software.
#
#  The Initial Developer of the Original Code is: Sun Microsystems, Inc.
#
#  Copyright: 2001 by Sun Microsystems, Inc.
#
#  All Rights Reserved.
#
##########################################################################
#___INFO__MARK_END__

umask 022

MANBUILDDIR=$1/MANSBUILD_$2
MANMODE=$2
MANASC=$3
MANHTML=$4

if [ $# -gt 6 ]; then
  MANBUILDDIR=$7
fi

echo "Removing old manpages in $MANBUILDDIR"
rm -rf $MANBUILDDIR
mkdir -p $MANBUILDDIR

cd $MANBUILDDIR

MANSRCDIR=$1/../doc/man
#
# Changes magic strings in the checked-in man page versions into SGE,
# etc. as appropriate.
# Creates the changed man pages in SEDMAN/man/man{1,...} subdirectories,
# which are created if they do not exist.
#
# Requires sed to be installed and accessible.
if [ $MANMODE = "ge" -o $MANMODE = "sge" ]; then
   xxQS_NAMExx="Grid Engine"
   xxQS_NAME_Sxx="SGE"
   xxqs_name_sxx="sge"
   xxRELxx="SGE 8.1.3pre"
else
   echo "error wrong MANMODE=$MANMODE. Exit" >&2
   exit 1
fi

# Build the list of the available sections
SECTION_LIST=""
for n in 1 2 3 4 5 6 7 8; do
   if [ -d $MANSRCDIR/man${n} ]; then
     if [ "$SECTION_LIST" = "" ]; then
        SECTION_LIST=$n
     else
        SECTION_LIST="$SECTION_LIST $n"
     fi
   fi
done

echo "Building SEDMAN pages"
for n in $SECTION_LIST; do
   mkdir -p $MANBUILDDIR/SEDMAN/man/man${n} > /dev/null 2>&1

   if [ ! -d $MANBUILDDIR/SEDMAN/man/man${n} ]; then
      echo "Error: Couldn't create subdirectory SEDMAN/man/man${n}." >&2
      exit 1
   fi

   for f in $MANSRCDIR/man${n}/*.${n}; do
      echo "Processing $f"
      sed -e "s/xxQS_NAMExx/$xxQS_NAMExx/g" \
          -e "s/xxQS_NAME_Sxx/$xxQS_NAME_Sxx/g" \
          -e "s/xxqs_name_sxx/$xxqs_name_sxx/g" \
          -e "s/xxRELxx/$xxRELxx/g" $f > $MANBUILDDIR/SEDMAN/man/man${n}/`basename $f`
   done
done


#
# process the seded man pages with groff
#
if [ "$MANASC" = 1 ]; then
   echo "Building ASCMAN from sedman pages"
   for n in $SECTION_LIST; do
      mkdir -p $MANBUILDDIR/ASCMAN/man/man${n} > /dev/null 2>&1

      if [ ! -d $MANBUILDDIR/ASCMAN/man/man${n} ]; then
         echo "Error: Couldn't create subdirectory ASCMAN/man/man${n}." >&2
         exit 1
      fi

      cd $MANBUILDDIR/SEDMAN/man
      for f in man${n}/*.${n}; do
         echo "Processing $f"
         groff -man -t -Tascii $f > $MANBUILDDIR/ASCMAN/man/man${n}/`basename $f .${n}`
      done
   done
fi

# Echo all the names corresponding to this page, dealing with "\ " and "\-".
altnames () {
    # Not done on formatted version because of line breaks
    grep -A 1 '\.SH NAME' "$1" | tail -n 1 |
      sed -e 's/  *\\-.*$//' -e 's/, */ /g' -e 's/\\ /\&nbsp;/g' -e 's/\\-/\&ndash;/g' |
      sed -e "s/xxQS_NAMExx/$xxQS_NAMExx/g" \
          -e "s/xxQS_NAME_Sxx/$xxQS_NAME_Sxx/g" \
          -e "s/xxqs_name_sxx/$xxqs_name_sxx/g" \
          -e "s/xxRELxx/$xxRELxx/g"
}

#
# build html man pages from sedman with man2html
# NB, this is the html2man from http://www.nongnu.org/man2html/, not
# the one in Debian, for instance.
#
if [ "$MANHTML" = 1 ]; then
   echo "Building HTML from sedman pages"
   for n in $SECTION_LIST; do
      mkdir -p $MANBUILDDIR/HTMLMAN/htmlman${n}
      for i in $MANBUILDDIR/SEDMAN/man/man${n}/*; do
         echo "Processing $i"
         bn=`basename $i .${n}`
         # man -M$MANBUILDDIR/SEDMAN/man/ $bn | man2html -solaris > $MANBUILDDIR/HTMLMAN/htmlman${n}/${bn}.html
         secopt=-s
         if [ Linux = `uname` ]; then
            secopt=""
         fi
	 # This used to use `man' on the SEDMAN files, but that loses
	 # the overstriking.
         groff -man -t -M$MANBUILDDIR/../scripts -my -Tascii $MANBUILDDIR/SEDMAN/man/man$n/$bn.$n | man2html -title $bn.$n -botm 4 -topm 4 -pgsize 999999 -cgiurl "../htmlman"'$section/$title'".html" | sed '2s/BODY/BODY BGCOLOR=white/' > $MANBUILDDIR/HTMLMAN/htmlman${n}/${bn}.html
# This works, but the backend doesn't do .IP right, at least
#          sed -e 's;\\\\fI\\\\\$1\\\\fR\\\\|(\\\\\$2)\\\\\$3;.URL ../htmlman\\\\$2/\\\\$1 \\\\fI\\\\$1\\\\fP(\\\\$2) \\\\$3;' $MANBUILDDIR/SEDMAN/man/man$n/$bn.$n | \
#          groff -man -t -Thtml > $MANBUILDDIR/HTMLMAN/htmlman${n}/${bn}.html
      done
   done

   #
   # generate an index file with alternative names and links
   #

   cp $1/scripts/template.html $MANBUILDDIR/HTMLMAN/index.html
   for n in $SECTION_LIST; do
      echo "<H3>Section $n</H3>" >> $MANBUILDDIR/HTMLMAN/index.html
      echo '<P><UL>' >> $MANBUILDDIR/HTMLMAN/index.html
      for f in $MANBUILDDIR/HTMLMAN/htmlman${n}/*; do
         base=`basename $f`
         title=`basename $base .html`
         names=`altnames $MANSRCDIR/man$n/$title.$n`
         case $title in         # exceptions
             usermapping) continue;;
         esac
         # duplicates fixed by sort -u if necessary
         echo "<LI><A HREF=\"htmlman${n}/$base\" target=\"PAGE\">$title</A>"
         for name in $names; do
             # for utilbin/... etc., and html entities
             name=`basename $name | sed -e 's/&ndash;/-/g'`
             echo "<LI><A HREF=\"htmlman${n}/$base\" target=\"PAGE\">$name</A>"
             if [ "$title" != "$name" ]; then
                 case $name in
                     *'&'*) ;; # exceptions
                     *) (cd ; ln -sf "$base" "`dirname $f`/$name.html";)
                 esac
             fi
         done
      done | sort -u -t '>' -k 3 >> $MANBUILDDIR/HTMLMAN/index.html
      echo '</UL></P>' >> $MANBUILDDIR/HTMLMAN/index.html
   done
   echo '</BODY></HTML>' >> $MANBUILDDIR/HTMLMAN/index.html

   #
   # generate the manual.html file
   #
   echo '<HTML>' > $MANBUILDDIR/HTMLMAN/manuals.html
   echo " <HEAD><TITLE>$xxQS_NAME_Sxx Manual Pages</TITLE></HEAD>" >> $MANBUILDDIR/HTMLMAN/manuals.html
   echo ' <frameset cols="230,*" frameborder="NO" framespacing="0" border="3">' >> $MANBUILDDIR/HTMLMAN/manuals.html
   echo '  <frame src=' >> $MANBUILDDIR/HTMLMAN/manuals.html
   echo "   index.html" >> $MANBUILDDIR/HTMLMAN/manuals.html
   echo '   marginwidth="0" marginheight=0 name="TOC" noresize>' >> $MANBUILDDIR/HTMLMAN/manuals.html
   echo '  <frame src=' >> $MANBUILDDIR/HTMLMAN/manuals.html
   echo "   htmlman1/sge_intro.html" >> $MANBUILDDIR/HTMLMAN/manuals.html
   echo '   marginwidth="0" marginheight=0 name="PAGE" noresize>' >> $MANBUILDDIR/HTMLMAN/manuals.html
   echo ' </frameset>' >> $MANBUILDDIR/HTMLMAN/manuals.html
   echo '</HTML>' >> $MANBUILDDIR/HTMLMAN/manuals.html
fi