Allow building on FreeBSD
[oweals/cde.git] / cde / admin / IntegTools / install.dt.usl.src
1 XCOMM $XConsortium: install.dt.usl.src /main/4 1996/04/23 11:19:27 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_SV -a "$(uname -r)" = 4.2 ]
108   then
109         if [ "$(uname -v)" = 1.0 ]
110         then
111                 DtiReturn \
112 "WARNING: THE CDE DESKTOP IS NOT SUPPORTED ON UnixWare 1.0"
113         else
114                 HASH for all 4.2 releases after 1.0
115                 DtiReturn "yes"
116         fi
117   else
118         DtiReturn "ERROR: THIS IS NOT A \"UNIX_SV 4.2\" SYSTEM"
119   fi
120 }
121
122 XCOMM ==========================================================================
123 XCOMM
124 XCOMM DtiWhoami
125 XCOMM
126 XCOMM The default DtiWhoami() uses the 'whoami' command to determine
127 XCOMM the user name. If this platform does not have the 'whoami' command,
128 XCOMM declare DtiWhoami() here with the appropriate functionality.
129 XCOMM
130 XCOMM Input - none
131 XCOMM Output - none
132 XCOMM Return
133 XCOMM   result of system 'whoami' command
134 XCOMM
135 XCOMM ==========================================================================
136
137 DtiWhoami()
138 {
139   /usr/ucb/whoami
140 }
141
142 XCOMM ==========================================================================
143 XCOMM
144 XCOMM DtiPrint - echo to stderr and log
145 XCOMM
146 XCOMM Input 
147 XCOMM   $1 - data to echo to stdout and log
148 XCOMM Output - none
149 XCOMM Return -none
150 XCOMM
151 XCOMM Override on UnixWare because of printf "%s" integer-const problem
152 XCOMM This coordinates with the leading blank in the passing of " $meg" in master.
153 XCOMM ==========================================================================
154
155 DtiPrint()
156 {
157   if [ "$#" -gt 1 ]
158   then
159         if [ "$#" -gt 5 ]
160         then
161                 printf "$1" "$2" "$3" "$4" "$5" "$6" $7 $8 $9 >&2
162         else
163                 if [ "$#" -gt 4 ]
164                 then
165                         printf "$1" "$2" "$3" "$4" "$5" $6 $7 $8 $9 >&2
166                 else
167                         printf "$1" "$2" $3 $4 $5 $6 $7 $8 $9 >&2
168                 fi
169         fi
170   else
171         printf "$1" $2 $3 $4 $5 $6 $7 $8 $9 >&2
172   fi
173   Log "$1" $2 $3 $4 $5 $6 $7 $8 $9
174 }