Allow building on FreeBSD
[oweals/cde.git] / cde / admin / IntegTools / install.dt.uxp.src
1 XCOMM $XConsortium: install.dt.uxp.src /main/4 1996/11/19 11:44:17 drk $
2 XCOMM ==========================================================================
3 XCOMM ==========================================================================
4 XCOMM install.dt.usl
5 XCOMM
6 XCOMM   Platform specific function overrides for the April 1994 Snapshot
7 XCOMM   install script, install.dt. 
8 XCOMM
9 XCOMM   This file is sourced by the install.dt script to allow platform
10 XCOMM   specific behavior for certain functionality. These functions are:
11 XCOMM
12 XCOMM   DtiClearScreen() - clear the screen
13 XCOMM   DtiFreeSpace() - return available bytes in a directory
14 XCOMM   DtiVerifyConfiguration() - verify system configuration
15 XCOMM   DtiWhoami() - return user name
16 XCOMM
17 XCOMM ==========================================================================
18 #define HASH #
19
20 XCOMM ==========================================================================
21 XCOMM
22 XCOMM DtiClearScreen() - clears the screen
23 XCOMM
24 XCOMM The default DtiClearScreen() uses the 'clear' command to clear the
25 XCOMM screen. If this platform does not have the 'clear' command, 
26 XCOMM declare DtiClearScreen() here with the appropriate functionality.
27 XCOMM
28 XCOMM Note: The default DtiClearScreen() writes to stderr, rather than stdout,
29 XCOMM so be sure to do the same here. DtiPrint() does this automatically, so
30 XCOMM use it if possible.
31 XCOMM 
32 XCOMM Example:
33 XCOMM
34 XCOMM DtiClearScreen()
35 XCOMM {
36 XCOMM   DtiPrint "\n\n\n\n\n\n\n\n\n\n\n\n\n\n\n\n\n\n\n\n"
37 XCOMM   DtiPrint "\n\n\n\n\n\n\n\n\n\n\n\n\n\n\n\n\n\n\n\n"
38 XCOMM }
39 XCOMM
40 XCOMM Input - none
41 XCOMM Output - none
42 XCOMM Return -none
43 XCOMM
44 XCOMM USL uses the default (clear).  We'll define it here to ensure usage.
45 XCOMM ==========================================================================
46
47 DtiClearScreen() {
48   clear 1>&2
49 }
50
51 XCOMM ==========================================================================
52 XCOMM
53 XCOMM DtiFreeSpace
54 XCOMM
55 XCOMM The default DtiFreeSpace() does not check for free space, rather it
56 XCOMM simply returns a BigNumber that install.dt will assume is large 
57 XCOMM enough in which to install the desktop. 
58 XCOMM
59 XCOMM Declare DtiFreeSpace() here to return the actual available space for
60 XCOMM a particular directory.
61 XCOMM
62 XCOMM The $1 parameter will contain the directory name to test. The directory 
63 XCOMM specified will exist. DtiFreeSpace() should return the number of bytes
64 XCOMM available via the DtiReturn() function. 
65 XCOMM
66 XCOMM Input
67 XCOMM   $1 - directory name
68 XCOMM Output - none
69 XCOMM Return
70 XCOMM   number of bytes available
71 XCOMM
72 XCOMM ==========================================================================
73
74 DtiFreeSpace()
75 {
76   blocks="$(df "$1" | sed 's/^.*://' | awk '{print $1}')"
77   case "$blocks" in
78   [0-9]*)       let blocks=blocks*512
79                 DtiReturn "$blocks" ;;
80   *)            DtiReturn "0" ;;        # install.dt warn and confirm
81   esac
82 }
83
84 XCOMM ==========================================================================
85 XCOMM
86 XCOMM DtiVerifyConfiguration
87 XCOMM
88 XCOMM The default DtiVerifyConfiguration() does no system configuration 
89 XCOMM testing. For a particular platform, one might want to test for
90 XCOMM the presence of X11R5 or the OS version, for example, before allowing
91 XCOMM the desktop to be installed.
92 XCOMM
93 XCOMM Declare this function to make such platform specific tests. Return
94 XCOMM "yes" if the system passed, or "<message text>" if the system failed
95 XCOMM in which case install.dt will display the <message text> as the reason.
96 XCOMM
97 XCOMM Input - none
98 XCOMM Output - none
99 XCOMM Return 
100 XCOMM   "yes" - system configuration verified
101 XCOMM   "<message text>" - verification failed, display message text
102 XCOMM
103 XCOMM ==========================================================================
104
105 DtiVerifyConfiguration()
106 {
107   if [ "$(uname -s)" = UNIX_System_V  -a "$(uname -r)" = 4.2.0 ]
108   then
109         DtiReturn "yes"
110         
111     HASH if [ "$(uname -v)" = 1.0 ]
112     HASH then
113     HASH  DtiReturn "WARNING: THE CDE DESKTOP IS NOT SUPPORTED ON UnixWare 1.0"
114     HASH else
115     HASH  for all 4.2 releases after 1.0
116     HASH    DtiReturn "yes"
117     HASH fi
118   else
119         DtiReturn "ERROR: THIS IS NOT A \"UNIX_System_V 4.2.0\" SYSTEM"
120   fi
121 }
122
123 XCOMM ==========================================================================
124 XCOMM
125 XCOMM DtiWhoami
126 XCOMM
127 XCOMM The default DtiWhoami() uses the 'whoami' command to determine
128 XCOMM the user name. If this platform does not have the 'whoami' command,
129 XCOMM declare DtiWhoami() here with the appropriate functionality.
130 XCOMM
131 XCOMM Input - none
132 XCOMM Output - none
133 XCOMM Return
134 XCOMM   result of system 'whoami' command
135 XCOMM
136 XCOMM ==========================================================================
137
138 DtiWhoami()
139 {
140   /usr/ucb/whoami
141 }
142
143 XCOMM ==========================================================================
144 XCOMM
145 XCOMM DtiPrint - echo to stderr and log
146 XCOMM
147 XCOMM Input 
148 XCOMM   $1 - data to echo to stdout and log
149 XCOMM Output - none
150 XCOMM Return -none
151 XCOMM
152 XCOMM Override on UnixWare because of printf "%s" integer-const problem
153 XCOMM This coordinates with the leading blank in the passing of " $meg" in master.
154 XCOMM ==========================================================================
155
156 DtiPrint()
157 {
158   if [ "$#" -gt 1 ]
159   then
160         if [ "$#" -gt 5 ]
161         then
162                 printf "$1" "$2" "$3" "$4" "$5" "$6" $7 $8 $9 >&2
163         else
164                 if [ "$#" -gt 4 ]
165                 then
166                         printf "$1" "$2" "$3" "$4" "$5" $6 $7 $8 $9 >&2
167                 else
168                         printf "$1" "$2" $3 $4 $5 $6 $7 $8 $9 >&2
169                 fi
170         fi
171   else
172         printf "$1" $2 $3 $4 $5 $6 $7 $8 $9 >&2
173   fi
174   Log "$1" $2 $3 $4 $5 $6 $7 $8 $9
175 }