Commits

Rob Williams  committed e490cd2

Added Linux infrastructure scripts

  • Participants
  • Parent commits be357d3

Comments (0)

Files changed (9)

File activate_Python_project.bash

 requireVariable BO_Home
 requireDirectory $BO_Home
 
+# Configure the Linux environment
+_Dir=$BO_Home/bin/Linux/helper
+requireDirectory ${_Dir}
+source ${_Dir}/declare.bash
+
+# Configure the Python environment
 _Dir=$BO_Home/bin/Python/helper
 requireDirectory ${_Dir}
-
 source ${_Dir}/configure_TMPDIR
 source ${_Dir}/configure_pip
 source ${_Dir}/configure_virtualenv

File bin/Linux/helper/color.bash

+#!/bin/bash
+# ----------------------------------------------------------------------------
+# This is ansi-color 0.6 from http://code.google.com/p/ansi-color/
+# ----------------------------------------------------------------------------
+# @file color
+# Color and format your shell script output with minimal effort.
+# Inspired by Moshe Jacobson <moshe@runslinux.net>
+# @author Alister Lewis-Bowen [alister@different.com]
+# ----------------------------------------------------------------------------
+# This software is distributed under the the MIT License.
+#
+# Copyright (c) 2008 Alister Lewis-Bowen
+#
+# Permission is hereby granted, free of charge, to any person obtaining a copy
+# of this software and associated documentation files (the "Software"), to deal
+# in the Software without restriction, including without limitation the rights
+# to use, copy, modify, merge, publish, distribute, sublicense, and/or sell
+# copies of the Software, and to permit persons to whom the Software is
+# furnished to do so, subject to the following conditions:
+#
+# The above copyright notice and this permission notice shall be included in
+# all copies or substantial portions of the Software.
+#
+# THE SOFTWARE IS PROVIDED "AS IS", WITHOUT WARRANTY OF ANY KIND, EXPRESS OR
+# IMPLIED, INCLUDING BUT NOT LIMITED TO THE WARRANTIES OF MERCHANTABILITY,
+# FITNESS FOR A PARTICULAR PURPOSE AND NONINFRINGEMENT. IN NO EVENT SHALL THE
+# AUTHORS OR COPYRIGHT HOLDERS BE LIABLE FOR ANY CLAIM, DAMAGES OR OTHER
+# LIABILITY, WHETHER IN AN ACTION OF CONTRACT, TORT OR OTHERWISE, ARISING FROM,
+# OUT OF OR IN CONNECTION WITH THE SOFTWARE OR THE USE OR OTHER DEALINGS IN
+# THE SOFTWARE.
+# ----------------------------------------------------------------------------
+
+COLORS=( black red green yellow blue magenta cyan white );
+NUM_COLORS=${#COLORS[@]};
+EFFECTS=( nm normal bd bold ft faint it italic ul underline bk blink fb fastblink rv reverse iv invisible );
+NUM_EFFECTS=${#EFFECTS[@]};
+
+# Function: Help
+# ----------------------------------------------------------------------------
+
+function help {
+	echo;
+	echo "$(color bd)Color and format your shell script output with minimal effort.$(color)";
+	echo;
+	echo 'Usage:';
+	echo "$(color bd)color$(color) [ $(color ul)effect$(color) ] [ [lt]$(color ul)fgcolor$(color) ] [ $(color ul)bgcolor$(color) ]";
+	echo "$(color bd)color$(color) list";
+	echo "$(color bd)color$(color) [ -h | --help ]";
+	echo;
+	echo 'where:';
+	echo -n "$(color ul)fgcolor$(color) and $(color ul)bgcolor$(color) are one of ";
+	for ((i=0;i<${NUM_COLORS};i++)); do
+		echo -n "$(color ${COLORS[${i}]})${COLORS[${i}]}$(color) ";
+	done;
+	echo;
+	echo -n "$(color ul)effect$(color) can be any of ";
+	for ((i=0;i<${NUM_EFFECTS};i++)); do
+		echo -n "$(color ${EFFECTS[${i}]})${EFFECTS[${i}]}$(color) ";
+	done;
+	echo;
+	echo "Preceed the $(color ul)fgcolor$(color) with $(color bd)lt$(color) to use a light color."
+	echo "$(color bd)color off$(color) or $(color bd)color$(color) resets to default colors and text effect.";
+	echo "$(color bd)color list$(color) displays all possible color combinations.";
+	echo;
+	echo 'Examples:';
+	echo '  echo "$(color ul)Underlined text$(color off)"';
+	echo 'results in:';
+	echo "  $(color ul)Underlined text$(color off)";
+	echo;
+	echo '  echo "Make $(color rv)this$(color nm) reverse video text$(color off)"';
+	echo 'results in:';
+	echo "  Make $(color rv)this$(color nm) reverse video text$(color off)";
+	echo;
+	echo '  echo "$(color white blue) White text on a blue background $(color)"';
+	echo 'results in:';
+	echo "  $(color white blue) White text on a blue background $(color)";
+	echo;
+	echo '  echo "$(color ltyellow green) lt prefix on the yellow text text $(color off)"';
+	echo 'results in:';
+	echo "  $(color ltyellow green) lt prefix on the yellow text text $(color off)";
+	echo;
+	echo '  echo "$(color bold blink red yellow) Blinking bold red text on a yellow background $(color)"';
+	echo 'results in:';
+	echo "  $(color bold blink red yellow) Blinking bold red text on a yellow background $(color)";
+	echo;
+	echo;
+	echo -n "Note that results may vary with these standard ANSI escape sequences because of the different configurations of terminal emulators. ";
+	echo;
+	exit 1;
+}
+
+# Function: List colors combinations
+# ----------------------------------------------------------------------------
+
+function list {
+
+	echo;
+	echo "$(color bd)These are the possible combinations of colors I can generate. ";
+	echo "$(color nm)Since terminal color settings vary, $(color ul)the expected output may vary$(color).";
+	echo;
+	
+	for ((bg=0;bg<${NUM_COLORS};bg++)); do
+		echo "${COLORS[${bg}]}:";
+			for ((fg=0;fg<${NUM_COLORS};fg++)); do
+				echo -n "$(color ${COLORS[${fg}]} ${COLORS[${bg}]}) ${COLORS[${fg}]} $(color) ";
+			done;
+			echo;
+		echo;
+	done;
+	
+	exit 1;
+}
+
+# Function: Test if color
+# ----------------------------------------------------------------------------
+
+function _isColor () {
+  if [ -n "$1" ]; then
+  	local normalize=${1#lt};
+	  for ((i=0;i<${NUM_COLORS};i++)); do
+	    if [ "$normalize" = ${COLORS[${i}]} ]; then return 1; fi;
+		done;
+	fi;
+	return 0;
+}
+
+# Function: Test if text effect
+# ----------------------------------------------------------------------------
+
+function _isEffect () {
+  if [ -n "$1" ]; then
+	  for ((i=0;i<${NUM_EFFECTS};i++)); do
+	    if [ "$1" = ${EFFECTS[${i}]} ]; then return 1; fi;
+		done;
+		if [ "$1" = off ]; then return 1; fi;
+	fi;
+	return 0;
+}
+
+# Function: Push code onto the escape sequence array
+# ----------------------------------------------------------------------------
+
+function _pushcode () { 
+	codes=("${codes[@]}" $1); 
+}
+
+# Parse input arguments
+# ----------------------------------------------------------------------------
+
+if [[ "$1" = '-h' || "$1" = '--help' ]]; then help; fi;
+if [ "$1" = list ];                      then list; fi;
+if [[ "$1" = off || -z "$1" ]];          then 
+	echo -en '\033[0m';
+	exit 0;
+fi;
+
+while (( "$#" )); do
+
+	_isColor $1;
+	if [ $? -eq 1 ]; then
+		if [ "$FG" = '' ]; then 
+			FG=$1;
+		else
+		  if [ "$BG" = '' ]; then
+		  	BG=$1;
+		  else
+		  	error="I see more than two colors. Type color -h for more information.";
+		  fi;
+		fi;
+	else
+		_isEffect $1;
+		if [ $? -eq 1 ]; then
+			TE=("${TE[@]}" $1);
+		else
+			error="I don't recognize '$1'. Type color -h for more information.";
+		fi;
+	fi;
+	
+	shift;
+	
+done;
+
+if [ "$error" != '' ]; then
+	echo $(color bold red)color: $error$(color); exit 1;
+fi;
+
+# Insert text effects into the escape sequence
+# ----------------------------------------------------------------------------
+
+for ((i=0;i<${#TE[@]};i++)); do
+
+	case "${TE[${i}]}" in
+		nm | normal )      _pushcode 0;;
+		bd | bold )        _pushcode 1;;
+		ft | faint )       _pushcode 2;;
+		it | italic )      _pushcode 3;;
+		ul | underline)    _pushcode 4;;
+		bl | blink)        _pushcode 5;;
+		fb | fastblink)    _pushcode 6;;
+		rv | reversevideo) _pushcode 7;;
+		iv | invisible)    _pushcode 8;;
+	esac;
+
+done;
+
+# Insert foreground colors into the escape sequence
+# ----------------------------------------------------------------------------
+
+if [ `expr "$FG" : 'lt'` -eq 2 ]; then _pushcode 2; fi;
+
+case "$FG" in
+	black)   _pushcode 30;;
+	red)     _pushcode 31;;
+	green)   _pushcode 32;;
+	yellow)  _pushcode 33;;
+	blue)    _pushcode 34;;
+	magenta) _pushcode 35;;
+	cyan)    _pushcode 36;;
+	white)   _pushcode 37;;
+esac;
+
+# Insert background colors into the escape sequence
+# ----------------------------------------------------------------------------
+
+case "$BG" in
+	black)   _pushcode 40;;
+	red)     _pushcode 41;;
+	green)   _pushcode 42;;
+	yellow)  _pushcode 43;;
+	blue)    _pushcode 44;;
+	magenta) _pushcode 45;;
+	cyan)    _pushcode 46;;
+	white)   _pushcode 47;;
+esac;
+
+# Assemble and echo the ANSI escape sequence
+# ----------------------------------------------------------------------------
+
+for ((i=0;i<${#codes[@]};i++)); do
+	if [ "$seq" != '' ]; then seq=$seq';'; fi;
+	seq=$seq${codes[${i}]};
+done;
+
+echo -en '\033['${seq}m;
+
+exit 0;

File bin/Linux/helper/declare-BASH.bash

+#!/bin/bash
+# Declare BASH functionality for BASH
+
+abort () {
+  # Abort BASH execution with message $3 and exit status $4
+  [[ "$#" -lt 2 ]] && Oops "$FUNCNAME" "$LINENO" && return 1
+  # $1 = name of script/function where call originated
+  # $2 = line in script where call originated
+  # $3 = optional message
+  # $4 = optional exit status
+
+  declare _Message="${3:-No message provided.}"
+  declare -i _Status="${4:-1}"
+  _logFatal "$1" "$2" "Aborting with status ${_Status}:  ${_Message}"
+  if [[ "$SHLVL" -eq 1 ]] ; then
+    logError "$1" "$2" 'At top level of BASH shell, NOT aborting!'
+    dumpBash "$FUNCNAME" "$LINENO"
+  else
+    exit ${_Status}
+  fi
+}
+
+abortIfMissing () {
+  # Abort with message $4 if value $3 is missing (resolves to null)
+  [[ "$#" -ne 4 ]] && Oops "$FUNCNAME" "$LINENO" && return 1
+  # $1 = name of script/function where call originated
+  # $2 = line in script where call originated
+  # $3 = value that is required
+  # $4 = message
+
+  [[ -z "$3" ]] && abort "$1" "$2" "$4"
+}
+
+abortOnFail () {
+  # Abort on failure of previous command reported as exit status $3
+  requireParameters "$FUNCNAME" "$LINENO" 3 "$#"
+  requireParameter  "$FUNCNAME" "$LINENO" "$1" 1 'script/function name'
+  requireParameter  "$FUNCNAME" "$LINENO" "$2" 2 'script line'
+  requireParameter  "$FUNCNAME" "$LINENO" "$3" 3 'previous command exit status'
+
+  logDebug "$FUNCNAME" "$LINENO" "Last command exited with status '$3'"
+  [[ "$3" -gt 0 ]] && abort "$1" "$2" "Command failed with exit status '$3'!"
+}
+
+dumpBash () {
+  # Dump BASH variables
+  [[ "$#" -ne 2 ]] && Oops "$FUNCNAME" "$LINENO" && return 1
+  # $1 = name of script/function where call originated
+  # $2 = line in script where call originated
+
+  logDebug "$1" "$2" 'Dumping BASH variables...'
+  trace "$1" "$2" BASH
+  trace "$1" "$2" BASH_ARGC
+  trace "$1" "$2" BASH_ARGV
+  trace "$1" "$2" BASH_COMMAND
+  trace "$1" "$2" BASH_ENV
+  trace "$1" "$2" BASH_EXECUTION_STRING
+  trace "$1" "$2" BASH_LINENO
+  trace "$1" "$2" BASH_REMATCH
+  trace "$1" "$2" BASH_SOURCE
+  trace "$1" "$2" BASH_SUBSHELL
+  trace "$1" "$2" BASH_VERSINFO[0]
+  trace "$1" "$2" BASH_VERSINFO[1]
+  trace "$1" "$2" BASH_VERSINFO[2]
+  trace "$1" "$2" BASH_VERSINFO[3]
+  trace "$1" "$2" BASH_VERSINFO[4]
+  trace "$1" "$2" BASH_VERSINFO[5]
+  trace "$1" "$2" BASH_VERSION
+  trace "$1" "$2" BASHPID
+  trace "$1" "$2" CDPATH
+  trace "$1" "$2" DIRSTACK
+  # trace "$1" "$2" EDITOR
+  trace "$1" "$2" EUID
+  trace "$1" "$2" FUNCNAME
+  trace "$1" "$2" GLOBIGNORE
+  trace "$1" "$2" GROUPS
+  # trace "$1" "$2" HOME
+  trace "$1" "$2" HOSTNAME
+  trace "$1" "$2" HOSTTYPE
+  trace "$1" "$2" IFS
+  trace "$1" "$2" IGNOREEOF
+  trace "$1" "$2" LC_COLLATE
+  trace "$1" "$2" LC_CTYPE
+  trace "$1" "$2" LINENO
+  trace "$1" "$2" MACHTYPE
+  trace "$1" "$2" OLDPWD
+  trace "$1" "$2" OSTYPE
+  # trace "$1" "$2" PATH
+  trace "$1" "$2" PIPESTATUS
+  trace "$1" "$2" PPID
+  trace "$1" "$2" PROMPT_COMMAND
+  trace "$1" "$2" PS1
+  trace "$1" "$2" PS2
+  trace "$1" "$2" PS3
+  trace "$1" "$2" PS4
+  trace "$1" "$2" PWD
+  trace "$1" "$2" REPLY
+  trace "$1" "$2" SECONDS
+  trace "$1" "$2" SHELL
+  trace "$1" "$2" SHELLOPTS
+  trace "$1" "$2" SHLVL
+  trace "$1" "$2" TMOUT
+  trace "$1" "$2" UID
+}
+
+requireParameter () {
+  # Require parameter passed as $1, indexed as $2, and described as $3;
+  # abort if missing
+  requireParameters "$FUNCNAME" "$LINENO" 5 "$#"
+  requireValue "$FUNCNAME" "$LINENO" "$1" 'script/function name'
+  requireValue "$FUNCNAME" "$LINENO" "$2" 'script line'
+  # $3 = actual parameter value (may be null)
+  requireValue "$FUNCNAME" "$LINENO" "$4" 'parameter index'
+  requireValue "$FUNCNAME" "$LINENO" "$5" 'description'
+
+  abortIfMissing "$1" "$2" "$3" "Missing parameter $4 = $5!"
+}
+
+requireParameters () {
+  # Require exactly $3 parameters to calling function/script
+  [[ "$#" -ne 4 ]] && Oops "$FUNCNAME" "$LINENO" && return 1
+  requireValue "$FUNCNAME" "$LINENO" "$1" 'script/function name'
+  requireValue "$FUNCNAME" "$LINENO" "$2" 'script line'
+  requireValue "$FUNCNAME" "$LINENO" "$3" 'required parameter count'
+  requireValue "$FUNCNAME" "$LINENO" "$4" 'actual parameter count (from $#)'
+
+  [[ "$4" -ne "$3" ]] && \
+    abort "$1" "$2" "'$4' parameters were passed when exactly '$3' are required!"
+}
+
+requireParametersAtLeast () {
+  # Require at least $3 parameters to calling function/script
+  requireParameters "$FUNCNAME" "$LINENO" 4 "$#"
+  requireValue "$FUNCNAME" "$LINENO" "$1" 'script/function name'
+  requireValue "$FUNCNAME" "$LINENO" "$2" 'script line'
+  requireValue "$FUNCNAME" "$LINENO" "$3" 'required parameter count'
+  requireValue "$FUNCNAME" "$LINENO" "$4" 'actual parameter count (from $#)'
+
+  [[ "$4" -lt "$3" ]] && \
+    abort "$1" "$2" "'$4' parameters were passed when at least '$3' are required!"
+}
+
+requireValue () {
+  # Require value $3 described as $4, abort if missing (resolves to null)
+  [[ "$#" -ne 4 ]] && Oops "$FUNCNAME" "$LINENO" && return 1
+  # $1 = name of script/function where call originated
+  # $2 = line in script where call originated
+  # $3 = value that is required
+  # $4 = description for value
+
+  abortIfMissing "$1" "$2" "$3" "Value for '$4' is missing (non-null)!"
+}
+
+requireVariable () {
+  # Require variable $3, abort if it is missing
+  requireParameters "$FUNCNAME" "$LINENO" 3 "$#"
+  requireParameter  "$FUNCNAME" "$LINENO" "$1" 1 'script/function name'
+  requireParameter  "$FUNCNAME" "$LINENO" "$2" 2 'script line'
+  requireParameter  "$FUNCNAME" "$LINENO" "$3" 3 'name of variable that is required'
+
+  declare _Name=$3
+  declare _Value="${!_Name}"
+  [[ -z "${_Value}" ]] && \
+    abort "$1" "$2" "Variable '$3' is required (defined and non-null)!"
+}
+

File bin/Linux/helper/declare-Hudson.bash

+#!/bin/bash
+# Declare BASH functionality for Hudson
+
+Hudson_findBuild() {
+  # Return whether found Hudson build for job $2, and save to file $1 if found
+  requireParameters "$FUNCNAME" "$LINENO" 2 "$#"
+  requireParameter  "$FUNCNAME" "$LINENO" "$1" 1 'build number file'
+  requireParameter  "$FUNCNAME" "$LINENO" "$2" 2 'Hudson URL'
+
+  logInfo "$FUNCNAME" "$LINENO" "Getting build number from '$2'..."
+  _Number=$(Hudson_getBuildNumber "$2")
+  Hudson_saveBuildNumber "$1" "${_Number}"
+}
+
+Hudson_getArtifact () {
+  # Get the Hudson build artifact from URL $1 as file $2
+  requireParameters "$FUNCNAME" "$LINENO" 2 "$#"
+  requireParameter  "$FUNCNAME" "$LINENO" "$1" 1 'artifact target file'
+  requireParameter  "$FUNCNAME" "$LINENO" "$2" 2 'artifact URL'
+
+  if fileExists "$1"; then
+    logWarn "$FUNCNAME" "$LINENO" "Artifact $1 already exists, skipping get!"
+  else
+    logInfo "$FUNCNAME" "$LINENO" "Getting artifact file '$1' from '$2'..."
+    curl -L# "$2" > "$1"
+    abortOnFail "$FUNCNAME" "$LINENO" "$?"
+    requireFile "$1"
+  fi
+}
+
+Hudson_getBuildNumber () {
+  # Return the Hudson build number for job $1
+  # NOTE:  Designed to return result via standard output
+  requireParameters "$FUNCNAME" "$LINENO" 1 "$#"
+  requireParameter  "$FUNCNAME" "$LINENO" "$1" 1 'Hudson job'
+
+  declare -r _Number=$(curl -Ls "$1")
+  abortOnFail "$FUNCNAME" "$LINENO" "$?"
+  echo "${_Number}"
+}
+
+Hudson_saveBuildNumber() {
+  # Save Hudson build number $2 to file $1
+  requireParameters "$FUNCNAME" "$LINENO" 2 "$#"
+  requireParameter  "$FUNCNAME" "$LINENO" "$1" 1 'target file'
+  requireParameter  "$FUNCNAME" "$LINENO" "$2" 2 'build number'
+
+  logInfo "$FUNCNAME" "$LINENO" "Saving build number '$2' in file '$1'..."
+  echo "$2" > "$1"
+  requireFile "$1"
+}
+

File bin/Linux/helper/declare-Mercurial.bash

+#!/bin/bash
+# Declare BASH functionality for Mercurial
+
+cloneMercurial () {
+  # Clone repository $1 to directory $2, but not if $2 exists
+  requireParameters "$FUNCNAME" "$LINENO" 2 "$#"
+  requireParameter  "$FUNCNAME" "$LINENO" "$1" 1 'target clone directory'
+  requireParameter  "$FUNCNAME" "$LINENO" "$2" 2 'Mercurial repository URL'
+
+  if directoryExists "$1" ; then
+    logWarn "$FUNCNAME" "$LINENO" "Directory '$1' exists, skipping clone of '$2'!"
+    return 1
+  else
+    logInfo "$FUNCNAME" "$LINENO" "Creating Mercurial clone '$1' from repository '$2'..."
+    hg clone "$2" "$1"
+    abortOnFail "$FUNCNAME" "$LINENO" "$?"
+    requireDirectory "$1"
+  fi
+}
+
+updateMercurial () {
+  # Update Mercurial clone $1 to branch $2
+  requireParameters "$FUNCNAME" "$LINENO" 2 "$#"
+  requireParameter  "$FUNCNAME" "$LINENO" "$1" 1 'target clone directory'
+  requireParameter  "$FUNCNAME" "$LINENO" "$2" 2 'Mercurial branch name'
+
+  requireDirectory "$1"
+  logInfo "$FUNCNAME" "$LINENO" "Updating Mercurial clone '$1' to branch '$2'..."
+  cd "$1"
+  hg update "$2"
+  abortOnFail "$FUNCNAME" "$LINENO" "$?"
+}
+

File bin/Linux/helper/declare-POSIX.bash

+#!/bin/bash
+# Declare BASH functionality for POSIX
+
+changeFileGroup () {
+  # Change ownership of file $2 to group $1
+  requireParameters "$FUNCNAME" "$LINENO" 2 "$#"
+  requireParameter  "$FUNCNAME" "$LINENO" "$1" 1 'group'
+  requireParameter  "$FUNCNAME" "$LINENO" "$2" 2 'target file'
+
+  # TODO:  Test existence of group $1
+  requireFile "$2"
+  logInfo "$FUNCNAME" "$LINENO" "Changing owner of file '$2' to group '$1'..."
+  chgrp "$1" "$2"
+  abortOnFail "$FUNCNAME" "$LINENO" "$?"
+}
+
+copyFile () {
+  # Copy source file $1 to target file $2, but not if it exists
+  requireParameters "$FUNCNAME" "$LINENO" 2 "$#"
+  requireParameter  "$FUNCNAME" "$LINENO" "$1" 1 'source file'
+  requireParameter  "$FUNCNAME" "$LINENO" "$2" 2 'target file'
+
+  requireFile "$1"
+  if fileExists "$2" ; then
+    logWarn "$FUNCNAME" "$LINENO" "File '$2' exists, skipping copy of file '$1'!"
+  else
+    logInfo "$FUNCNAME" "$LINENO" "Copying file '$2' from file '$1'..."
+    cp "$1" "$2"
+    abortOnFail "$FUNCNAME" "$LINENO" "$?"
+  fi
+  requireFile "$2"
+}
+
+copyFileForce () {
+  # Copy source file $1 to target file $2, EVEN if it exists
+  requireParameters "$FUNCNAME" "$LINENO" 2 "$#"
+  requireParameter  "$FUNCNAME" "$LINENO" "$1" 1 'source file'
+  requireParameter  "$FUNCNAME" "$LINENO" "$2" 2 'target file'
+
+  requireFile "$1"
+  if fileExists "$2" ; then
+    logWarn "$FUNCNAME" "$LINENO" "File '$2' exists, overwriting!"
+  fi
+  logInfo "$FUNCNAME" "$LINENO" "Copying file '$2' from file '$1'..."
+  cp "$1" "$2"
+  abortOnFail "$FUNCNAME" "$LINENO" "$?"
+  requireFile "$2"
+}
+
+copyFiles () {
+  # Copy all files in source directory $1 to target directory $2
+  requireParameters "$FUNCNAME" "$LINENO" 2 "$#"
+  requireParameter  "$FUNCNAME" "$LINENO" "$1" 1 'source directory'
+  requireParameter  "$FUNCNAME" "$LINENO" "$2" 2 'target directory'
+
+  requireDirectory "$1"
+  # if directoryExists "$2" ; then
+    logInfo "$FUNCNAME" "$LINENO" "Copying directory '$2' from directory '$1'..."
+    cp -R $1/* $2/
+    abortOnFail "$FUNCNAME" "$LINENO" "$?"
+  # fi
+  requireDirectory "$2"
+}
+
+createDirectory () {
+  # Create directory $1, but not if it exists
+  requireParameters "$FUNCNAME" "$LINENO" 1 "$#"
+  requireParameter  "$FUNCNAME" "$LINENO" "$1" 1 'target directory'
+
+  if directoryExists "$1" ; then
+    logWarn "$FUNCNAME" "$LINENO" "Directory '$1' exists, skipping creation!"
+  else
+    logInfo "$FUNCNAME" "$LINENO" "Creating directory '$1'..."
+    mkdir -p "$1"
+    abortOnFail "$FUNCNAME" "$LINENO" "$?"
+  fi
+  requireDirectory "$1"
+}
+
+directoryExists () {
+  # Return whether directory $1 exists, abort if it is not creatable
+  requireParameters "$FUNCNAME" "$LINENO" 1 "$#"
+  requireParameter  "$FUNCNAME" "$LINENO" "$1" 1 'target directory'
+
+  [[   -d "$1" ]] && \
+    logDebug "$FUNCNAME" "$LINENO" "Found directory '$1'" && \
+    return 0
+  [[   -e "$1" ]] && \
+    abort "$FUNCNAME" "$LINENO" "Found non-directory '$1'"
+  return 1 # $1 does not exist, but appears to be creatable
+}
+
+fileExists () {
+  # Return whether file $1 exists, abort if it is not creatable
+  requireParameters "$FUNCNAME" "$LINENO" 1 "$#"
+  requireParameter  "$FUNCNAME" "$LINENO" "$1" 1 'target file'
+
+  [[   -f "$1" ]] && \
+    logDebug "$FUNCNAME" "$LINENO" "Found file '$1'" && \
+    return 0
+  [[   -e "$1" ]] && \
+    abort "$FUNCNAME" "$LINENO" "Found non-file '$1'"
+  return 1 # $1 does not exist, but appears to be creatable
+}
+
+makeFilesExecutable () {
+  # Make the files executable within directory $1
+  requireParameters "$FUNCNAME" "$LINENO" 1 "$#"
+  requireParameter  "$FUNCNAME" "$LINENO" "$1" 1 'target directory'
+
+  requireDirectory "$1"
+  logInfo "$FUNCNAME" "$LINENO" "Making files executable in directory '$1'..."
+  chmod -R u+x "$1"
+  abortOnFail "$FUNCNAME" "$LINENO" "$?"
+}
+
+moveFile () {
+  # Move source file $1 to target file $2, but not if it exists
+  requireParameters "$FUNCNAME" "$LINENO" 2 "$#"
+  requireParameter  "$FUNCNAME" "$LINENO" "$1" 1 'source file'
+  requireParameter  "$FUNCNAME" "$LINENO" "$2" 2 'target file'
+
+  requireFile "$1"
+  if fileExists "$2" ; then
+    logWarn "$FUNCNAME" "$LINENO" "File '$2' exists, skipping move of file '$1'!"
+  else
+    logInfo "$FUNCNAME" "$LINENO" "Moving file '$2' from file '$1'..."
+    mv "$1" "$2"
+    abortOnFail "$FUNCNAME" "$LINENO" "$?"
+  fi
+  # TODO:  Check that file $1 is gone?
+  requireFile "$2"
+}
+
+requireDirectory () {
+  # Require that directory $1 exists, abort if not
+  requireParameters "$FUNCNAME" "$LINENO" 1 "$#"
+  requireParameter  "$FUNCNAME" "$LINENO" "$1" 1 'target directory'
+
+  directoryExists "$1" && return 0
+  abort "$FUNCNAME" "$LINENO" "Required directory '$1' must exist!"
+}
+
+requireFile () {
+  # Require that file $1 exists, abort if not
+  requireParameters "$FUNCNAME" "$LINENO" 1 "$#"
+  requireParameter  "$FUNCNAME" "$LINENO" "$1" 1 'target file'
+
+  fileExists "$1" && return 0
+  abort "$FUNCNAME" "$LINENO" "Required file '$1' must exist!"
+}
+
+: <<DISABLED
+  # NOTE:  Place content to be ignored in here.
+
+  # TODO:  Refactor & redesign
+
+directoryExists () {
+  # Verify that directory $1 exists
+  # $1 = pathname that should exist and be a directory
+  [[   -d "$1" ]] && logInfo  "Found directory $1"         && return 0
+  [[ ! -e "$1" ]] && logError "Pathname $1 does not exist" && return 1
+  [[   -e "$1" ]] && logError "Found non-directory $1"     && return 2
+  return 3
+}
+
+fileExists () {
+  # Verify that file $1 exists
+  # $1 = pathname that should exist and be a file
+  [[   -f "$1" ]] && logInfo  "Found file $1"              && return 0
+  [[ ! -e "$1" ]] && logError "Pathname $1 does not exist" && return 1
+  [[   -e "$1" ]] && logError "Found non-file $1"          && return 2
+  return 3
+}
+
+maybeCopyFile () {
+  # Copy file $1 to directory $2 as $3, but not if it exists
+  # $1 = pathname of source file
+  # $2 = name of target directory
+  # $3 = name of target file
+  [[   -f "$2/$3" ]] && logInfo  "Found file $2/$3"           && return 0
+  [[ ! -e "$1"    ]] && logError "Pathname $1 does not exist" && return 1
+  [[ ! -f "$1"    ]] && logError "Found non-file $1"          && return 2
+  maybeCreateDirectory "$2"
+  directoryExists "$2" && cp "$1" "$2/$3" && logInfo "Created $2/$3"
+}
+
+maybeCreateDirectory () {
+  # Create directory $1, but not if it exists
+  # $1 = pathname of directory to create
+  maybeDirectoryExists "$1" && return 0
+  pathnameNotExists "$1" && mkdir -p "$1" && logInfo "Created $1"
+  directoryExists "$1"
+}
+
+maybeDirectoryExists () {
+  # Return pathname $1 does not exist or is a directory
+  # $1 = pathname that could be a directory or not exist
+  [[ -d "$1" ]] && logInfo  "Found directory $1"     && return 0
+  [[ -e "$1" ]] && logError "Found non-directory $1" && return 2
+  logInfo "Pathname $1 does not exist"               && return 1
+}
+
+pathnameNotExists () {
+  # Verify that pathname $1 does not exist
+  # $1 = pathname that should not exist
+  [[ -e "$1" ]] && logError "Pathname $1 should not exist" && return 1
+  return 0
+}
+DISABLED
+

File bin/Linux/helper/declare-Subversion.bash

+#!/bin/bash
+# Declare BASH functionality for Subversion
+
+checkoutSubversion () {
+  # Checkout repository $1 to directory $2, but not if $2 exists
+  requireParameters "$FUNCNAME" "$LINENO" 2 "$#"
+  requireParameter  "$FUNCNAME" "$LINENO" "$1" 1 'target directory'
+  requireParameter  "$FUNCNAME" "$LINENO" "$2" 2 'Subversion URL'
+
+  if directoryExists "$1" ; then
+    logWarn "$FUNCNAME" "$LINENO" "Directory '$1' exists, skipping checkout of '$2'!"
+    return 1
+  else
+    logInfo "$FUNCNAME" "$LINENO" "Checking out '$1' from '$2'..."
+    svn checkout "$2" "$1"
+    abortOnFail "$FUNCNAME" "$LINENO" "$?"
+    requireDirectory "$1"
+  fi
+}
+

File bin/Linux/helper/declare-logging.bash

+#!/bin/bash
+# Declare BASH functionality for logging
+
+# NOTE:  Uses ANSI coloring
+
+# NOTE:  This is a very low-level script used by practically all other scripts,
+#        so it MUST NOT depend on any other scripts (beyond color)!
+
+# NOTE:  Logging priorities are implicitly ordered as:
+#        Debug < Info < Warn < Error < Fatal
+
+# For logging the source of calls below, pass $LINENO for the line and either
+# $FUNCNAME, $BASH_SOURCE, or $0 for the name.
+
+_log () {
+  # Log to STDERR the message $3 that originated in line $2 of script $1
+  # NOTE:  Should only be called from this script
+  [[ "$#" -ne 3 ]] && Oops "$FUNCNAME" "$LINENO" && return 1
+  # $1 = name of script/function where call originated
+  # $2 = line in script where call originated
+  # $3 = message
+
+  declare -r _Name="${1:-Unknown}"
+  declare -r _Line="${2:-0}"
+  declare -r _Message="${3:-No message provided.}"
+  echo -e "${_Name}:${_Line} ${_Message}" >&2
+}
+
+_logFatal () {
+  # Log a fatal message $3 that originated in line $2 of script $1
+  # NOTE:  Should only be called from abort()
+  [[ "$#" -ne 3 ]] && Oops "$FUNCNAME" "$LINENO" && return 1
+  # $1 = name of script/function where call originated
+  # $2 = line in script where call originated
+  # $3 = message
+
+  _logWithPriority "$1" "$2" "$3" 'FATAL: ' "$(color red black)"
+}
+
+_logWithPriority () {
+  # Log with priority $4 colorized as $5 the message $3 that originated in line
+  # $2 of script $1
+  # NOTE:  Should only be called from this script
+  [[ "$#" -ne 5 ]] && Oops "$FUNCNAME" "$LINENO" && return 1
+  # $1 = name of script/function where call originated
+  # $2 = line in script where call originated
+  # $3 = message
+  # $4 = priority (short text prefix)
+  # $5 = ANSI color specification
+
+  _log "$1" "$2" "$5$4$3$(color off)"
+}
+
+logDebug () {
+  # Log a debugging message $3 that originated in line $2 of script $1
+  [[ "$#" -ne 3 ]] && Oops "$FUNCNAME" "$LINENO" && return 1
+  # $1 = name of script/function where call originated
+  # $2 = line in script where call originated
+  # $3 = message
+
+  _logWithPriority "$1" "$2" "$3" 'DEBUG: ' "$(color magenta black)"
+}
+
+logError () {
+  # Log an error message $3 that originated in line $2 of script $1
+  [[ "$#" -ne 3 ]] && Oops "$FUNCNAME" "$LINENO" && return 1
+  # $1 = name of script/function where call originated
+  # $2 = line in script where call originated
+  # $3 = message
+
+  _logWithPriority "$1" "$2" "$3" 'ERROR: ' "$(color yellow black)"
+}
+
+logInfo () {
+  # Log an informational message $3 that originated in line $2 of script $1
+  [[ "$#" -ne 3 ]] && Oops "$FUNCNAME" "$LINENO" && return 1
+  # $1 = name of script/function where call originated
+  # $2 = line in script where call originated
+  # $3 = message
+
+  _logWithPriority "$1" "$2" "$3" 'INFO:  ' "$(color blue black)"
+}
+
+logWarn () {
+  # Log a warning message $3 that originated in line $2 of script $1
+  [[ "$#" -ne 3 ]] && Oops "$FUNCNAME" "$LINENO" && return 1
+  # $1 = name of script/function where call originated
+  # $2 = line in script where call originated
+  # $3 = message
+
+  _logWithPriority "$1" "$2" "$3" 'WARN:  ' "$(color cyan black)"
+}
+
+Oops () {
+  # Echo to STDERR that an Oops originated in line $2 of script $1
+  # NOTE:  This is usable to indicate an error in low-level code such as this
+  # logging infrastructure that is then used to support error handling in
+  # other higher-level code.
+  # $1 = name of script/function where call originated
+  # $2 = line in script where call originated
+
+  echo "$1:$2 had an Oops!" >&2
+}
+
+trace () {
+  # Trace variable $3 that originated in line $2 of script $1
+  [[ "$#" -ne 3 ]] && Oops "$FUNCNAME" "$LINENO" && return 1
+  # $1 = name of script/function where call originated
+  # $2 = line in script where call originated
+  # $3 = name of variable to trace
+
+  declare -r _Name=$3
+  declare -r _Value="${!_Name}"
+  logDebug "$1" "$2" "${_Name}='${_Value}'"
+}
+

File bin/Linux/helper/declare.bash

+#!/bin/bash
+# Declare all BASH functionality for BriteOnyx
+
+requireVariable BO_Home
+requireDirectory $BO_Home
+
+# Configure the Linux environment
+_Dir=$BO_Home/bin/Linux/helper
+requireDirectory ${_Dir}
+source ${_Dir}/declare-logging.bash
+source ${_Dir}/declare-BASH.bash
+source ${_Dir}/declare-POSIX.bash
+source ${_Dir}/declare-Hudson.bash
+source ${_Dir}/declare-Mercurial.bash
+source ${_Dir}/declare-Subversion.bash
+