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