Skip to Content.
Sympa Menu

sm-commit - [SM-Commit] GIT changes to master cauldron by Justin Boffemmyer (23c9e6ff142b538c78f079501a770243edfeb6cc)

sm-commit AT lists.ibiblio.org

Subject: Source Mage code commit list

List archive

Chronological Thread  
  • From: Justin Boffemmyer <scm AT sourcemage.org>
  • To: sm-commit AT lists.ibiblio.org
  • Subject: [SM-Commit] GIT changes to master cauldron by Justin Boffemmyer (23c9e6ff142b538c78f079501a770243edfeb6cc)
  • Date: Fri, 5 Jun 2009 11:45:32 -0500

GIT changes to master cauldron by Justin Boffemmyer <flux AT sourcemage.org>:

cauldron/cauldron | 4 -
cauldron/errorcodes | 60 +++++++++++++++++++++++++
cauldron/etc/config | 17 +------
cauldron/libcauldron | 46 ++++++++++---------
cauldron/libinit | 2
enchantment/errorcodes | 52 +++++++++++++++++++++
enchantment/etc/config | 30 ++++++++++++
enchantment/libenchantment | 25 +++++++---
enchantment/shell/bashrc | 7 +-
lib/liberror | 108
+++++----------------------------------------
lib/liberrorcodes | 80 +++++++++++++++++++++++++++++++++
11 files changed, 289 insertions(+), 142 deletions(-)

New commits:
commit 23c9e6ff142b538c78f079501a770243edfeb6cc
Author: Justin Boffemmyer <flux AT sourcemage.org>
Commit: Justin Boffemmyer <flux AT sourcemage.org>

error code cleanup

Strip the leading "C" and "E" from the earlier error code uses to comply
with the new liberror implementation ("ERR_*").

commit af0419b2ac4c428b84a43725c1b9e1d4cb666707
Author: Justin Boffemmyer <flux AT sourcemage.org>
Commit: Justin Boffemmyer <flux AT sourcemage.org>

separate cauldron and enchantment configs

Separate the variables for cauldron and enchantment into separate
config files. This is cleaner than stuffing everything into one file,
and helps to cut down on pollution of the user's namespace while also
making tracking down bugs easier.

commit 68ea0291eeef69b5e69581d1c6b4da2fd9f4ecc8
Author: Justin Boffemmyer <flux AT sourcemage.org>
Commit: Justin Boffemmyer <flux AT sourcemage.org>

update copyright information

Updated all the copyrights to the present year.

commit 4307bde1706bc428341d71b975fae9ee22481f7b
Author: Justin Boffemmyer <flux AT sourcemage.org>
Commit: Justin Boffemmyer <flux AT sourcemage.org>

new implmentation of liberror contexts

Rather than harcode the notion of calling contexts into liberror,
extract all the error codes and messages out to a separate file. This
file provides only base, default error codes and messages. Error
definitions specific to cauldron and enchantment are defined in their
respective source trees as errorcodes. This is a much more flexible
system, and also more optimized in terms of the code itself, as there is
less waste of variables and conditional branching.

diff --git a/cauldron/cauldron b/cauldron/cauldron
index 196dab1..038ed61 100755
--- a/cauldron/cauldron
+++ b/cauldron/cauldron
@@ -16,7 +16,7 @@
##
##=head1 COPYRIGHT
##
-## Copyright 2007 by the Cauldron Team
+## Copyright 2009 by the Cauldron Team
##
##=head1 FUNCTIONS
##
@@ -49,7 +49,7 @@ function cauldron_brew () {
# set up chroot for building inside $CAULDRON_BUILD
cauldron_chroot_init
# exit with error if chroot not defined
- [[ -n "$CAULDRON_CHROOT" ]] || exit $CERR_CHROOT
+ [[ -n "$CAULDRON_CHROOT" ]] || exit $ERR_CHROOT

# build the cross-compile tool-chain targeted for the target sys
if [ -n $TARGET ]
diff --git a/cauldron/errorcodes b/cauldron/errorcodes
new file mode 100644
index 0000000..8325d22
--- /dev/null
+++ b/cauldron/errorcodes
@@ -0,0 +1,60 @@
+#!/bin/bash
+#-------------------------------------------------------------------------------
+##
+##=head1 SYNOPSIS
+##
+## These are the cauldron-specific error definitions.
+##
+##=head1 COPYRIGHT
+##
+## Copyright 2009 by the Cauldron Team
+##
+##=head1 FUNCTIONS
+##
+##=over 4
+##
+#-------------------------------------------------------------------------------
+
+#-------------------------------------------------------------------------------
+# ERROR definitions
+#-------------------------------------------------------------------------------
+# error codes
+ERR_OK=0 # everything is good
+ERR_FATAL=1 # fatal error (missing cauldron libs, etc.)
+ERR_ARCHIVE=2 # problem creating archives
+ERR_CHROOT=3 # problem with a chroot
+ERR_CLEANFILE=4 # missing cleaner files
+ERR_TARGETSORCERY=5 # missing target sorcery files
+ERR_HOSTSORCERY=6 # sorcery not installed on host
+
+# error messages
+ERR_MSGS=(
+ "operation succeeded" # ERR_OK
+ "fatal error" # ERR_FATAL
+ "sorcery not set to archive" # ERR_ARCHIVE
+ "not in chroot" # ERR_CHROOT
+ "cleanfile not found" # ERR_CLEANFILE
+ "could not load target sorcery" # ERR_TARGETSORCERY
+ "could not load host sorcery" # ERR_HOSTSORCERY
+ )
+
+#-------------------------------------------------------------------------------
+##
+## This software is free software; you can redistribute it and/or modify
+## it under the terms of the GNU General Public License as published by
+## the Free Software Foundation; either version 2 of the License, or
+## (at your option) any later version.
+##
+## This software is distributed in the hope that it will be useful,
+## but WITHOUT ANY WARRANTY; without even the implied warranty of
+## MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the
+## GNU General Public License for more details.
+##
+## You should have received a copy of the GNU General Public License
+## along with this software; if not, write to the Free Software
+## Foundation, Inc., 59 Temple Place, Suite 330, Boston, MA 02111-1307 USA
+##
+#-------------------------------------------------------------------------------
+
+# vim:ai:tw=80:tabstop=2:softtabstop=2:shiftwidth=2:expandtab
+
diff --git a/cauldron/etc/config b/cauldron/etc/config
index 5eadfc1..6eeb928 100644
--- a/cauldron/etc/config
+++ b/cauldron/etc/config
@@ -19,8 +19,10 @@
# path to the ISO system (this should usually be null, unless
# you are doing some tricky hacking)
ISOPATH=""
+# path to the base library modules
+ BASE_LIBS="${HOSTPATH}/var/lib/cauldron"
# path to the cauldron library modules
- CAULDRON_LIBS="${HOSTPATH}/var/lib/cauldron"
+ CAULDRON_LIBS="${HOSTPATH}/var/lib/cauldron/cauldron"
# path to the cauldron configs
CAULDRON_DATA="/etc/cauldron"
# path to where the ISO build chroot is/will go
@@ -43,16 +45,3 @@
CAULDRON_KEEPISO="yes"
# branch of sorcery to use in the ISO
ISO_SORCERY_BRANCH="stable"
-
-# The following variables are for Enchant
- ENCHANT_TMP="${ISO}/tmp/enchant"
- ENCHANT_STATUS="${ENCHANT_TMP}/status"
- ENCHANT_BACK="${ENCHANT_TMP}/history/back"
- ENCHANT_FORWARD="${ENCHANT_TMP}/history/forward"
- ENCHANT_TARGET="${ISO}/mnt/root"
- ENCHANT_DATA="usr/share/enchant"
- ENCHANT_MSGS="${ENCHANT_DATA}/messages"
- ENCHANT_DOCS="usr/share/doc/enchant"
-# specifies the max. size of the history buffers
-# total history size = $ENCHANT_HISTORY * 2 = back + forward
- ENCHANT_HISTORY=20
diff --git a/cauldron/libcauldron b/cauldron/libcauldron
index 39a2c2e..5bd5129 100755
--- a/cauldron/libcauldron
+++ b/cauldron/libcauldron
@@ -7,7 +7,7 @@
##
##=head1 COPYRIGHT
##
-## Copyright 2007 by the Cauldron Team
+## Copyright 2009 by the Cauldron Team
##
##=head1 FUNCTIONS
##
@@ -16,11 +16,17 @@

#-------------------------------------------------------------------------------


#-------------------------------------------------------------------------------
-# Cauldron includes
+# cauldron includes

#-------------------------------------------------------------------------------
-. ${CAULDRON_LIBS}/libinit ||
- cauldron_fatal_error "error: cannot load cauldron libraries!"
-. ${CAULDRON_LIBS}/liberror ||
+. ${BASE_LIBS}/libinit ||
+ cauldron_fatal_error "error: cannot load base libraries!"
+. ${BASE_LIBS}/liberror ||
+ cauldron_fatal_error "error: cannot load base libraries!"
+. ${BASE_LIBS}/liberrorcodes ||
+ cauldron_fatal_error "error: cannot load base libraries!"
+
+# load cauldron error code and message defines
+. ${CAULDRON_LIBS}/errorcodes ||
cauldron_fatal_error "error: cannot load cauldron libraries!"


#-------------------------------------------------------------------------------
@@ -48,7 +54,7 @@ fi

#-------------------------------------------------------------------------------
function cauldron_fatal_error() {
echo $1
- exit $CERR_FATAL
+ exit $ERR_FATAL
}


#-------------------------------------------------------------------------------
@@ -60,11 +66,11 @@ function cauldron_fatal_error() {
function cauldron_source_sorcery() {
local target=$1

- source "$target/etc/sorcery/config" || return $CERR_TARGETSORCERY
+ source "$target/etc/sorcery/config" || return $ERR_TARGETSORCERY
if [[ -e "$target/etc/sorcery/local/config" ]]
then
source "$target/etc/sorcery/local/config"
- fi || return $CERR_TARGETSORCERY
+ fi || return $ERR_TARGETSORCERY
}


#-------------------------------------------------------------------------------
@@ -77,10 +83,10 @@ function cauldron_chroot_init() {

if [[ "$CAULDRON_CHROOTINIT" -ne 1 ]]
then
- mount --bind "$HOSTPATH"/dev "$TARGET"/dev || ret=$CERR_CHROOTINIT
- mount --bind "$HOSTPATH"/dev/pts "$TARGET"/dev/pts ||
ret=$CERR_CHROOTINIT
- mount --bind "$HOSTPATH"/proc "$TARGET"/proc || ret=$CERR_CHROOTINIT
- cauldron_source_sorcery "$TARGET" || return $CERR_TARGETSORCERY
+ mount --bind "$HOSTPATH"/dev "$TARGET"/dev || ret=$ERR_CHROOTINIT
+ mount --bind "$HOSTPATH"/dev/pts "$TARGET"/dev/pts || ret=$ERR_CHROOTINIT
+ mount --bind "$HOSTPATH"/proc "$TARGET"/proc || ret=$ERR_CHROOTINIT
+ cauldron_source_sorcery "$TARGET" || return $ERR_TARGETSORCERY
export CAULDRON_CHROOTINIT=1
export CAULDRON_CHROOT="chroot \"$TARGET\""
fi
@@ -154,7 +160,7 @@ function cauldron_base_toolchain() {
local HOST_TRIPLE

# exit with error if chroot not defined
- [[ -n "$CAULDRON_CHROOT" ]] || exit $CERR_CHROOT
+ [[ -n "$CAULDRON_CHROOT" ]] || exit $ERR_CHROOT

# set the value for HOST_TRIPLE
HOST_TRIPLE=$(cauldron_get_host_triple)
@@ -316,7 +322,7 @@ function cauldron_configure_toolchain() {

#-------------------------------------------------------------------------------
function cauldron_cross_toolchain() {
# exit with error if chroot not defined
- [[ -n "$CAULDRON_CHROOT" ]] || exit $CERR_CHROOT
+ [[ -n "$CAULDRON_CHROOT" ]] || exit $ERR_CHROOT

# build the stage 1 tools
cauldron_configure_toolchain 1
@@ -359,14 +365,14 @@ function cauldron_build_target_system() {
local spell

# exit with error if chroot not defined
- [[ -n "$CAULDRON_CHROOT" ]] || exit $CERR_CHROOT
+ [[ -n "$CAULDRON_CHROOT" ]] || exit $ERR_CHROOT

# Since we will be installing from the running ISO system instead of a
giant
# tarball, for each spell we only need to make sure that the cache file is
# available. This will require that the ISO sorcery has caching enabled.
The
# caching should really be turned on from the very beginning though...
cauldron_chroot_init
- [[ "$ARCHIVE" == "off" ]] && return $CERR_ARCHIVE
+ [[ "$ARCHIVE" == "off" ]] && return $ERR_ARCHIVE
for spell in $target_spells
do
# Cheap cop-out to get the cache generated - cast the spell to generate
the
@@ -378,7 +384,7 @@ function cauldron_build_target_system() {
${CAULDRON_CHROOT} ${CAULDRON_DISPEL} $spell
done
cauldron_chroot_done
- return $CERR_OK
+ return $ERR_OK
}


#-------------------------------------------------------------------------------
@@ -393,7 +399,7 @@ function cauldron_build_target_system() {
function cauldron_clean_iso_system() {
local CLEANFILE=$1

- [[ -z "$CLEANFILE" ]] && return $CERR_CLEANFILE
+ [[ -z "$CLEANFILE" ]] && return $ERR_CLEANFILE

for i in $(sort -r $CLEANFILE)
do
@@ -406,7 +412,7 @@ function cauldron_clean_iso_system() {
rm $i
fi
done
- return $CERR_OK
+ return $ERR_OK
}


#-------------------------------------------------------------------------------
@@ -458,7 +464,7 @@ function cauldron_add_installer() {

#-------------------------------------------------------------------------------
function cauldron_prepare() {
# exit with error if chroot not defined
- [[ -n "$CAULDRON_CHROOT" ]] || exit $CERR_CHROOT
+ [[ -n "$CAULDRON_CHROOT" ]] || exit $ERR_CHROOT

# first, ensure that the build dir exists
mkdir -p "$CAULDRON_BUILD"
diff --git a/cauldron/libinit b/cauldron/libinit
index 5bfce76..e124b62 100755
--- a/cauldron/libinit
+++ b/cauldron/libinit
@@ -9,7 +9,7 @@
##
##=head1 COPYRIGHT
##
-## Copyright 2007 by the Cauldron Team
+## Copyright 2009 by the Cauldron Team
##
##=head1 FUNCTIONS
##
diff --git a/enchantment/errorcodes b/enchantment/errorcodes
new file mode 100644
index 0000000..5941adc
--- /dev/null
+++ b/enchantment/errorcodes
@@ -0,0 +1,52 @@
+#!/bin/bash
+#-------------------------------------------------------------------------------
+##
+##=head1 SYNOPSIS
+##
+## These are the enchantment-specific error definitions.
+##
+##=head1 COPYRIGHT
+##
+## Copyright 2009 by the Cauldron Team
+##
+##=head1 FUNCTIONS
+##
+##=over 4
+##
+#-------------------------------------------------------------------------------
+
+#-------------------------------------------------------------------------------
+# ERROR definitions
+#-------------------------------------------------------------------------------
+# error codes
+ERR_OK=0 # everything is good
+ERR_FATAL=1 # fatal error (missing cauldron libs, etc.)
+ERR_STEP=2 # error in processing a step
+
+# error messages
+ERR_MSGS=(
+ "operation succeeded" # ERR_OK
+ "fatal error" # ERR_FATAL
+ "step error" # ERR_STEP
+ )
+
+#-------------------------------------------------------------------------------
+##
+## This software is free software; you can redistribute it and/or modify
+## it under the terms of the GNU General Public License as published by
+## the Free Software Foundation; either version 2 of the License, or
+## (at your option) any later version.
+##
+## This software is distributed in the hope that it will be useful,
+## but WITHOUT ANY WARRANTY; without even the implied warranty of
+## MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the
+## GNU General Public License for more details.
+##
+## You should have received a copy of the GNU General Public License
+## along with this software; if not, write to the Free Software
+## Foundation, Inc., 59 Temple Place, Suite 330, Boston, MA 02111-1307 USA
+##
+#-------------------------------------------------------------------------------
+
+# vim:ai:tw=80:tabstop=2:softtabstop=2:shiftwidth=2:expandtab
+
diff --git a/enchantment/etc/config b/enchantment/etc/config
new file mode 100644
index 0000000..ba038f4
--- /dev/null
+++ b/enchantment/etc/config
@@ -0,0 +1,30 @@
+ SORCERY_CONFIG="/etc/sorcery/config"
+ SORCERY_LIBS="/var/lib/sorcery/modules"
+ HOST_ARCH_PATH=$(grep "ARCH_SPEC=" ${SORCERY_CONFIG} | \
+ cut -d = -f 2)
+ HOST_ARCH=$(grep "ARCHITECTURE=" ${HOST_SORCERY_CONFIG} | \
+ cut -d = -f 2)
+ CACHE_EXTENSION=$(grep "EXTENSION=" ${HOST_SORCERY_CONFIG} | \
+ cut -d = -f 2)
+
+# path to the ISO system (this should usually be null, unless
+# you are doing some tricky hacking)
+ ISOPATH=""
+# path to the base library modules
+ BASE_LIBS="${ISOPATH}/var/lib/cauldron"
+# branch of sorcery to use in the ISO
+ ISO_SORCERY_BRANCH="stable"
+
+# path to the cauldron library modules
+ ENCHANT_LIBS="${ISOPATH}/var/lib/cauldron/enchantment"
+ ENCHANT_TMP="${ISOPATH}/tmp/enchantment"
+ ENCHANT_STATUS="${ENCHANT_TMP}/status"
+ ENCHANT_BACK="${ENCHANT_TMP}/history/back"
+ ENCHANT_FORWARD="${ENCHANT_TMP}/history/forward"
+ ENCHANT_TARGET="${ISOPATH}/mnt/root"
+ ENCHANT_DATA="usr/share/enchantment"
+ ENCHANT_MSGS="${ENCHANT_DATA}/messages"
+ ENCHANT_DOCS="usr/share/doc/enchantment"
+# specifies the max. size of the history buffers
+# total history size = $ENCHANT_HISTORY * 2 = back + forward
+ ENCHANT_HISTORY=20
diff --git a/enchantment/libenchantment b/enchantment/libenchantment
index 870f151..4710286 100755
--- a/enchantment/libenchantment
+++ b/enchantment/libenchantment
@@ -16,7 +16,7 @@
##
##=head1 COPYRIGHT
##
-## Copyright 2007 The Cauldron Team
+## Copyright 2009 The Cauldron Team
##
##=head1 FUNCTIONS
##
@@ -24,8 +24,19 @@
##

#-------------------------------------------------------------------------------

-# source liberror
-. ${CAULDRON_LIBS}/liberror
+#-------------------------------------------------------------------------------
+# enchantment includes
+#-------------------------------------------------------------------------------
+. ${BASE_LIBS}/libinit ||
+ cauldron_fatal_error "error: cannot load base libraries!"
+. ${BASE_LIBS}/liberror ||
+ cauldron_fatal_error "error: cannot load base libraries!"
+. ${BASE_LIBS}/liberrorcodes ||
+ cauldron_fatal_error "error: cannot load base libraries!"
+
+# load cauldron error code and message defines
+. ${ENCHANT_LIBS}/errorcodes ||
+ enchant_fatal_error "error: cannot load enchantment libraries!"


#-------------------------------------------------------------------------------
##
@@ -152,7 +163,7 @@ function enchant_setprev() {

#-------------------------------------------------------------------------------
function enchant_back() {
# if the forward history is empty, then we can't go forward
- [[ $(wc -l < ${ENCHANT_BACK}) -eq 0 ]] && return $EERR_BACK
+ [[ $(wc -l < ${ENCHANT_BACK}) -eq 0 ]] && return $ERR_BACK

# if the max history size has been reached, then we drop the oldest item
[[ $(wc -l < ${ENCHANT_FORWARD}) -ge $ENCHANT_HISTORY ]] &&
@@ -175,7 +186,7 @@ function enchant_back() {

#-------------------------------------------------------------------------------
function enchant_forward() {
# if the forward history is empty, then we can't go forward
- [[ $(wc -l < ${ENCHANT_FORWARD}) -eq 0 ]] && return $EERR_FORWARD
+ [[ $(wc -l < ${ENCHANT_FORWARD}) -eq 0 ]] && return $ERR_FORWARD

# if the max history size has been reached, then we drop the oldest item
[[ $(wc -l < ${ENCHANT_BACK}) -ge $ENCHANT_HISTORY ]] &&
@@ -246,10 +257,10 @@ function enchant_setstep() {
# copy the current status to the back history, so we can go back to
where we
# are after we jump forward
cat < ${ENCHANT_STATUS} >> ${ENCHANT_BACK}
- return $EERR_OK
+ return $ERR_OK
fi
done
- return $EERR_STEP
+ return $ERR_STEP
}


diff --git a/enchantment/shell/bashrc b/enchantment/shell/bashrc
index e639251..08f5f78 100755
--- a/enchantment/shell/bashrc
+++ b/enchantment/shell/bashrc
@@ -4,8 +4,9 @@
# Take care not to pollute the user's namespace too much,
# And make sure your functions don't collide with existing commands.

-. /etc/cauldron/local/config
-. ${ISO}/${ENCHANT_DATA}/libenchant
+. /etc/cauldron/enchant.config
+. /etc/cauldron/local/enchant.config
+. ${ISOPATH}/${ENCHANT_DATA}/libenchant

# Ensure installer sanity
enchant_prepare
@@ -65,7 +66,7 @@ function forward() {

function jump() {
enchant_setstep $*
- if [[ $? = $EERR_STEP ]]
+ if [[ $? = $ERR_STEP ]]
then
echo ""
echo "Error: '$*' is not a recognized step."
diff --git a/lib/liberror b/lib/liberror
index 09f0069..1e28799 100755
--- a/lib/liberror
+++ b/lib/liberror
@@ -8,7 +8,7 @@
##
##=head1 COPYRIGHT
##
-## Copyright 2007 by the Cauldron Team
+## Copyright 2009 by the Cauldron Team
##
##=head1 FUNCTIONS
##
@@ -17,71 +17,6 @@

#-------------------------------------------------------------------------------


#-------------------------------------------------------------------------------
-# Local global variables
-#-------------------------------------------------------------------------------
-CDEFAULT_COLOR="\e[0m"
-CBOLD="\e[1m"
-CBLACK="\e[30m"
-CRED="\e[31m"
-CGREEN="\e[32m"
-CYELLOW="\e[33m"
-CBLUE="\e[34m"
-CVIOLET="\e[35m"
-CCYAN="\e[36m"
-CWHITE="\e[37m"
-
-CERR_COLOR="${RED}${BOLD}"
-EERR_COLOR="${RED}${BOLD}"
-
-CSPELL_COLOR="${WHITE}${BOLD}\e[40m"
-CVERSION_COLOR="${WHITE}${BOLD}\e[40m"
-CQUERY_COLOR="${YELLOW}${BOLD}"
-CDISPEL_COLOR="${YELLOW}${BOLD}"
-CCHECK_COLOR="${CYAN}"
-CRESURRECT_COLOR="${GREEN}${BOLD}"
-CFILE_COLOR="${GREEN}${BOLD}"
-CSYMLINK_COLOR="${CYAN}${BOLD}"
-CPROBLEM_COLOR="${RED}${BOLD}"
-CMESSAGE_COLOR="${CYAN}"
-
-#-------------------------------------------------------------------------------
-# ERROR definitions
-#-------------------------------------------------------------------------------
-# cauldron errors
-CERR_OK=0 # everything is good
-CERR_FATAL=1 # fatal error (missing cauldron libs, etc.)
-CERR_ARCHIVE=2 # problem creating archives
-CERR_CHROOT=3 # problem with a chroot
-CERR_CLEANFILE=4 # missing cleaner files
-CERR_TARGETSORCERY=5 # missing target sorcery files
-CERR_HOSTSORCERY=6 # sorcery not installed on host
-
-# cauldron error messages
-CERR_MSG=(
- "operation succeeded" # CERR_OK
- "fatal error" # CERR_FATAL
- "sorcery not set to archive" # CERR_ARCHIVE
- "not in chroot" # CERR_CHROOT
- "cleanfile not found" # CERR_CLEANFILE
- "could not load target sorcery" # CERR_TARGETSORCERY
- "could not load host sorcery" # CERR_HOSTSORCERY
- )
-
-# enchant errors
-EERR_OK=0
-EERR_STEP=1
-
-# enchant error messages
-EERR_MSG=(
- "operation succeeded" # EERR_OK
- "step error" # EERR_STEP
- )
-
-# liberror context - should be either C for cauldron or E for enchant,
defaults
-# to cauldron context ("C").
-LIBERROR_CONTEXT=${LIBERROR_CONTEXT:-C}
-
-#-------------------------------------------------------------------------------
# Function definitions

#-------------------------------------------------------------------------------

#-------------------------------------------------------------------------------
@@ -104,7 +39,7 @@ function liberror_checkerror() {
error="$(liberror_geterror $rc)"
fi
else
- error="${LIBERROR_CONTEXT}ERR_OK"
+ error="ERR_OK"
fi
[[ -z $error ]] && return 1
echo $error
@@ -119,7 +54,7 @@ function liberror_checkerror() {
##

#-------------------------------------------------------------------------------
function liberror_geterror() {
- local error=$(set | grep "${LIBERROR_CONTEXT}ERR_[A-Z]*=$1" | cut -d = -f
1)
+ local error=$(set | grep "ERR_[A-Z]*=$1" | cut -d = -f 1)

[[ -z $error ]] && return 1
echo "$error"
@@ -136,37 +71,20 @@ function liberror_geterror() {

#-------------------------------------------------------------------------------
function liberror_printerror() {
local error=$1
- local errmsg=
+ local errmsg="${ERR_MSGS[${!error}]}"

- # check if we are in cauldron or enchant
- if [[ $LIBERROR_CONTEXT == C ]]
- then
- errmsg="${CERR_MSG[${!error}]}"
- # exit if $errmsg not defined
- [[ -z $errmsg ]] && return 1
+ # exit if $errmsg not defined
+ [[ -z $errmsg ]] && return 1

- if [[ ${!error} -eq 0 ]]
- then
- # print a cauldron OK message
- echo "$CMESSAGE_COLOR" "$errmsg" "$CDEFAULT_COLOR"
- else
- # print a cauldron error message
- echo "$CERR_COLOR" "error: ${errmsg}!" "$CDEFAULT_COLOR"
- fi
+ if [[ ${!error} -eq 0 ]]
+ then
+ # print a cauldron OK message
+ echo "$MESSAGE_COLOR" "$errmsg" "$DEFAULT_COLOR"
else
- errmsg="${EERR_MSG[${!error}]}"
- # exit if $errmsg not defined
- [[ -z $errmsg ]] && return 1
-
- if [[ ${!error} -eq 0 ]]
- then
- # print an enchant OK message
- echo "$EMESSAGE_COLOR" "$errmsg" "$EDEFAULT_COLOR"
- else
- # print an enchant error message
- echo "$EERR_COLOR" "error: ${errmsg}!" "$EDEFAULT_COLOR"
- fi
+ # print a cauldron error message
+ echo "$ERR_COLOR" "error: ${errmsg}!" "$DEFAULT_COLOR"
fi || return 1
+
return 0
}

diff --git a/lib/liberrorcodes b/lib/liberrorcodes
new file mode 100644
index 0000000..5737fd3
--- /dev/null
+++ b/lib/liberrorcodes
@@ -0,0 +1,80 @@
+#!/bin/bash
+#-------------------------------------------------------------------------------
+##
+##=head1 SYNOPSIS
+##
+## liberrorcodes provides a set of variables which define default error
codes.
+## Most likely, code that links to liberror should provide its own custom
+## definitions, but it is possible to load these first and then load custom
+## defines afterwards to overwrite the defaults (or simply add to them).
+##
+##=head1 COPYRIGHT
+##
+## Copyright 2009 by the Cauldron Team
+##
+##=head1 FUNCTIONS
+##
+##=over 4
+##
+#-------------------------------------------------------------------------------
+
+#-------------------------------------------------------------------------------
+# Local global variables
+#-------------------------------------------------------------------------------
+DEFAULT_COLOR="\e[0m"
+BOLD="\e[1m"
+BLACK="\e[30m"
+RED="\e[31m"
+GREEN="\e[32m"
+YELLOW="\e[33m"
+BLUE="\e[34m"
+VIOLET="\e[35m"
+CYAN="\e[36m"
+WHITE="\e[37m"
+
+ERR_COLOR="${RED}${BOLD}"
+
+SPELL_COLOR="${WHITE}${BOLD}\e[40m"
+VERSION_COLOR="${WHITE}${BOLD}\e[40m"
+QUERY_COLOR="${YELLOW}${BOLD}"
+DISPEL_COLOR="${YELLOW}${BOLD}"
+CHECK_COLOR="${CYAN}"
+RESURRECT_COLOR="${GREEN}${BOLD}"
+FILE_COLOR="${GREEN}${BOLD}"
+SYMLINK_COLOR="${CYAN}${BOLD}"
+PROBLEM_COLOR="${RED}${BOLD}"
+MESSAGE_COLOR="${CYAN}"
+
+#-------------------------------------------------------------------------------
+# ERROR definitions
+#-------------------------------------------------------------------------------
+# error codes
+ERR_OK=0 # everything is good
+ERR_FATAL=1 # fatal error (missing cauldron libs, etc.)
+
+# error messages
+ERR_MSGS=(
+ "operation succeeded" # ERR_OK
+ "fatal error" # ERR_FATAL
+ )
+
+#-------------------------------------------------------------------------------
+##
+## This software is free software; you can redistribute it and/or modify
+## it under the terms of the GNU General Public License as published by
+## the Free Software Foundation; either version 2 of the License, or
+## (at your option) any later version.
+##
+## This software is distributed in the hope that it will be useful,
+## but WITHOUT ANY WARRANTY; without even the implied warranty of
+## MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the
+## GNU General Public License for more details.
+##
+## You should have received a copy of the GNU General Public License
+## along with this software; if not, write to the Free Software
+## Foundation, Inc., 59 Temple Place, Suite 330, Boston, MA 02111-1307 USA
+##
+#-------------------------------------------------------------------------------
+
+# vim:ai:tw=80:tabstop=2:softtabstop=2:shiftwidth=2:expandtab
+



  • [SM-Commit] GIT changes to master cauldron by Justin Boffemmyer (23c9e6ff142b538c78f079501a770243edfeb6cc), Justin Boffemmyer, 06/05/2009

Archive powered by MHonArc 2.6.24.

Top of Page