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