Provide support for installation under OpenBSD. Don't override PATH in the install...
[oweals/cde.git] / cde / admin / IntegTools / dbTools / installCDE.src
1 XCOMM! /bin/ksh
2 XCOMM $XConsortium: installCDE.src /main/20 1996/11/25 14:21:13 drk $
3
4 XCOMM
5 XCOMM This script uses the 'CDE' databases to install either the Desktop
6 XCOMM environment on a specified machine or creates a tar ball to be used
7 XCOMM in an install process.
8 XCOMM
9 XCOMM this script accepts the following parameters:
10 XCOMM       -s <source>         -- The top of build tree where the files are
11 XCOMM                              gathered from.
12 XCOMM       -z <package>        -- The desktop install package
13 XCOMM
14 XCOMM      Optional parameters:
15 XCOMM
16 XCOMM       -t  <package destination>     -- where to store install package
17 XCOMM       -pI <actual install location> -- where CDE_INSTALLATION_TOP will be linked to.
18 XCOMM       -pC <actual config location>  -- where CDE_CONFIGURATION_TOP will be linked to.
19 XCOMM       -pV <actual var location>     -- where CDE_LOGFILES_TOP will be linked to.
20 XCOMM    -a  <alternate udb directory>
21 XCOMM       -f  <filesets>                -- a quoted, space-separated list of 
22 XCOMM                                        filesets to load. The .udb extension
23 XCOMM                                        is not required.
24 XCOMM
25 XCOMM       -clean   -- remove the temporary, configuration and installation 
26 XCOMM                   directories
27 XCOMM       -cleanTwo-- remove the temporary and installation directories
28 XCOMM                   but NOT the configuration directory
29 XCOMM       -cleanEtc-- remove the configuration directories
30 XCOMM       -prog    -- load only the development environment
31 XCOMM       -runtime -- load only the runtime environment
32 XCOMM       -pack    -- create packing list
33 XCOMM       -pseudo  -- don't configure the desktop
34 XCOMM       -nocompress -- don't compress the tarball (-t only)
35 XCOMM
36 XCOMM       -Lang           -- load the localized filesets
37 XCOMM       -LinkStepOnly   -- set up the -pI, -pC, and -pV links
38 XCOMM                          then exit
39 XCOMM       -DontRunScripts -- stop after installation
40 XCOMM       -RunScriptsOnly -- only execute the scripts
41 XCOMM       -configureOnly -- only configure the desktop
42 XCOMM
43 XCOMM ##########################################################################
44
45 #define HASH #
46 #define STAR *
47
48 LOGFILE="installCDE.$$.log"
49
50 REVISION="$(echo "$Revision: /main/20 $" | awk '{print $2}')"
51
52 Log()
53 {
54   echo "$1" | tee -a $LOGFILE
55 }
56
57 MakeTarball()
58 {
59     Log "\nGenerating UNIX Desktop install package $DATE in $TARBALL_LOCATION"
60     HASH
61     HASH create installable tarball
62     HASH
63     Log "Creating tarball..."
64
65     if [ $PLATFORM = "usl" -o "$PLATFORM" = "uxp" ]
66     then
67       ulimit -f unlimited
68     fi
69
70     DIRNAME=build.$DATE
71     mkdir -p $TARBALL_LOCATION/$DIRNAME
72     cd /
73     echo $DATE >$LOGFILES_LOCATION/.build.$DATE
74     chown bin $LOGFILES_LOCATION/.build.$DATE
75
76     if [ "$COMPRESS_TARBALL" = "yes" ]; then
77       tar -cf - $INSTALL_LOCATION/STAR \
78         2>$TARBALL_LOCATION/$DIRNAME/extract.err |
79         compress -c >$TARBALL_LOCATION/$DIRNAME/dttar.Z
80     else
81       tar -cf $TARBALL_LOCATION/$DIRNAME/dt.tar \
82         $INSTALL_LOCATION/STAR \
83         2>$TARBALL_LOCATION/$DIRNAME/extract.err 2>&1
84     fi
85
86     if [ "$ACTUAL_INSTALLATION_LOC" = "" ]; then
87       actualInstallDir=$INSTALL_LOCATION
88     else
89       actualInstallDir=$ACTUAL_INSTALLATION_LOC
90     fi 
91     let size=$(du -s $actualInstallDir | awk '{print $1}')*512
92
93     HASH load installation fileset *after* tarball generated
94     LoadFileSet "" "CDE-INSTALL"
95
96     HASH create config dir
97     destPost=$TARBALL_LOCATION/$DIRNAME/config
98     mkdir $destPost
99
100     HASH copy config and platform config scripts
101     src=$INSTALL_LOCATION/install/$PLATFORM_SCRIPT_DIR
102     cp $src/config/STAR.cfg $destPost
103    
104     HASH copy this script and install.dt platform overrides
105     cp $src/install.dto $TARBALL_LOCATION/$DIRNAME/install.dto
106     cp $src/install.cde $TARBALL_LOCATION/$DIRNAME/install.cde
107     chmod 755 $TARBALL_LOCATION/$DIRNAME/install.cde
108
109     cd /
110
111     Log "done."
112
113     cat >$TARBALL_LOCATION/$DIRNAME/dt.pkg <<FIN
114 PLATFORM: $PLATFORM
115 VERSION: $REVISION
116 TS: $DATE
117 COMPRESSED: $COMPRESS_TARBALL
118 SIZE: $size
119 CL: $ORIGINAL_COMMAND_LINE
120 FILESETS: $DATABASE_FILES
121 FIN
122
123     cat >$TARBALL_LOCATION/$DIRNAME/build.status <<FIN
124 The UNIX Desktop
125
126 BUILD: $DATE
127 OVERALL STATUS: <not yet tested>
128 OVERALL PERFORMANCE: <not yet tested>
129 MAJOR PROBLEMS: <not yet tested>
130
131 FIN
132
133     chmod g+w $TARBALL_LOCATION/$DIRNAME/build.status
134 }
135
136 DoFilesetScript()
137 {
138   typeset ScriptName
139
140   FilesetName=$1
141   if [ "$BUILD_TREE" = "" ]; then
142     ScriptName=$3       # use short config file name (foo.cfg)
143   else
144     ScriptName=$2       # use long config file name (configFoo)
145   fi
146
147   if [ $CDECONFIGDIR = "CONFIG" ]; then
148     typeset -u ScriptName
149   fi
150
151   test_string=${DATABASE_FILES#*$FilesetName}
152   if (( ${#DATABASE_FILES} > ${#test_string} ))
153   then
154     if [ -x $POST_INSTALL_DIR/$PLATFORM_SCRIPT_DIR/$ScriptName ]
155     then
156         Log "Executing $PLATFORM specific $FilesetName customize script"
157         $POST_INSTALL_DIR/$PLATFORM_SCRIPT_DIR/$ScriptName -e 2>&1 | \
158                                 tee -a $LOGFILE
159     elif [ -x $POST_INSTALL_DIR/$ScriptName ]
160     then
161         Log "Executing $FilesetName customize script" 
162         $POST_INSTALL_DIR/$ScriptName -e 2>&1 | tee -a $LOGFILE
163     fi
164   fi
165 }
166
167 DoScripts()
168 {
169   Log " "
170
171   DoFilesetScript CDE-TT       configTT      tt.cfg
172   DoFilesetScript CDE-MIN      configMin     min.cfg
173   DoFilesetScript CDE-SHLIBS   configShlibs  shlibs.cfg
174   DoFilesetScript CDE-RUN      configRun     run.cfg
175 }
176
177 CreatePackingList()
178 {
179     Log " "
180     Log "Creating packing list."
181     touch $INSTALL_LOCATION/Packing_list
182     for i in `echo $DATABASE_FILES`
183     do
184       Log "  for $i"
185       $TOOL_DIR/udbToAny.ksh -toDB -ReleaseStream $PLATFORM $DATABASE_DIR/${i}.udb > /tmp/${i}.db
186       if [ -r /tmp/${i}.db ]
187       then
188         for file in `fgrep install_target /tmp/${i}.db | cut -sf 2 -d \: ` 
189         do
190           echo "$file" >>$INSTALL_LOCATION/Packing_list
191         done
192       fi
193     done
194 }
195
196 CleanDaemons()
197 {
198   HASH kill these processes so that they can be removed and new ones
199   HASH installed
200
201   for i in inetd rpc.ttdbserver rpc.cmsd
202   do
203     if [ "$PLATFORM" = "aix" -a $i = "inetd" ]
204     then
205       lssrc -s inetd >/dev/null 2>&1
206       if [ $? = "0" ]
207       then
208         stopsrc -s inetd >>$LOGFILE 2>&1
209       fi
210     elif [ "$PLATFORM" = openbsd ]
211     then
212       true
213     else    
214       ps -ef | grep $i | grep -v grep >/tmp/tmppsout
215       if [ -s /tmp/tmppsout ]
216       then
217         awk '{print "kill " $2}' /tmp/tmppsout | /bin/csh -f
218         sleep 2
219       fi
220     fi
221   done
222   rm -f /tmp/tmppsout
223 }
224
225 RestartInetd()
226 {
227   HASH now restart inetd
228
229   OLDPWD=`pwd`
230   cd /
231   if [ "$PLATFORM" = "sun" -o "$PLATFORM" = "usl" -o "$PLATFORM" = "uxp" ]
232   then
233     /usr/sbin/inetd -s
234   elif [ "$PLATFORM" = "aix" ]
235   then
236     startsrc -s inetd >>$LOGFILE 2>&1
237   elif [ "$PLATFORM" = "dec" ]
238   then
239     /usr/sbin/inetd
240   elif [ "$PLATFORM" = "openbsd" ]
241   then
242     true
243   else
244 #ifdef hpV4
245     /usr/sbin/inetd 
246 #else
247     /etc/inetd
248 #endif
249   fi
250   cd $OLDPWD
251 }
252
253 CheckForActualLocations()
254 {
255 XCOMM
256 XCOMM if different actual locations specified, set up the links
257 XCOMM
258
259
260   if [ "$CLEAN_DAEMONS" = "yes" ]
261   then
262     CleanDaemons
263   fi
264
265   HASH remove the contents of the installation directory then the directory
266   HASH itself
267
268   if [ "$CLEANING" = "yes" ]
269   then
270     Log "Removing $INSTALL_LOCATION contents... "
271     if [ -d $INSTALL_LOCATION ]
272     then
273       rm -rf $INSTALL_LOCATION/STAR
274       if [ "$LeaveLinks" = "yes" ]
275       then
276         if [ ! -L $INSTALL_LOCATION ]
277         then
278           rm -rf $INSTALL_LOCATION
279         fi
280       else
281         if [ -L $INSTALL_LOCATION ]
282         then
283           rm -f $INSTALL_LOCATION
284         else
285           rm -rf $INSTALL_LOCATION
286         fi
287       fi
288     fi
289   fi
290
291   if [ "$CONFIGURE_ONLY" = "no" ]
292   then
293     if [ "$ACTUAL_INSTALLATION_LOC" != "" ]
294     then
295
296       HASH
297       HASH first create the actual directory - if not there
298       HASH
299
300       if [ ! -d $ACTUAL_INSTALLATION_LOC ]
301       then
302         mkdir -p $ACTUAL_INSTALLATION_LOC
303         if [ ! -d $ACTUAL_INSTALLATION_LOC ]
304         then
305           Log "cannot create $ACTUAL_INSTALLATION_LOC directory"
306           exit 1
307         fi
308       fi
309
310       ln -s $ACTUAL_INSTALLATION_LOC $INSTALL_LOCATION
311
312     else
313       if [ ! -d $INSTALL_LOCATION -a ! -L $INSTALL_LOCATION ]; 
314       then
315         mkdir -p $INSTALL_LOCATION
316       fi
317     fi
318   fi
319
320   if [ "$CLEAN_DAEMONS" = "yes" ]
321   then
322     RestartInetd
323   fi
324
325   HASH remove the contents of the configuration directory
326
327   if [ "$CLEANING_ETC" = "yes" ]
328   then
329     Log "Removing $CONFIGURE_LOCATION contents... "
330     if [ -d $CONFIGURE_LOCATION ]
331     then
332       rm -rf $CONFIGURE_LOCATION/STAR
333       if [ "$LeaveLinks" = "yes" ]
334       then
335         if [ ! -L $CONFIGURE_LOCATION ]
336         then
337           rm -rf $CONFIGURE_LOCATION
338         fi
339       else
340         if [ -L $CONFIGURE_LOCATION ]
341         then
342           rm -f $CONFIGURE_LOCATION
343         else
344           rm -rf $CONFIGURE_LOCATION
345         fi
346       fi
347     fi
348   fi
349         
350   if [ "$ACTUAL_CONFIGURATION_LOC" != "" ]
351   then
352     if [ ! -d $ACTUAL_CONFIGURATION_LOC ]
353     then
354       mkdir -p $ACTUAL_CONFIGURATION_LOC
355       if [ ! -d $ACTUAL_CONFIGURATION_LOC ]
356       then
357         Log "cannot create $ACTUAL_CONFIGURATION_LOC directory"
358         exit 1
359       fi
360     fi
361
362     ln -s $ACTUAL_CONFIGURATION_LOC $CONFIGURE_LOCATION
363
364   else
365     if [ ! -d $CONFIGURE_LOCATION -a ! -L $CONFIGURE_LOCATION ];
366     then
367       mkdir -p $CONFIGURE_LOCATION
368     fi
369   fi
370
371   if [ "$CLEANING" = "yes" ]
372   then
373     Log "Removing $LOGFILES_LOCATION contents... "
374     if [ -d $LOGFILES_LOCATION ]
375     then
376       rm -rf $LOGFILES_LOCATION/STAR
377       if [ "$LeaveLinks" = "yes" ]
378       then
379         if [ ! -L $LOGFILES_LOCATION ]
380         then
381           rm -rf $LOGFILES_LOCATION
382         fi
383       else
384         if [ -L $LOGFILES_LOCATION ]
385         then
386           rm -f $LOGFILES_LOCATION
387         else
388           rm -rf $LOGFILES_LOCATION
389         fi
390       fi
391     fi
392   fi
393
394   if [ "$ACTUAL_VAR_LOC" != "" ]
395   then
396     if [ ! -d $ACTUAL_VAR_LOC ]
397     then
398       mkdir -p $ACTUAL_VAR_LOC
399       if [ ! -d $ACTUAL_VAR_LOC ]
400       then
401         Log "cannot create $ACTUAL_VAR_LOC directory"
402         exit 1
403       fi
404     fi
405
406     ln -s $ACTUAL_VAR_LOC $LOGFILES_LOCATION
407     
408   else
409     if [ ! -d $LOGFILES_LOCATION -a ! -L $LOGFILES_LOCATION ]; 
410     then
411       mkdir -p $LOGFILES_LOCATION
412     fi
413   fi
414
415   Log " "
416 }
417
418 USAGE()
419 {
420 echo -e "Usage: $(basename $0) {-s <source>|-z <package>} [options]"
421 echo -e ""
422 echo -e "\t-s <source>\t\t\tthe top of the build tree"
423 echo -e "\t-z <package>\t\tthe desktop install package"
424 echo -e ""
425 echo -e "\tOptions:"
426 echo -e ""
427 echo -e "\t[-t <package_destination>]\tif specified create an"
428 echo -e "\t\t\t\t\tinstall package and store it in the"
429 echo -e "\t\t\t\t\tdestination."
430 echo -e "\t[-pI <actual install location>]\twhere" CDE_INSTALLATION_TOP "will be linked to."
431 echo -e "\t[-pC <actual config location>]\twhere" CDE_CONFIGURATION_TOP "will be linked to."
432 echo -e "\t[-pV <actual var location>]\twhere" CDE_LOGFILES_TOP "will be linked to."
433 echo -e ""
434 echo -e "\t[-a <udb directory>]\t\talternate place to get the"
435 echo -e "\t\t\t\t\tudb files from."
436 echo -e "\t[-f <filesets>]\t\t\tspecify filesets to be loaded."
437 echo -e "\t\t\t\t\tThe list should be double-quoted,"
438 echo -e "\t\t\t\t\tspace-separated, with no .udb"
439 echo -e "\t\t\t\t\textensions."
440 echo -e ""
441 echo -e "\t[-clean]\t\t\tremove the temporary, configuration, and"
442 echo -e "\t\t\t\t\tinstallation directory"
443 echo -e "\t[-cleanTwo]\t\t\tremove the temporary and installation "
444 echo -e "\t\t\t\t\tdirectory, but NOT the configuration directory"
445 echo -e "\t[-cleanEtc]\t\t\tremove the configuration directory, but "
446 echo -e "\t\t\t\t\NOT the temporary and installation directories"
447 echo -e "\t[-prog]\t\t\t\tload only the development environment"
448 echo -e "\t[-runtime]\t\t\tload only the runtime environment"
449 echo -e "\t[-relative]\t\t\trun the relative-located config scripts"
450 echo -e "\t[-pack]\t\t\t\tcreate a packing list"
451 echo -e "\t[-pseudo]\t\t\tdo not configure desktop when installing"
452 echo -e "\t[-nocompress]\t\t\tdo not compress tarball when creating package"
453 echo -e "\t[-lang LANG]\t\t\tspecify LANG to load appropriate localized"
454 echo -e "\t\t\t\t\tfilesets"
455 echo -e "\t[-LeaveLinks]\t\t\t\tdo not delete the links after cleaning"
456 echo -e ""
457 echo -e "\t[-LinkStepOnly]\t\t\tset up the -pI, -pC, and -pV links"
458 echo -e "\t\t\t\t\tthen exit"
459 echo -e "\t[-DontRunScripts]\t\tstop after installation"
460 echo -e "\t[-RunScriptsOnly]\t\tonly execute the scripts"
461 echo -e "\t[-configureOnly]\t\tonly configure the desktop"
462 echo -e ""
463 echo -e "\tExamples:"
464 echo -e ""
465 echo -e "\tinstallCDE -s /x/cde_hp700_90"
466 echo -e "\tinstallCDE -s /x/cde_aix_32 -f \"CDE_MIN CDE-SHLIBS\""
467 echo -e "\tinstallCDE -s /x/cde_sun_52 -pI /bigdisk/opt/dt -clean"
468 echo -e "\tinstallCDE -s /x/cde_sun_52 -pI /dtinstall -clean\\"
469 echo -e "\t\t-pseudo -t /dtpackages -nocompress"
470 }
471
472 XCOMM
473 XCOMM LoadFileSet() - load a UDB file
474 XCOMM $1 - fileset number
475 XCOMM $2 - fileset name
476 XCOMM
477 LoadFileSet()
478 {
479   if [ "$1" = "" ]; then
480     num=""
481   else
482     num="$1."
483   fi
484
485 XCOMM don't bother if the fileset doesn't exist
486   if [ ! -e $DATABASE_DIR/${2}.udb ]
487   then
488         return
489   fi
490
491   Log "  $num installing database $2"
492   Log "      - creating ${2}.lst file"
493   $TOOL_DIR/udbToAny.ksh  -toLst -ReleaseStream $PLATFORM \
494             $DATABASE_DIR/${2}.udb >  /tmp/${2}.lst
495   Log "      - installing ... \c"
496   $TOOL_DIR/mkProd -D / -S $BUILD_TREE /tmp/${2}.lst \
497             2>/tmp/${2}.err 1>/tmp/${2}.good
498   Log "done."
499
500   Log "      - checking for errors ..."
501   rm -f /tmp/${2}.missing
502   awk '{if ($1 == "ERROR:") print "           " $4}' \
503             /tmp/${2}.err >> /tmp/${2}.missing
504   if [ -s /tmp/${2}.missing ]
505   then
506     Log "      - missing files:"
507     cat /tmp/${2}.missing | tee -a $LOGFILE
508   fi
509 }
510
511 ORIGINAL_COMMAND_LINE="$*"
512
513 XCOMM Set which system we are on
514 BUILDSYSTEM=$(uname)
515
516 PLATFORM=""
517 PLATFORM_SCRIPT_DIR=""
518
519 XCOMM
520 XCOMM Set system
521 XCOMM 
522   if [ $BUILDSYSTEM = "AIX" ];
523   then
524     PLATFORM=aix
525     PLATFORM_SCRIPT_DIR=ibm
526   elif [ $BUILDSYSTEM = "SunOS" ];
527   then
528     PLATFORM=sun
529     PLATFORM_SCRIPT_DIR=sun
530   elif [ $BUILDSYSTEM = "UNIX_SV" ];
531   then
532     PLATFORM=usl
533     PLATFORM_SCRIPT_DIR=usl
534   elif [ $BUILDSYSTEM = "UNIX_System_V" ];
535   then
536     PLATFORM=uxp
537     PLATFORM_SCRIPT_DIR=uxp
538   elif [ $BUILDSYSTEM = "OSF1" ];
539   then
540     PLATFORM=dec
541     PLATFORM_SCRIPT_DIR=dec
542   elif [ $BUILDSYSTEM = "Linux" ];
543   then
544     PLATFORM="linux"
545     PLATFORM_SCRIPT_DIR=""
546   elif [ $BUILDSYSTEM = "OpenBSD" ];
547   then
548     PLATFORM="openbsd"
549     PLATFORM_SCRIPT_DIR=""
550   else                  # Build system = HP
551     PLATFORM=hp-ux
552     PLATFORM_SCRIPT_DIR=hp
553   fi
554
555   if [ "$PLATFORM" = "aix" ];
556   then
557     USER=`/bin/whoami`
558   elif [ "$PLATFORM" = "sun" -o "$PLATFORM" = "usl" -o "$PLATFORM" = "uxp" ];
559   then
560     USER=`/usr/ucb/whoami`
561   else
562     USER=`/usr/bin/whoami`
563   fi
564
565   if [ "$USER" != "root" ];
566   then
567     echo ""
568     echo "You should be root to run this script.  Continuing anyway."
569     echo ""
570   fi
571
572   if [ "$PLATFORM" = "usl" -o "$PLATFORM" = "uxp" ]
573   then
574     umask 000
575   fi
576
577   unset TMPDIR
578
579   CLEANING="no"
580   CLEANING_ETC="no"
581   TARBALL="no"
582   COMPRESS_TARBALL="yes"
583   USE_ALTERNATE_UDB_DIR="no"
584   DEVELOP_ENV="no"
585   RUNTIME_ENV="no"
586   USE_RELATIVE="no"
587   STARTING_DIR=$PWD
588   ACTUAL_INSTALLATION_LOC=""
589   ACTUAL_CONFIGURATION_LOC=""
590   ACTUAL_VAR_LOC=""
591   CREATE_PACKING_LIST="no"
592   DO_LINK_STEP_ONLY="no"
593   DO_INSTALL_ONLY="no"
594   RUN_SCRIPTS="yes"
595   RUN_SCRIPTS_ONLY="no"
596   DATABASE_FILES=""
597   BUILD_TREE=""
598   TAR_DIR=""
599   LeaveLinks="no"
600   REMOVE_LINKS="no"
601   CLEAN_DAEMONS="yes"
602   theLang=""
603   CONFIGURE_ONLY="no"
604
605   rm -f $LOGFILE
606
607   Log "Options specified..."
608   while [ $# -ne 0 ]; do
609     case $1 in
610         -s) Log "  - get the build tree to extract from"
611             shift;
612             [ $# -ne 0 ] || {
613                 USAGE
614                 exit 1;
615             }
616             BUILD_TREE=$1
617             shift;
618             ;;
619         -z) Log "  - get the install package to extract from"
620             shift;
621             [ $# -ne 0 ] || {
622                 USAGE
623                 exit 1;
624             }
625             TAR_TREE=$1
626             shift;
627             ;;
628         -t) Log "  - where to put the install package"
629             shift;
630             [ $# -ne 0 ] || {
631                 USAGE
632                 exit 1;
633             }
634             if [ "$SOURCE_TAR_FILE" = "" ]
635             then
636                 TARBALL="yes"
637                 TARBALL_LOCATION=$1
638             fi
639             shift;
640             ;;
641         -a) Log "  - alternate place to get the udb files from"
642             shift;
643             [ $# -ne 0 ] || {
644                 USAGE
645                 exit 1;
646             }
647             ALTERNATE_UDB_DIR=$1
648             USE_ALTERNATE_UDB_DIR="yes"
649             shift;
650             ;;
651         -f) Log "  - load specific filesets"
652             shift;
653             [ $# -ne 0 ] || {
654                 USAGE
655                 exit 1;
656             }
657             DATABASE_FILES=$1
658             shift;
659             ;;
660         -p) Log "  - get all locations"
661             shift;
662             [ $# -ne 0 ] || {
663                 USAGE
664                 exit 1;
665             }
666             ACTUAL_INSTALLATION_LOC=$1
667             ACTUAL_CONFIGURATION_LOC=$1
668             ACTUAL_VAR_LOC=$1
669             shift;
670             ;;
671         -pI) Log "  - get actual installation location"
672             shift;
673             [ $# -ne 0 ] || {
674                 USAGE
675                 exit 1;
676             }
677             ACTUAL_INSTALLATION_LOC=$1
678             shift;
679             ;;
680         -pC) Log "  - get actual configuration location"
681             shift;
682             [ $# -ne 0 ] || {
683                 USAGE
684                 exit 1;
685             }
686             ACTUAL_CONFIGURATION_LOC=$1
687             shift;
688             ;;
689         -pV) Log "  - get actual var location"
690             shift;
691             [ $# -ne 0 ] || {
692                 USAGE
693                 exit 1;
694             }
695             ACTUAL_VAR_LOC=$1
696             shift;
697             ;;
698         -clean) Log "  - delete all three cde directories"
699             CLEANING="yes"
700             CLEANING_ETC="yes"
701             shift;
702             ;;
703         -cleanTwo) Log "  - delete only temporary and installation directories"
704             CLEANING="yes"
705             shift;
706             ;;
707         -cleanEtc) Log "  - delete only the configuration directory"
708             CLEANING_ETC="yes"
709             shift;
710             ;;
711         -prog) Log "  - load only the development environment"
712             DEVELOP_ENV="yes"
713             RUNTIME_ENV="no"
714             shift;
715             ;;
716         -runtime) Log "  - load only the runtime environment"
717             RUNTIME_ENV="yes"
718             DEVELOP_ENV="no"
719             shift;
720             ;;
721         -relative) Log "  - run the relative-located config scripts"
722             USE_RELATIVE="yes"
723             shift;
724             ;;
725         -pack) Log "  - create a packing list"
726             CREATE_PACKING_LIST="yes"
727             shift;
728             ;;
729         -LeaveLinks) Log "  - do not remove the links"
730             LeaveLinks="yes"
731             shift;
732             ;;
733         -LinkStepOnly) Log "  - do link step only"
734             DO_LINK_STEP_ONLY="yes"
735             shift;
736             ;;
737         -DontRunScripts) Log "  - stop after installation"
738             DO_INSTALL_ONLY="yes"
739             shift;
740             ;;
741         -RunScriptsOnly) Log "  - only run scripts"
742             RUN_SCRIPTS_ONLY="yes"
743             shift;
744             ;;
745         -pseudo) Log "  - pseudo install"
746             RUN_SCRIPTS="no"
747             REMOVE_LINKS="yes"
748             CLEAN_DAEMONS="no"
749             shift;
750             ;; 
751         -nocompress) Log "  - do not compress tarball"
752             COMPRESS_TARBALL="no"
753             shift;
754             ;;
755         -lang) Log "  - load localized filesets"
756             shift;
757             [ $# -ne 0 ] || {
758                 USAGE
759                 exit 1;
760             }
761             theLang=$1
762             shift;
763             ;;
764         -configureOnly) Log "  - Configure only"
765             CONFIGURE_ONLY="yes"
766             CLEAN_DAEMONS="yes"
767             shift;
768             ;;
769         *) Log "  - unknown option"
770             USAGE
771             exit 1;
772             ;;
773         esac
774   done
775
776   echo ""
777
778   if [ -z "$BUILD_TREE" -a -z "$TAR_TREE" ]
779   then
780     USAGE
781     exit 1
782   fi
783
784   if [ "$BUILD_TREE" != "" -a ! -d "$BUILD_TREE" ]
785   then
786     Log "Build tree does not exist."
787     exit 1
788   fi
789
790   if [ "$TAR_TREE" != "" -a ! -d "$TAR_TREE" ]
791   then
792     Log "Tar tree does not exist."
793     exit 1
794   fi
795
796   CDEPACKAGE=dt.pkg
797   CDETARFILE=dt.tar
798   CDETARFILEZ=dttar.Z
799   CDECONFIGDIR=config
800
801 XCOMM
802 XCOMM get the current time stamp if going to create a tarball
803 XCOMM
804
805   if [ $TARBALL = "yes" ]; 
806   then
807     set -- `/bin/date`
808     DATE=$2_$3_$4_$6
809   fi
810
811   if [ -z "$BUILD_TREE" -a ${0##STAR/} = INSTALL.CDE ]; then
812     typeset -u CDEPACKAGE
813     typeset -u CDETARFILE
814     typeset -u CDETARFILEZ
815     typeset -u CDECONFIGDIR
816   fi
817
818   TOOL_DIR=$BUILD_TREE/admin/IntegTools/dbTools
819   if [ "$USE_RELATIVE" = "yes" ]
820   then
821     POST_INSTALL_DIR=../post_install
822   else
823     if [ -z "$BUILD_TREE" ]
824     then
825       POST_INSTALL_DIR=$TAR_TREE/$CDECONFIGDIR
826     else
827       POST_INSTALL_DIR=$BUILD_TREE/admin/IntegTools/post_install
828     fi
829   fi
830
831   if [ "$USE_ALTERNATE_UDB_DIR" = "yes" ]
832   then
833     DATABASE_DIR=$ALTERNATE_UDB_DIR/databases
834   else
835     DATABASE_DIR=$BUILD_TREE/databases
836   fi
837
838   if [ "$DATABASE_FILES" = "" ]
839   then
840     if [ "$DEVELOP_ENV" = "yes" ]
841     then
842       DATABASE_FILES="CDE-HELP-PRG CDE-PRG CDE-INC CDE-DEMOS \
843                       CDE-MAN-DEV CDE-SHLIBS"
844     elif [ "$RUNTIME_ENV" = "yes" ]
845     then
846       DATABASE_FILES="CDE-RUN CDE-MIN CDE-TT CDE-MAN CDE-HELP-RUN CDE-C \
847                       CDE-HELP-C CDE-MSG-C CDE-SHLIBS CDE-ICONS CDE-FONTS \
848                       CDE-INFO CDE-INFOLIB-C"
849     else
850       DATABASE_FILES="CDE-RUN CDE-MIN CDE-TT CDE-MAN CDE-HELP-RUN CDE-C \
851                       CDE-MSG-C CDE-HELP-C CDE-SHLIBS CDE-HELP-PRG \
852                       CDE-PRG CDE-INC CDE-DEMOS CDE-MAN-DEV CDE-ICONS \
853                       CDE-FONTS CDE-INFO CDE-INFOLIB-C"
854     fi
855
856     HASH now load any localized filesets
857     if [ "$DEVELOP_ENV" != "yes" ]
858     then
859       if [ "$theLang" != "" ]
860       then
861         DATABASE_FILES="$DATABASE_FILES CDE-$theLang CDE-MSG-$theLang \
862                         CDE-HELP-$theLang"
863       else
864         HASH load all current (working) languages
865         DATABASE_FILES="$DATABASE_FILES \
866                                         CDE-DE \
867                                         CDE-MSG-DE \
868                                         CDE-HELP-DE \
869                                         CDE-ES \
870                                         CDE-MSG-ES \
871                                         CDE-HELP-ES \
872                                         CDE-FR \
873                                         CDE-MSG-FR \
874                                         CDE-HELP-FR \
875                                         CDE-IT \
876                                         CDE-MSG-IT \
877                                         CDE-HELP-IT "
878       fi
879     fi
880   fi
881
882   [ -z "$INSTALL_LOCATION" ] && INSTALL_LOCATION=CDE_INSTALLATION_TOP
883   [ -z "$CONFIGURE_LOCATION" ] && CONFIGURE_LOCATION=CDE_CONFIGURATION_TOP
884   [ -z "$LOGFILES_LOCATION" ] && LOGFILES_LOCATION=CDE_LOGFILES_TOP
885
886   if [ -L $INSTALL_LOCATION -a "$CONFIGURE_ONLY" != "yes" ]
887   then
888     touch $INSTALL_LOCATION/foo >/dev/null 2>/dev/null
889     if [ ! -f $INSTALL_LOCATION/foo ]
890     then
891       Log "Insufficient permissions to install CDE files in $INSTALL_LOCATION"
892       exit 1
893     fi
894     if [ ! -O $INSTALL_LOCATION/foo ]
895     then
896       Log "Root access to $INSTALL_LOCATION is required for CDE installation."
897       exit 1
898     fi
899     rm $INSTALL_LOCATION/foo
900   fi
901
902   if [ -d $INSTALL_LOCATION ]
903   then
904     if [ -x $INSTALL_LOCATION/bin -a ! -d $INSTALL_LOCATION/bin ]
905     then
906         rm -f $INSTALL_LOCATION/bin
907     fi
908   fi
909
910   if [ "$CONFIGURE_ONLY" = "yes" ]
911   then
912     CheckForActualLocations
913     DoScripts
914     Log "Configuration completed."
915     exit 0
916   fi
917
918   if [ "$RUN_SCRIPTS_ONLY" = "yes" ]
919   then
920     DoScripts
921     exit 0
922   fi
923
924   CheckForActualLocations
925
926   if [ "$DO_LINK_STEP_ONLY" = "yes" ]
927   then
928     exit 0
929   fi
930
931   if [ "$CREATE_PACKING_LIST" = "yes" ]
932   then
933     CreatePackingList
934     exit 0
935   fi
936
937 XCOMM
938 XCOMM we are ready to load the environment ...
939 XCOMM
940
941   if [ "$BUILD_TREE" != "" ]
942   then
943     Log "Load the Desktop from $BUILD_TREE"
944
945     cd $STARTING_DIR
946     let j=1
947     for i in `echo $DATABASE_FILES`
948     do
949       LoadFileSet "$j" "$i"
950       let j=j+1
951     done
952   else
953     Log "Load the Desktop from $TAR_TREE"
954     compressed=$(awk '/COMPRESSED: /{print $2}' $TAR_TREE/$CDEPACKAGE)
955     if [ "$compressed" = "yes" ]; then
956       uncompress <$TAR_TREE/$CDETARFILEZ | tar xvf - $INSTALL_LOCATION
957     else
958       tar -xvf $TAR_TREE/$CDETARFILE $INSTALL_LOCATION
959     fi 
960     DATABASE_FILES=$(awk 'BEGIN {FS=":"} /FILESETS: /{print $2}' $TAR_TREE/$CDEPACKAGE)
961   fi
962
963   Log " "
964   Log "Desktop installed in $INSTALL_LOCATION"
965
966   if [ "$DO_INSTALL_ONLY" = "yes" ]
967   then
968     exit 0
969   fi
970
971   if [ $TARBALL = "yes" ]; 
972   then
973     MakeTarball
974   fi
975
976   cd $STARTING_DIR
977
978   if [ "$RUN_SCRIPTS" = "yes" ]
979   then
980     DoScripts
981   fi
982   
983   if [ "$REMOVE_LINKS" = "yes" ]
984   then
985     [ -L /usr/dt ] && rm /usr/dt
986     [ -L /etc/dt ] && rm /etc/dt
987     [ -L /var/dt ] && rm /var/dt
988   fi
989
990   echo "Done."
991   echo ""
992   echo "See $LOGFILE for a log of this install session."
993   echo ""