From 6f6cc76fec8dbdeeebff1b877304de4655475586 Mon Sep 17 00:00:00 2001 From: Chris Koeritz Date: Tue, 21 Feb 2012 22:19:50 -0500 Subject: [PATCH] leaner and not so much meaner. --- scripts/core/functions.sh | 376 ++++++++++++++------------- scripts/core/launch_feisty_meow.sh | 61 +++-- scripts/core/variables.sh | 404 +++++++++++++++-------------- 3 files changed, 433 insertions(+), 408 deletions(-) diff --git a/scripts/core/functions.sh b/scripts/core/functions.sh index 3e7b0c8a..d25e71d7 100644 --- a/scripts/core/functions.sh +++ b/scripts/core/functions.sh @@ -2,197 +2,213 @@ # This defines some general, useful functions. -if [ ! -z "$SHELL_DEBUG" ]; then - echo function definitions begin... +# test whether we've been here before or not. +skip_all= +date_stringer &>/dev/null +if [ $? -eq 0 ]; then + # there was no error, so we can skip the inits. +# if [ ! -z "$SHELL_DEBUG" ]; then + echo skipping functions.sh because already defined. +# fi fi -# a handy little method that can be used for date strings. it was getting -# really tiresome how many different ways the script did the date formatting. -function date_stringer() { - date +"%Y_%m_%e_%H%M_%S" | tr -d '/\n/' -} +echo proceeding to run functions.sh -# makes a directory of the name specified and then tries to change the -# current directory to that directory. -function mcd() { - if [ ! -d "$1" ]; then mkdir -p "$1"; fi - cd "$1" -} +if [ -z "$skip_all" ]; then -# locates a process given a search pattern to match in the process list. -function psfind() { - PID_DUMP="$(mktemp "$TMP/zz_pidlist.XXXXXX")" - appropriate_pattern='s/^[-a-zA-Z_0-9][-a-zA-Z_0-9]* *\([0-9][0-9]*\).*$/\1/p' - # pattern to use for peeling off the process numbers. - extra_flags= - # flags to pass to ps if any special ones are needed. - if [ "$OS" = "Windows_NT" ]; then - # on win32, there is some weirdness to support msys. - appropriate_pattern='s/^[ ]*\([0-9][0-9]*\).*$/\1/p' - extra_flags=-W + if [ ! -z "$SHELL_DEBUG" ]; then + echo function definitions begin... fi - /bin/ps $extra_flags wuax >$PID_DUMP - # remove the first line of the file, search for the pattern the - # user wants to find, and just pluck the process ids out of the - # results. - PIDS_SOUGHT=$(cat $PID_DUMP \ - | sed -e '1d' \ - | grep -i "$1" \ - | sed -n -e "$appropriate_pattern") - if [ ! -z "$PIDS_SOUGHT" ]; then echo "$PIDS_SOUGHT"; fi - /bin/rm $PID_DUMP -} - -# finds all processes matching the pattern specified and shows their full -# process listing (whereas psfind just lists process ids). -function psa() { - p=$(psfind "$1") - if [ ! -z "$p" ]; then - echo "" - echo "Processes containing \"$1\"..." - echo "" - if [ -n "$IS_DARWIN" ]; then - unset fuzil_sentinel - for i in $p; do - # only print the header the first time. - if [ -z "$fuzil_sentinel" ]; then - ps $i -w -u + + # a handy little method that can be used for date strings. it was getting + # really tiresome how many different ways the script did the date formatting. + function date_stringer() { + date +"%Y_%m_%e_%H%M_%S" | tr -d '/\n/' + } + + # makes a directory of the name specified and then tries to change the + # current directory to that directory. + function mcd() { + if [ ! -d "$1" ]; then mkdir -p "$1"; fi + cd "$1" + } + + # locates a process given a search pattern to match in the process list. + function psfind() { + PID_DUMP="$(mktemp "$TMP/zz_pidlist.XXXXXX")" + appropriate_pattern='s/^[-a-zA-Z_0-9][-a-zA-Z_0-9]* *\([0-9][0-9]*\).*$/\1/p' + # pattern to use for peeling off the process numbers. + extra_flags= + # flags to pass to ps if any special ones are needed. + if [ "$OS" = "Windows_NT" ]; then + # on win32, there is some weirdness to support msys. + appropriate_pattern='s/^[ ]*\([0-9][0-9]*\).*$/\1/p' + extra_flags=-W + fi + /bin/ps $extra_flags wuax >$PID_DUMP + # remove the first line of the file, search for the pattern the + # user wants to find, and just pluck the process ids out of the + # results. + PIDS_SOUGHT=$(cat $PID_DUMP \ + | sed -e '1d' \ + | grep -i "$1" \ + | sed -n -e "$appropriate_pattern") + if [ ! -z "$PIDS_SOUGHT" ]; then echo "$PIDS_SOUGHT"; fi + /bin/rm $PID_DUMP + } + + # finds all processes matching the pattern specified and shows their full + # process listing (whereas psfind just lists process ids). + function psa() { + p=$(psfind "$1") + if [ ! -z "$p" ]; then + echo "" + echo "Processes containing \"$1\"..." + echo "" + if [ -n "$IS_DARWIN" ]; then + unset fuzil_sentinel + for i in $p; do + # only print the header the first time. + if [ -z "$fuzil_sentinel" ]; then + ps $i -w -u + else + ps $i -w -u | sed -e '1d' + fi + fuzil_sentinel=true + done + else + # cases besides darwin OS (for macs). + extra_flags= + if [ "$OS" = "Windows_NT" ]; then + # special case for windows. + extra_flags=-W + ps | head -1 + for curr in $p; do + ps $extra_flags | grep "^ *$curr" + done else - ps $i -w -u | sed -e '1d' + # normal OSes can handle a nice simple query. + ps wu $p fi - fuzil_sentinel=true - done - else - # cases besides darwin OS (for macs). - extra_flags= - if [ "$OS" = "Windows_NT" ]; then - # special case for windows. - extra_flags=-W - ps | head -1 - for curr in $p; do - ps $extra_flags | grep "^ *$curr" - done - else - # normal OSes can handle a nice simple query. - ps wu $p fi fi - fi -} - -# an unfortunately similarly named function to the above 'ps' as in process -# methods, but this 'ps' stands for postscript. this takes a postscript file -# and converts it into pcl3 printer language and then ships it to the printer. -# this mostly makes sense for an environment where one's default printer is -# pcl. if the input postscript causes ghostscript to bomb out, there has been -# some good success running ps2ps on the input file and using the cleaned -# postscript file for printing. -function ps2pcl2lpr() { - for $i in $*; do - gs -sDEVICE=pcl3 -sOutputFile=- -sPAPERSIZE=letter "$i" | lpr -l - done -} - -function fix_alsa() { - sudo /etc/init.d/alsasound restart -} - -# switches from a /X/path form to an X:/ form. -function msys_to_dos_path() { - # we always remove dos slashes in favor of forward slashes. - echo "$1" | sed -e 's/\\/\//g' | sed -e 's/\/\([a-zA-Z]\)\/\(.*\)/\1:\/\2/' -} - -# switches from an X:/ form to an /X/path form. -function dos_to_msys_path() { - # we always remove dos slashes in favor of forward slashes. - echo "$1" | sed -e 's/\\/\//g' | sed -e 's/\([a-zA-Z]\):\/\(.*\)/\/\1\/\2/' -} - -# su function: makes su perform a login. -# for some OSes, this transfers the X authority information to the new login. -function su() { - # decide if we think this is debian or ubuntu or a variant. - DEBIAN_LIKE=$(if [ ! -z "$(grep -i debian /etc/issue)" \ - -o ! -z "$(grep -i ubuntu /etc/issue)" ]; then echo 1; else echo 0; fi) - - if [ $DEBIAN_LIKE -eq 1 ]; then - # debian currently requires the full version which imports X authority - # information for su. - - # get the x authority info for our current user. - source $FEISTY_MEOW_SCRIPTS/x_win/get_x_auth.sh - - if [ -z "$X_auth_info" ]; then - # if there's no authentication info to pass along, we just do a normal su. - /bin/su -l $* + } + + # an unfortunately similarly named function to the above 'ps' as in process + # methods, but this 'ps' stands for postscript. this takes a postscript file + # and converts it into pcl3 printer language and then ships it to the printer. + # this mostly makes sense for an environment where one's default printer is + # pcl. if the input postscript causes ghostscript to bomb out, there has been + # some good success running ps2ps on the input file and using the cleaned + # postscript file for printing. + function ps2pcl2lpr() { + for $i in $*; do + gs -sDEVICE=pcl3 -sOutputFile=- -sPAPERSIZE=letter "$i" | lpr -l + done + } + + function fix_alsa() { + sudo /etc/init.d/alsasound restart + } + + # switches from a /X/path form to an X:/ form. + function msys_to_dos_path() { + # we always remove dos slashes in favor of forward slashes. + echo "$1" | sed -e 's/\\/\//g' | sed -e 's/\/\([a-zA-Z]\)\/\(.*\)/\1:\/\2/' + } + + # switches from an X:/ form to an /X/path form. + function dos_to_msys_path() { + # we always remove dos slashes in favor of forward slashes. + echo "$1" | sed -e 's/\\/\//g' | sed -e 's/\([a-zA-Z]\):\/\(.*\)/\/\1\/\2/' + } + + # su function: makes su perform a login. + # for some OSes, this transfers the X authority information to the new login. + function su() { + # decide if we think this is debian or ubuntu or a variant. + DEBIAN_LIKE=$(if [ ! -z "$(grep -i debian /etc/issue)" \ + -o ! -z "$(grep -i ubuntu /etc/issue)" ]; then echo 1; else echo 0; fi) + + if [ $DEBIAN_LIKE -eq 1 ]; then + # debian currently requires the full version which imports X authority + # information for su. + + # get the x authority info for our current user. + source $FEISTY_MEOW_SCRIPTS/x_win/get_x_auth.sh + + if [ -z "$X_auth_info" ]; then + # if there's no authentication info to pass along, we just do a normal su. + /bin/su -l $* + else + # under X, we update the new login's authority info with the previous + # user's info. + (unset XAUTHORITY; /bin/su -l $* -c "$X_auth_info ; export DISPLAY=$DISPLAY ; bash") + fi else - # under X, we update the new login's authority info with the previous - # user's info. - (unset XAUTHORITY; /bin/su -l $* -c "$X_auth_info ; export DISPLAY=$DISPLAY ; bash") + # non-debian supposedly doesn't need the extra overhead any more. + # or at least suse doesn't, which is the other one we've tested on. + /bin/su -l $* fi - else - # non-debian supposedly doesn't need the extra overhead any more. - # or at least suse doesn't, which is the other one we've tested on. - /bin/su -l $* - fi - - # relabel the console after returning. - bash $FEISTY_MEOW_SCRIPTS/tty/label_terminal_with_infos.sh -} - -# sudo function wraps the normal sudo by ensuring we replace the terminal -# label if they're doing an su with the sudo. -function sudo() { - local first_command="$1" - /usr/bin/sudo $* - if [ "$first_command" == "su" ]; then - # yep, they were doing an su, but they're back now. + + # relabel the console after returning. bash $FEISTY_MEOW_SCRIPTS/tty/label_terminal_with_infos.sh - fi -} - -# buntar is a long needed uncompressing macro that feeds into tar -x. -# it takes a list of bz2 file names and extracts their contents into -# sequentially numbered directories. -function buntar() { - index=1 - for i in $*; do - mkdir buntar_$index - pushd buntar_$index &>/dev/null - file=$i - # if the filename has no directory component, we will assume it used to - # be above our unzipping directory here. - if [ "$(basename $file)" = $file ]; then - file=../$file + } + + # sudo function wraps the normal sudo by ensuring we replace the terminal + # label if they're doing an su with the sudo. + function sudo() { + local first_command="$1" + /usr/bin/sudo $* + if [ "$first_command" == "su" ]; then + # yep, they were doing an su, but they're back now. + bash $FEISTY_MEOW_SCRIPTS/tty/label_terminal_with_infos.sh fi - bunzip2 -d -c $file | tar -xf - - popd &>/dev/null - index=$(expr $index + 1) - done -} - -# trashes the .#blah files that cvs and svn leave behind when finding conflicts. -# this kind of assumes you've already checked them for any salient facts. -function clean_cvs_junk() { - for i in $*; do - find $i -follow -type f -iname ".#*" -exec perl $FEISTY_MEOW_SCRIPTS/files/safedel.pl {} ";" - done -} - -# recreates all the generated files that the feisty meow scripts use. -function regenerate() { - bash $FEISTY_MEOW_SCRIPTS/core/bootstrap_shells.sh - echo - local wheres_nechung=$(which nechung 2>/dev/null) - if [ -z "$wheres_nechung" ]; then - echo "The nechung oracle program cannot be found. You may want to consider" - echo "rebuilding the feisty meow applications with this command:" - echo " bash $FEISTY_MEOW_DIR/scripts/generator/bootstrap_build.sh" - else - nechung - fi -} - -if [ ! -z "$SHELL_DEBUG" ]; then echo function definitions end....; fi + } + + # buntar is a long needed uncompressing macro that feeds into tar -x. + # it takes a list of bz2 file names and extracts their contents into + # sequentially numbered directories. + function buntar() { + index=1 + for i in $*; do + mkdir buntar_$index + pushd buntar_$index &>/dev/null + file=$i + # if the filename has no directory component, we will assume it used to + # be above our unzipping directory here. + if [ "$(basename $file)" = $file ]; then + file=../$file + fi + bunzip2 -d -c $file | tar -xf - + popd &>/dev/null + index=$(expr $index + 1) + done + } + + # trashes the .#blah files that cvs and svn leave behind when finding conflicts. + # this kind of assumes you've already checked them for any salient facts. + function clean_cvs_junk() { + for i in $*; do + find $i -follow -type f -iname ".#*" -exec perl $FEISTY_MEOW_SCRIPTS/files/safedel.pl {} ";" + done + } + + # recreates all the generated files that the feisty meow scripts use. + function regenerate() { + bash $FEISTY_MEOW_SCRIPTS/core/bootstrap_shells.sh + echo + local wheres_nechung=$(which nechung 2>/dev/null) + if [ -z "$wheres_nechung" ]; then + echo "The nechung oracle program cannot be found. You may want to consider" + echo "rebuilding the feisty meow applications with this command:" + echo " bash $FEISTY_MEOW_DIR/scripts/generator/bootstrap_build.sh" + else + nechung + fi + } + + if [ ! -z "$SHELL_DEBUG" ]; then echo function definitions end....; fi + +fi diff --git a/scripts/core/launch_feisty_meow.sh b/scripts/core/launch_feisty_meow.sh index ad9a12c0..26b61511 100644 --- a/scripts/core/launch_feisty_meow.sh +++ b/scripts/core/launch_feisty_meow.sh @@ -16,46 +16,43 @@ ############## -# FEISTY_MEOW_GENERATED is where the generated files yeti uses are located. -# this is our single entry point we can use without knowing any variables -# yet in the initialization process. -export FEISTY_MEOW_GENERATED="$HOME/.zz_auto_gen" - -# make sure our main variables are established. -GENERATED_FEISTY_MEOW_VARIABLES="$FEISTY_MEOW_GENERATED/fmc_variables.sh" -if [ ! -f "$GENERATED_FEISTY_MEOW_VARIABLES" ]; then - echo -e '\n\n' - echo "The yeti scripts need to be initialized via the bootstrap process, e.g.:" - echo " bash $HOME/feisty_meow/scripts/core/bootstrap_shells.sh" - echo -e '\n\n' -fi - -############## +if [ -z "$FEISTY_MEOW_GENERATED" ]; then + # FEISTY_MEOW_GENERATED is where the generated files yeti uses are located. + # this is our single entry point we can use without knowing any variables + # yet in the initialization process. + export FEISTY_MEOW_GENERATED="$HOME/.zz_auto_gen" +#hmmm: the above is kind of a constant. that's not so great. + + # make sure our main variables are established. + GENERATED_FEISTY_MEOW_VARIABLES="$FEISTY_MEOW_GENERATED/fmc_variables.sh" + if [ ! -f "$GENERATED_FEISTY_MEOW_VARIABLES" ]; then + echo -e '\n\n' + echo "The yeti scripts need to be initialized via the bootstrap process, e.g.:" + echo " bash $HOME/feisty_meow/scripts/core/bootstrap_shells.sh" + echo -e '\n\n' + fi -# pull in our generated variables that are the minimal set we need to find -# the rest of our resources. -source "$GENERATED_FEISTY_MEOW_VARIABLES" + ############## -############## + # pull in our generated variables that are the minimal set we need to find + # the rest of our resources. + source "$GENERATED_FEISTY_MEOW_VARIABLES" -# load all the standard feisty meow variables into the environment. -source $FEISTY_MEOW_SCRIPTS/core/variables.sh + # Set up the temporary directory. + source $FEISTY_MEOW_SCRIPTS/core/create_tempdir.sh -# Set up the temporary directory. -source $FEISTY_MEOW_SCRIPTS/core/create_tempdir.sh + ############## -############## + # load the larger body of standard feisty meow variables into the environment. + source $FEISTY_MEOW_SCRIPTS/core/variables.sh -# check if this is dos/windows. -if [ "$OS" == "Windows_NT" ]; then - if [ -z "$HOME" ]; then - # set a default that might not be appropriate for everyone, but should - # still work. - export HOME=c:/home - fi - if [ ! -d "$HOME" ]; then mkdir $HOME; fi fi +# check hash table before searching path. +shopt -s checkhash +# don't check path for sourced files. +shopt -u sourcepath + ############## if [ -z "$LIGHTWEIGHT_INIT" ]; then diff --git a/scripts/core/variables.sh b/scripts/core/variables.sh index c339ca00..f56af98d 100644 --- a/scripts/core/variables.sh +++ b/scripts/core/variables.sh @@ -9,210 +9,222 @@ ############## -if [ ! -z "$SHELL_DEBUG" ]; then echo variables initialization begins...; fi - -############## - -# start with some simpler things. - -export SCRIPT_SYSTEM=feisty_meow - -# OS variable records the operating system we think we found. -if [ -z "$OS" ]; then - export OS=UNIX -fi -export IS_DARWIN=$(echo $OSTYPE | grep -i darwin) - -############## - -# windoze sometimes needs a special home variable setup. -if [ "$OS" == "Windows_NT" ]; then - # give them a default place if they don't have one already. - if [ -z "$HOME" ]; then - export HOME=c:/home - fi - # patch home to undo cygwin style of drive letter. -# export HOME=$(echo $HOME | sed -e 's/\/cygdrive\//\//g') - # make the home folder if it doesn't exist yet. - if [ ! -d $HOME ]; then - mkdir $HOME +# we'll run this again only if we think it's needed. +if [ -z "$NECHUNG" ]; then + + if [ ! -z "$SHELL_DEBUG" ]; then echo variables initialization begins...; fi + + ############## + + # start with some simpler things. + + export SCRIPT_SYSTEM=feisty_meow + + # OS variable records the operating system we think we found. + if [ -z "$OS" ]; then + export OS=UNIX fi - if [ ! -z "$SHELL_DEBUG" ]; then echo HOME is now $HOME; fi -fi - -############## - -# fallbacks to set crucial variables for feisty meow... - -# set the main root directory variable for the feisty meow codebase. -# this is only used for extreme failure modes, when the values were not -# pulled in from our auto-generated config. -if [ -z "$FEISTY_MEOW_DIR" ]; then - if [ -d "$HOME/feisty_meow" ]; then - export FEISTY_MEOW_DIR="$HOME/feisty_meow" - export FEISTY_MEOW_SCRIPTS="$FEISTY_MEOW_DIR/scripts" + export IS_DARWIN=$(echo $OSTYPE | grep -i darwin) + + ############## + + # windoze sometimes needs a special home variable setup. + if [ "$OS" == "Windows_NT" ]; then + # give them a default place if they don't have one already. + if [ -z "$HOME" ]; then + export HOME=c:/home + fi + # patch home to undo cygwin style of drive letter. + # export HOME=$(echo $HOME | sed -e 's/\/cygdrive\//\//g') + # make the home folder if it doesn't exist yet. + if [ ! -d $HOME ]; then + mkdir $HOME + fi + if [ ! -z "$SHELL_DEBUG" ]; then echo HOME is now $HOME; fi fi -fi - -# similarly, make sure we have someplace to look for our generated files, if -# we were not handed a value. -if [ -z "$FEISTY_MEOW_GENERATED" ]; then - # The generated scripts directory is where automatically generated files live. - # It is separate from the main body of the shell scripts in order to keep things from - # exploding. - export FEISTY_MEOW_GENERATED=$HOME/.zz_auto_gen -fi - -############## - -# umask sets a permission mask for all file creations. the mask used here -# disallows writing by the "group" and "others" categories. -umask 022 -# ulimit sets user limits. we set the maximum allowed core dump file size -# to zero, because it is obnoxious to see the core dumps from crashed -# programs lying around everywhere. -ulimit -c 0 - -############## - -# include helpful functions. -source "$FEISTY_MEOW_SCRIPTS/core/functions.sh" - -############## - -# user variables, sort of... if they haven't given themselves a name yet, -# then we will make one up for them. - -# define a default name, if one wasn't already set. -if [ -z "$NAME" ]; then - export NAME='Unset Q. Namington, Fixley Your Name III' -fi - -############## - -# sets the main prompt to a simple default, with user@host. -export PS1='\u@\h $ '; - -############## - -# variables for perl. - -export PERLLIB -if [ "$OS" != "Windows_NT" ]; then - PERLLIB+="/usr/lib/perl5" -else - export PERLIO=:perlio - # choose perl's IO over the ms-windows version so we can handle file - # bytes properly. -fi - -# iterate across our sub-directories and find the perl scripts. -# this currently only looks one level down. -for i in $FEISTY_MEOW_SCRIPTS/*; do - if [ -d "$i" ]; then - # check if there is a perl file present; add the folder to PERLLIB if so. - ls $i/*.pl &>/dev/null - if [ $? -eq 0 ]; then - PERLLIB+=":$i" + + ############## + + # fallbacks to set crucial variables for feisty meow... + + # set the main root directory variable for the feisty meow codebase. + # this is only used for extreme failure modes, when the values were not + # pulled in from our auto-generated config. + if [ -z "$FEISTY_MEOW_DIR" ]; then + if [ -d "$HOME/feisty_meow" ]; then + export FEISTY_MEOW_DIR="$HOME/feisty_meow" + export FEISTY_MEOW_SCRIPTS="$FEISTY_MEOW_DIR/scripts" fi fi -done -#echo PERLLIB is now $PERLLIB - -############## - -# set this so nechung can find its data. -export NECHUNG=$FEISTY_MEOW_DIR/database/fortunes.dat - -# ensure we use the right kind of rsh for security. -export CVS_RSH=ssh - -# sets the history length and max file size so we can get some long history around here. -HISTSIZE=1000000 -HISTFILESIZE=2000000 - -# the base checkout list is just to update feisty_meow. additional folder -# names can be added in your customized scripts. -export REPOSITORY_LIST="feisty_meow" - -# set the editor for subversion if it hasn't already been set. -if [ -z "$SVN_EDITOR" ]; then -#hmmm: not sure what original reason for having these different was... - if [ "$OS" == "Windows_NT" ]; then - export SVN_EDITOR=$(which gvim) - else - export SVN_EDITOR=$(which vi) + + # similarly, make sure we have someplace to look for our generated files, if + # we were not handed a value. + if [ -z "$FEISTY_MEOW_GENERATED" ]; then + # The generated scripts directory is where automatically generated files live. + # It is separate from the main body of the shell scripts in order to keep things from + # exploding. + export FEISTY_MEOW_GENERATED=$HOME/.zz_auto_gen fi -fi - -# initializes the feisty meow build variables, if possible. -function initialize_build_variables() -{ - found_build_vars=0 - # we need to know the feisty meow directory, or we bail. - if [ -z "$FEISTY_MEOW_DIR" ]; then return; fi - # pick from our expected generator folder, but make sure it's there... - buildvars="$FEISTY_MEOW_DIR/scripts/generator/build_variables.sh" - if [ -f "$buildvars" ]; then - # yep, that one looks good, so pull in the build defs. - source "$buildvars" "$buildvars" - found_build_vars=1 + + ############## + + # umask sets a permission mask for all file creations. the mask used here + # disallows writing by the "group" and "others" categories. + umask 022 + # ulimit sets user limits. we set the maximum allowed core dump file size + # to zero, because it is obnoxious to see the core dumps from crashed + # programs lying around everywhere. + ulimit -c 0 + + ############## + + # include helpful functions. + source "$FEISTY_MEOW_SCRIPTS/core/functions.sh" + + ############## + + # user variables, sort of... if they haven't given themselves a name yet, + # then we will make one up for them. + + # define a default name, if one wasn't already set. + if [ -z "$NAME" ]; then + export NAME='Unset Q. Namington, Fixley Your Name III' fi - # now augment the environment if we found our build variables. - if [ $found_build_vars == 1 ]; then - # the binary directory contains handy programs we use a lot in yeti. we set up the path to it - # here based on the operating system. - # note that yeti has recently become more dependent on hoople. hoople was always the source of - # the binaries, but now we don't ship them with yeti any more as pre-built items. this reduces - # the size of the code package a lot and shortens up our possible exposure to compromised - # binaries. people can bootstrap up their own set from hoople now instead. - export BINDIR=$FEISTY_MEOW_DIR/production/binaries - - # add binaries created within build to the path. -# export PATH="$(dos_to_msys_path $BUILD_TOP/build/bin):$PATH" - export PATH="$BUILD_TOP/build/bin:$PATH" - - # Shared libraries are located via this variable. -# export LD_LIBRARY_PATH="$(dos_to_msys_path $LD_LIBRARY_PATH):$(dos_to_msys_path $BINDIR)" - export LD_LIBRARY_PATH="$LD_LIBRARY_PATH:$BINDIR" + + ############## + + # sets the main prompt to a simple default, with user@host. + export PS1='\u@\h $ '; + + ############## + + # variables for perl. + + export PERLLIB + if [ "$OS" != "Windows_NT" ]; then + PERLLIB+="/usr/lib/perl5" + else + export PERLIO=:perlio + # choose perl's IO over the ms-windows version so we can handle file + # bytes properly. fi -} - -# load in the build environment. -initialize_build_variables - -############## - -# windoze specific patching up missing things. - -if [ "$OS" == "Windows_NT" ]; then - export HOSTNAME=$(echo $HOSTNAME | tr A-Z a-z) -fi - -############## - -# pull in the custom overrides for feisty_meow scripts. this is done last, -# because we want to set everything up as expected, then let the user -# override individual variables and definitions. -for i in $FEISTY_MEOW_GENERATED/custom/*.sh; do - if [ ! -f "$i" ]; then - # skip it if it's not real. - continue; + + # iterate across our sub-directories and find the perl scripts. + # this currently only looks one level down. + for i in $FEISTY_MEOW_SCRIPTS/*; do + if [ -d "$i" ]; then + # check if there is a perl file present; add the folder to PERLLIB if so. + ls $i/*.pl &>/dev/null + if [ $? -eq 0 ]; then + PERLLIB+=":$i" + fi + fi + done + #echo PERLLIB is now $PERLLIB + + ############## + + # set this so nechung can find its data. + export NECHUNG=$FEISTY_MEOW_DIR/database/fortunes.dat + + # ensure we use the right kind of rsh for security. + export CVS_RSH=ssh + + # sets the history length and max file size so we can get some long history around here. + HISTSIZE=1000000 + HISTFILESIZE=2000000 + + # the base checkout list is just to update feisty_meow. additional folder + # names can be added in your customized scripts. + export REPOSITORY_LIST="feisty_meow" + + # set the editor for subversion if it hasn't already been set. + if [ -z "$SVN_EDITOR" ]; then + #hmmm: not sure what original reason for having these different was... + if [ "$OS" == "Windows_NT" ]; then + export SVN_EDITOR=$(which gvim) + else + export SVN_EDITOR=$(which vi) + fi fi - if [ ! -z "$SHELL_DEBUG" ]; then - echo "loading customization: $(basename $(dirname $i))/$(basename $i)" + + # initializes the feisty meow build variables, if possible. + function initialize_build_variables() + { + found_build_vars=0 + # we need to know the feisty meow directory, or we bail. + if [ -z "$FEISTY_MEOW_DIR" ]; then return; fi + # pick from our expected generator folder, but make sure it's there... + buildvars="$FEISTY_MEOW_DIR/scripts/generator/build_variables.sh" + if [ -f "$buildvars" ]; then + # yep, that one looks good, so pull in the build defs. + source "$buildvars" "$buildvars" + found_build_vars=1 + fi + # now augment the environment if we found our build variables. + if [ $found_build_vars == 1 ]; then + # the binary directory contains handy programs we use a lot in yeti. we set up the path to it + # here based on the operating system. + # note that yeti has recently become more dependent on hoople. hoople was always the source of + # the binaries, but now we don't ship them with yeti any more as pre-built items. this reduces + # the size of the code package a lot and shortens up our possible exposure to compromised + # binaries. people can bootstrap up their own set from hoople now instead. + export BINDIR=$FEISTY_MEOW_DIR/production/binaries + + # add binaries created within build to the path. + # export PATH="$(dos_to_msys_path $BUILD_TOP/build/bin):$PATH" + export PATH="$BUILD_TOP/build/bin:$PATH" + + # Shared libraries are located via this variable. + # export LD_LIBRARY_PATH="$(dos_to_msys_path $LD_LIBRARY_PATH):$(dos_to_msys_path $BINDIR)" + export LD_LIBRARY_PATH="$LD_LIBRARY_PATH:$BINDIR" + fi + } + + # load in the build environment. + initialize_build_variables + + ############## + + # windoze specific patching up missing things. + + if [ "$OS" == "Windows_NT" ]; then + export HOSTNAME=$(echo $HOSTNAME | tr A-Z a-z) fi - source $i -done - -############## - -# set the path for locating applications. this is done after any -# potential overrides from the user. -#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:." -export PATH="$BINDIR:$FEISTY_MEOW_GENERATED:$PATH:/bin:/sbin:/usr/sbin:/usr/local/bin:/usr/local/lib:/usr/games:/usr/bin:." - -############## + + ############## + + # pull in the custom overrides for feisty_meow scripts. this is done last, + # because we want to set everything up as expected, then let the user + # override individual variables and definitions. + for i in $FEISTY_MEOW_GENERATED/custom/*.sh; do + if [ ! -f "$i" ]; then + # skip it if it's not real. + continue; + fi + if [ ! -z "$SHELL_DEBUG" ]; then + echo "loading customization: $(basename $(dirname $i))/$(basename $i)" + fi + source $i + done + + ############## + + # set the path for locating applications. this is done after any + # potential overrides from the user. + #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:." + export PATH="$BINDIR:$FEISTY_MEOW_GENERATED:$PATH:/bin:/sbin:/usr/sbin:/usr/local/bin:/usr/local/lib:/usr/games:/usr/bin:." + + ############## + + if [ ! -z "$SHELL_DEBUG" ]; then echo variables initialization ends....; fi -if [ ! -z "$SHELL_DEBUG" ]; then echo variables initialization ends....; fi +else + # we are seeing this lot again, we believe, so make things easier for the + # rest of initialization. + export LIGHTWEIGHT_INIT=true + if [ ! -z "$SHELL_DEBUG" ]; then + echo skipped var init and put in lightweight mode due to belief in previous existence.; +fi +fi -- 2.34.1