3 # -------------------------------------------------------------
6 # This script was leveraged from "databaseConversionTool.ksh"
7 # it should provide a superset of the functionality of that script;
8 # however the primary motivation was to get away from the use of
9 # multiple divergent parsers for the ".udb" style database. The
10 # parser has been moved into an awk "library" file: udbParseLib.awk.
11 # this parser can and should be used by all scripts wishing to parse
12 # the ".udb" data bases.
14 # ----------------------------
17 # -toDB to convert to old mksubmit-style ".db" format
18 # -toLst to convert to old domain-port-style ".lst" files
19 # -toCustom <prt> to specify a print routine for a custom format
20 # -custom <awklib> to specify a library containing custom print routines.
21 # -udbParseLib <awkLib> to specify a library containing an alternate parser.
22 # -mailTo <user> to specify an administrator who will receive mail
23 # concerning parsing errors.
25 # -Database is now obsolete (although it will still work)
26 # <udbfile> ... ... The script can now take multiple udb files (Only the
27 # defaults specified in the first udb file will apply).
29 # ----------------------------
31 # This script converts a universal database to an
32 # HP OSF style System Definition Database (SDD) file,
33 # or a set of args suitable to supply to the Chelmsford deliver
34 # tool, or a set of commands to build a delivery tree.
35 # For more details, please refer to the "X11 and VUE for HP_OSF/1.0"
38 # This script was leveraged (read hacked extensively) from
39 # the "udbToDb" script by Jim Andreas. Ron Voll authored the
40 # original "udbToDb" script.
42 # -------------------------------------------------------------
44 # usage: databaseToSDD.ksh Option udbFile
46 # where Option is one of the following:
48 # -toDB convert a .udb to ".db" format
49 # -toLst convert a .udb to ".lst" format
50 # -toSDD convert a .udb to SDD format
51 # -toDeliverArgs convert a .udb to args that the deliver tool likes
52 # -toReleaseTree convert a .udb to a script to build a delivery tree
53 # -toCheckBuild convert a .udb to a script to check the items in a build
54 # -toFileList convert a .udb to a list of files for carbon units
55 # -Machine specifies 3,7,8 for hp-ux releases
56 # -ReleaseStream {hp-ux, osf, whatever}
57 # -NoDefaults do not convert any records labeled default
58 # -toTargetList convert a .udb to a list of target files in product tree
59 # the leading path is stripped and just the target
60 # file is left - for easy diffing with some other
61 # version of a release
62 # -custom <awkFile> Supply a custom "awk" print library
63 # -toCustom <prt routine>
64 # -udbParseLib <awkFile> Supply an alternate "awk" parser library
67 # -------------------------------------------------------------
70 # This ksh function invokes awk to do all of the dirty
71 # work. The DoAction variable is consulted only in the
72 # final stages of printing the desired info after the
73 # .udb "phrases" are parsed.
75 # -------------------------------------------------------------
81 # set what we are going to do
86 # set the "release stream" or token in a block in the .udb
87 # file for which we will scan.
92 # and for HP-UX releases, the particular machine 68k/Snake/S800 3/7/8
96 # set flag if default blocks are to be processed
98 typeset UseDefaultBlocks=$4
106 if [ -x /usr/bin/nawk ]; then
111 # Custom print routines may use the following parser variables:
112 # defOrder[] --- An array containing the names of the fields in
113 # a data base record (in the correct order).
114 # NumEntries --- One MORE than the number of entries in the
115 # "defOrder" array. This is the number of fields
116 # in a data base record.
117 # rec[] --- An associative array indexed by data base record
118 # field name containing the value of the field.
120 # Assign custom print routines to be used for output. The default is to
121 # use the "printDb" function associated with the library.
132 toFileList|toTargetList|toCheckBuild|toReleaseTree|toDeliverArgs|toSDD)
136 CUSTOM_PRINT="-f $CUSTOM_PRINT_LIB"
140 echo "$0: Unknown Action>> \"$doAction\""
147 # The function name "PRTREC" is used by the parsing routines
148 # to do the output. By providing a custom output function you
149 # can print the database any way you want. The default is to
150 # use the "printRecord" function built defined in the awk file
151 # containing the awk parser.
153 function PRTREC(rec) {
160 print "Getting New Line AWK style -- Problem?"
166 # Create a single awk file for use with the "-f" parameter.
167 # IBM's awk only allows one "-f"
169 cat "$UDB_PARSE_LIB" >> $TMPFILE
170 [ -z "$CUSTOM_PRINT" ] || cat "$CUSTOM_PRINT_LIB" >> $TMPFILE
172 $AWK -v mailTo="$Administrator" \
173 -v action="$DoAction" \
174 -v BlockToken="$BlockToken" \
175 -v Machine="$machine" \
176 -v UseDefaultBlocks="$UseDefaultBlocks" \
177 -v DeBugFile="$DEBUGFILE" \
178 -v DeBug="$DEBUGLEVEL" \
183 # Removed from parameter list because IBM's awk only allows one "-f"
185 # -f "$UDB_PARSE_LIB" \
192 # print a handy usage message to stderr (file descriptor 2 )
199 echo "$ScriptName: usage:"
201 echo " $ScriptName [Options] <UdbFile> ..."
203 echo " -toDB convert a .udb to \".db\" format"
204 echo " -toLst convert a .udb to \".lst\" format"
205 echo " -toSDD convert a .udb to SDD format"
206 echo " -toDeliverArgs convert a .udb to args that the deliver tool likes"
207 echo " -toReleaseTree convert a .udb to a script to build a delivery tree"
208 echo " -toCheckBuild convert a .udb to a script to check a build"
209 echo " -toFileList convert a .udb to a list of files"
210 echo " -toTargetList convert a .udb to a list of product files"
211 echo " -ReleaseStream {hp-ux, osf, whatever}"
212 echo " -Machine specifies machine 3,7,8 for hp-ux"
213 echo " -NoDefaults do not convert any records labeled \"default\""
214 echo " -Database path (obsolete) specifies full path to the .udb file to convert"
215 echo " -mailTo <user> Specify a user to receive mail on errors."
216 echo " -toCustom <prt> Specify the name of a custom print routine."
217 echo " -custom <awkFile> Supply a custom "awk" print library."
218 echo " -udbParseLib <awkFile> Supply an alternate 'awk' parser library"
223 # OK, here is where we really start execution.
224 # Check that the first argument defines what this script is
227 # Obscurity footprint-in-the-sand: "${1##*/}" is equivalent
232 # -toSDD convert a .udb to SDD format
233 # -toDeliverArgs convert a .udb to args that the deliver tool likes
234 # -toReleaseTree convert a .udb to a script to build a delivery tree
235 # -toCheckBuild convert a .udb to a script to check the items in a build
237 if [ $# -le 3 ]; then
241 typeset TakeDefaultBlocks="Y"
242 typeset Administrator=""
243 #typeset DBTOOLSRC=/x/toolsrc/dbTools
244 typeset DBTOOLSRC=`dirname $0`
245 typeset UDB_PARSE_LIB="$DBTOOLSRC/udbParseLib.awk"
246 typeset CUSTOM_PRINT_LIB=""
247 typeset DEBUGFILE="/dev/tty"
249 typeset TMPFILE=`mktemp /tmp/awkXXXXXXXXXXXXXXXXXXXXX`
251 if [ $# -gt 2 ]; then
301 if [ "x$2" = "x" ]; then
310 if [ "x$2" = "x" ]; then
319 if [ "x$2" = "x" ]; then
322 if [ ! -r "$2" ]; then
325 Database="$Database $2"
330 -udbParseLib) # specify alternate "awk" parser location
331 if [ "x$2" = "x" ]; then
334 if [ ! -r "$2" ]; then
342 -toCustom) # specify custom "awk" print routines
343 if [ "x$2" = "x" ]; then
352 -custom) # specify custom "awk" print routines
353 if [ "x$2" = "x" ]; then
356 if [ ! -r "$2" ]; then
364 -mailTo) # specify an administrator who receives mail about errors.
365 if [ "x$2" = "x" ]; then
373 -DeBugFile) # specify a debug file and debug level for parser debug info
374 if [ "x$2" = "x" ]; then
377 if [ "x$3" = "x" ]; then
384 -DeBugLevel) # specify a debug level for parser debug info
385 if [ "x$2" = "x" ]; then
388 if [ "x$3" = "x" ]; then
396 echo "unknown option: $1"
401 *) if [ ! -r $1 ]; then
404 Database="$Database $1"
411 if [ "$Action" = "toCustom" ]; then
412 if [ -z "$CUSTOM_PRINT_LIB" ]; then
413 echo "You Must specify an awk file containing the custom print routine \"$CUS_PRT\""
419 if [ "$Machine" = "" ]; then
421 elif [ "$Machine" = "300" ]; then
423 elif [ "$Machine" = "700" ]; then
425 elif [ "$Machine" = "800" ]; then
428 if [ "$ReleaseStream" = "" ]; then
429 echo "$ScriptName: need to specify a -ReleaseStream" >&2
432 if [ "$Database" = "" ]; then
433 echo "$ScriptName: need to specify a -Database" >&2
438 ConvertRoutine $Action $ReleaseStream $Machine $TakeDefaultBlocks $Database