updated to remove some msys refs.
[feisty_meow.git] / scripts / core / variables.sh
1 #!/bin/bash
2
3 ##############
4
5 # variables script:
6 #   Defines the environment variables used by the personalized unix
7 #   environment.
8 # Author: Chris Koeritz
9
10 ##############
11
12 if [ ! -z "$SHELL_DEBUG" ]; then echo variables initialization begins...; fi
13
14 ##############
15
16 # start with some simpler things.
17
18 export SCRIPT_SYSTEM=feisty_meow
19
20 # OS variable records the operating system we think we found.
21 if [ -z "$OS" ]; then
22   export OS=UNIX
23 fi
24 export IS_DARWIN=$(echo $OSTYPE | grep -i darwin)
25
26 ##############
27
28 # windoze sometimes needs a special home variable setup.
29 if [ "$OS" == "Windows_NT" ]; then
30   # give them a default place if they don't have one already.
31   if [ -z "$HOME" ]; then
32     export HOME=c:/home
33   fi
34   # patch home to undo cygwin style of drive letter.
35 #  export HOME=$(echo $HOME | sed -e 's/\/cygdrive\//\//g')
36   # make the home folder if it doesn't exist yet.
37   if [ ! -d $HOME ]; then
38     mkdir $HOME
39   fi
40   if [ ! -z "$SHELL_DEBUG" ]; then echo HOME is now $HOME; fi
41 fi
42
43 ##############
44
45 # fallbacks to set crucial variables for feisty meow...
46
47 # set the main root directory variable for the feisty meow codebase.
48 # this is only used for extreme failure modes, when the values were not
49 # pulled in from our auto-generated config.
50 if [ -z "$FEISTY_MEOW_DIR" ]; then
51   if [ -d "$HOME/feisty_meow" ]; then
52     export FEISTY_MEOW_DIR="$HOME/feisty_meow"
53     export FEISTY_MEOW_SCRIPTS="$FEISTY_MEOW_DIR/scripts"
54   fi
55 fi
56
57 # similarly, make sure we have someplace to look for our generated files, if
58 # we were not handed a value.
59 if [ -z "$FEISTY_MEOW_GENERATED" ]; then
60   # The generated scripts directory is where automatically generated files live.
61   # It is separate from the main body of the shell scripts in order to keep things from
62   # exploding.
63   export FEISTY_MEOW_GENERATED=$HOME/.zz_auto_gen
64 fi
65
66 ##############
67
68 # umask sets a permission mask for all file creations.  the mask used here
69 # disallows writing by the "group" and "others" categories.
70 umask 022
71 # ulimit sets user limits.  we set the maximum allowed core dump file size
72 # to zero, because it is obnoxious to see the core dumps from crashed
73 # programs lying around everywhere.
74 ulimit -c 0
75
76 ##############
77
78 # include helpful functions.
79 source "$FEISTY_MEOW_SCRIPTS/core/functions.sh"
80
81 ##############
82
83 # user variables, sort of...  if they haven't given themselves a name yet,
84 # then we will make one up for them.
85
86 # define a default name, if one wasn't already set.
87 if [ -z "$NAME" ]; then
88   export NAME='Unset Q. Namington, Fixley Your Name III'
89 fi
90
91 ##############
92
93 # sets the main prompt to a simple default, with user@host.
94 export PS1='\u@\h $ ';
95
96 ##############
97
98 # variables for perl.
99
100 export PERLLIB
101 if [ "$OS" != "Windows_NT" ]; then
102   PERLLIB+="/usr/lib/perl5"
103 else
104   export PERLIO=:perlio
105     # choose perl's IO over the ms-windows version so we can handle file
106     # bytes properly.
107 fi
108
109 # iterate across our sub-directories and find the perl scripts.
110 # this currently only looks one level down.
111 for i in $FEISTY_MEOW_SCRIPTS/*; do
112   if [ -d "$i" ]; then
113     # check if there is a perl file present; add the folder to PERLLIB if so.
114     ls $i/*.pl &>/dev/null
115     if [ $? -eq 0 ]; then
116       PERLLIB+=":$i"
117     fi
118   fi
119 done
120 #echo PERLLIB is now $PERLLIB
121
122 ##############
123
124 # set this so nechung can find its data.
125 export NECHUNG=$FEISTY_MEOW_DIR/database/fortunes.dat
126
127 # ensure we use the right kind of rsh for security.
128 export CVS_RSH=ssh
129
130 # sets the history length and max file size so we can get some long history around here.
131 HISTSIZE=1000000
132 HISTFILESIZE=2000000
133
134 # the base checkout list is just to update feisty_meow.  additional folder
135 # names can be added in your customized scripts.
136 export REPOSITORY_LIST="feisty_meow"
137
138 # set the editor for subversion if it hasn't already been set.
139 if [ -z "$SVN_EDITOR" ]; then
140 #hmmm: not sure what original reason for having these different was...
141   if [ "$OS"  == "Windows_NT" ]; then
142     export SVN_EDITOR=$(which gvim)
143   else
144     export SVN_EDITOR=$(which vi)
145   fi
146 fi
147
148 # initializes the feisty meow build variables, if possible.
149 function initialize_build_variables()
150 {
151   found_build_vars=0
152   # we need to know the feisty meow directory, or we bail.
153   if [ -z "$FEISTY_MEOW_DIR" ]; then return; fi
154   # pick from our expected generator folder, but make sure it's there...
155   buildvars="$FEISTY_MEOW_DIR/scripts/generator/build_variables.sh"
156   if [ -f "$buildvars" ]; then
157     # yep, that one looks good, so pull in the build defs.
158     source "$buildvars" "$buildvars"
159     found_build_vars=1
160   fi
161   # now augment the environment if we found our build variables.
162   if [ $found_build_vars == 1 ]; then
163     # the binary directory contains handy programs we use a lot in yeti.  we set up the path to it
164     # here based on the operating system.
165     # note that yeti has recently become more dependent on hoople.  hoople was always the source of
166     # the binaries, but now we don't ship them with yeti any more as pre-built items.  this reduces
167     # the size of the code package a lot and shortens up our possible exposure to compromised
168     # binaries.  people can bootstrap up their own set from hoople now instead.
169     export BINDIR=$FEISTY_MEOW_DIR/production/binaries
170
171     # add binaries created within build to the path.
172 #    export PATH="$(dos_to_msys_path $BUILD_TOP/build/bin):$PATH"
173     export PATH="$BUILD_TOP/build/bin:$PATH"
174
175     # Shared libraries are located via this variable.
176 #    export LD_LIBRARY_PATH="$(dos_to_msys_path $LD_LIBRARY_PATH):$(dos_to_msys_path $BINDIR)"
177     export LD_LIBRARY_PATH="$LD_LIBRARY_PATH:$BINDIR"
178   fi
179 }
180
181 # load in the build environment.
182 initialize_build_variables
183
184 ##############
185
186 # windoze specific patching up missing things.
187
188 if [ "$OS" == "Windows_NT" ]; then
189   export HOSTNAME=$(echo $HOSTNAME | tr A-Z a-z)
190 fi
191
192 ##############
193
194 # pull in the custom overrides for feisty_meow scripts.  this is done last,
195 # because we want to set everything up as expected, then let the user
196 # override individual variables and definitions.
197 for i in $FEISTY_MEOW_GENERATED/custom/*.sh; do
198   if [ ! -f "$i" ]; then
199     # skip it if it's not real.
200     continue;
201   fi
202   if [ ! -z "$SHELL_DEBUG" ]; then
203     echo "loading customization: $(basename $(dirname $i))/$(basename $i)"
204   fi
205   source $i
206 done
207
208 ##############
209
210 # set the path for locating applications.  this is done after any
211 # potential overrides from the user.
212 #export PATH="$(dos_to_msys_path $BINDIR):$(dos_to_msys_path $FEISTY_MEOW_GENERATED):$PATH:/bin:/sbin:/usr/sbin:/usr/local/bin:/usr/local/lib:/usr/games:/usr/bin:."
213 export PATH="$BINDIR:$FEISTY_MEOW_GENERATED:$PATH:/bin:/sbin:/usr/sbin:/usr/local/bin:/usr/local/lib:/usr/games:/usr/bin:."
214
215 ##############
216
217 if [ ! -z "$SHELL_DEBUG" ]; then echo variables initialization ends....; fi
218