6 # Defines the environment variables used by the personalized unix
8 # Author: Chris Koeritz
12 #hmmm: moved from functions.sh; does that hose everything up?
14 # defines a variable within the feisty meow environment and remembers that
15 # this is a new or modified definition. if the feisty meow codebase is
16 # unloaded, then so are all the variables that were defined.
17 # this function always exports the variables it defines.
18 function define_yeti_variable()
20 # if variable exists already, save old value for restore,
21 # otherwise save null value for restore,
22 # have to handle unsetting if there was no prior value of one
24 # add variable name to a list of feisty defined variables.
26 #hmmm: first implem just sets it up and exports the variable.
27 # i.e., this method always exports.
37 # this section should always run or bash will reset them on us.
38 # these need to be as minimal as possible.
40 # sets the main prompt to a simple default, with user@host.
41 define_yeti_variable PS1='\u@\h $ ';
42 # sets the history length and max file size so we can get some long history around here.
43 define_yeti_variable HISTSIZE=1000000
44 define_yeti_variable HISTFILESIZE=8000000
46 # make the TERM available to all sub-shells.
47 define_yeti_variable TERM
51 # we'll run this again only if we think it's needed.
52 if [ -z "$NECHUNG" ]; then
54 if [ ! -z "$SHELL_DEBUG" ]; then echo variables initialization begins...; fi
58 # start with some simpler things.
60 define_yeti_variable SCRIPT_SYSTEM=feisty_meow
62 # OS variable records the operating system we think we found.
64 define_yeti_variable OS=UNIX
66 define_yeti_variable IS_DARWIN=$(echo $OSTYPE | grep -i darwin)
70 # guess the current platform.
71 IS_UNIX=$(uname | grep -i linux)
72 if [ -z "$IS_UNIX" ]; then IS_UNIX=$(uname | grep -i unix); fi
73 if [ -z "$IS_UNIX" ]; then IS_UNIX=$(uname | grep -i darwin); fi
74 IS_DOS=$(uname | grep -i ming)
75 if [ -z "$IS_DOS" ]; then IS_DOS=$(uname | grep -i cygwin); fi
77 # now if we're stuck in DOS, try to determine the type of system.
78 if [ ! -z "$IS_DOS" ]; then
79 # IS_MSYS will be non-empty if this is the msys toolset. otherwise
80 # we assume that it's cygwin.
81 IS_MSYS=$(uname | grep -i ming)
86 # fallbacks to set crucial variables for feisty meow...
88 # set the main root directory variable for the feisty meow codebase.
89 # this is only used for extreme failure modes, when the values were not
90 # pulled in from our auto-generated config.
91 if [ -z "$FEISTY_MEOW_APEX" ]; then
92 if [ -d "$HOME/feisty_meow" ]; then
93 define_yeti_variable FEISTY_MEOW_APEX="$HOME/feisty_meow"
94 define_yeti_variable FEISTY_MEOW_SCRIPTS="$FEISTY_MEOW_SCRIPTS"
98 # main declaration of the transients area.
99 if [ -z "$TMP" ]; then
100 define_yeti_variable TMP=$HOME/.tmp
103 # set up the top-level for all build creations and logs and such.
104 if [ -z "$GENERATED_DIR" ]; then
105 define_yeti_variable GENERATED_DIR="$TMP/generated-feisty_meow"
107 if [ ! -d "$GENERATED_DIR" ]; then
108 mkdir -p "$GENERATED_DIR"
110 # set up our effluent outsourcing valves.
111 if [ -z "$TEMPORARIES_DIR" ]; then
112 define_yeti_variable TEMPORARIES_DIR="$GENERATED_DIR/temporaries"
114 if [ ! -d "$TEMPORARIES_DIR" ]; then
115 mkdir -p "$TEMPORARIES_DIR"
118 # similarly, make sure we have someplace to look for our generated files, if
119 # we were not handed a value.
120 if [ -z "$FEISTY_MEOW_LOADING_DOCK" ]; then
121 # The generated scripts directory is where automatically generated files live.
122 # It is separate from the main body of the shell scripts in order to keep things from
124 define_yeti_variable FEISTY_MEOW_LOADING_DOCK=$HOME/.zz_feisty_loading
129 # umask sets a permission mask for all file creations.
130 # this mask disallows writes by "group" and "others".
132 # this mask disallows writes by the "group" and disallows "others" completely.
135 # ulimit sets user limits. we set the maximum allowed core dump file size
136 # to zero, because it is obnoxious to see the core dumps from crashed
137 # programs lying around everywhere.
142 # user variables, sort of... if they haven't given themselves a name yet,
143 # then we will make one up for them.
145 # define a default name, if one wasn't already set.
146 if [ -z "$NAME" ]; then
147 define_yeti_variable NAME='Unset Q. Namington, Fixley Your Name III'
152 # variables for perl.
154 define_yeti_variable PERLLIB+="/usr/lib/perl5"
155 if [ "$OS" == "Windows_NT" ]; then
156 define_yeti_variable PERLIO=:perlio
157 # choose perl's IO over the ms-windows version so we can handle file
161 # iterate across our sub-directories and find the perl scripts.
162 # this currently only looks one level down.
163 for i in $FEISTY_MEOW_SCRIPTS/*; do
165 # check if there is a perl file present; add the folder to PERLLIB if so.
166 ls $i/*.pl &>/dev/null
167 if [ $? -eq 0 ]; then
168 PERLLIB+=":$(dos_to_unix_path $i)"
172 #echo PERLLIB is now $PERLLIB
176 # set this so nechung can find its data.
177 define_yeti_variable NECHUNG=$FEISTY_MEOW_APEX/infobase/fortunes.dat
179 # ensure we use the right kind of secure shell.
180 # define_yeti_variable CVS_RSH=$FEISTY_MEOW_SCRIPTS/security/ssh.sh
181 # define_yeti_variable GIT_SSH=$FEISTY_MEOW_SCRIPTS/security/ssh.sh
183 # the base checkout list is just to update feisty_meow. additional folder
184 # names can be added in your customized scripts. the space at the end of
185 # this variable is important and allows users to extend the list like:
186 # define_yeti_variable REPOSITORY_DIR+="muppets configs"
187 define_yeti_variable REPOSITORY_LIST="feisty_meow "
189 # initializes the feisty meow build variables, if possible.
190 function initialize_build_variables()
193 # we need to know the feisty meow directory, or we bail.
194 if [ -z "$FEISTY_MEOW_APEX" ]; then return; fi
195 # pick from our expected generator folder, but make sure it's there...
196 buildvars="$FEISTY_MEOW_SCRIPTS/generator/build_variables.sh"
197 if [ -f "$buildvars" ]; then
198 # yep, that one looks good, so pull in the build defs.
199 source "$buildvars" "$buildvars"
202 # now augment the environment if we found our build variables.
203 if [ $found_build_vars == 1 ]; then
204 # the binary directory contains our collection of handy programs.
205 define_yeti_variable BINDIR=$TARGETS_DIR
206 # add binaries created within build to the path.
207 define_yeti_variable PATH="$(dos_to_unix_path $BINDIR):$PATH"
208 # Shared libraries are located via this variable.
209 define_yeti_variable LD_LIBRARY_PATH="$(dos_to_unix_path $LD_LIBRARY_PATH):$(dos_to_unix_path $BINDIR)"
215 # windoze specific patching up missing things.
217 if [ "$OS" == "Windows_NT" ]; then
218 define_yeti_variable HOSTNAME=$(echo $HOSTNAME | tr A-Z a-z)
223 # load in the build environment.
224 initialize_build_variables
228 # add to the PATH variables used for locating applications. this step is taken after any
229 # potential overrides from the user.
230 define_yeti_variable PATH="$(dos_to_unix_path $FEISTY_MEOW_LOADING_DOCK):$PATH:$(find /usr/local/games -maxdepth 1 -type d -exec echo -n {}: ';' 2>/dev/null)/sbin"
234 # set the SHUNIT_DIR so our shunit tests can find the codebase.
235 define_yeti_variable SHUNIT_DIR="$FEISTY_MEOW_SCRIPTS/shunit"
239 if [ ! -z "$SHELL_DEBUG" ]; then echo variables initialization ends....; fi
244 # pull in the custom overrides for feisty_meow scripts. this is done last,
245 # because we want to set everything up as expected, then let the user
246 # override individual variables and definitions. we also don't guard this
247 # to avoid running it again, because we don't know what mix of functions and
248 # aliases they want to define in there.
249 for i in $FEISTY_MEOW_LOADING_DOCK/custom/*.sh; do
250 if [ ! -f "$i" ]; then
251 # skip it if it's not real.
254 if [ ! -z "$SHELL_DEBUG" ]; then
255 echo "loading customization: $(basename $(dirname $i))/$(basename $i)"