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