Skip to Content.
Sympa Menu

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

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 (0bc463669005cfa37e4549f4c05807ac770b82f8)
  • Date: Fri, 25 Mar 2011 07:21:24 -0500

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

enchantment/errorcodes | 10 +++-
enchantment/shell/bin/enchantment | 6 --
lib/liberror | 8 +--
ward/libward | 88
++++++++++++++++++++++++++++++++++----
ward/ward-configvars | 2
5 files changed, 95 insertions(+), 19 deletions(-)

New commits:
commit 0bc463669005cfa37e4549f4c05807ac770b82f8
Author: Justin Boffemmyer <flux AT sourcemage.org>
Commit: Justin Boffemmyer <flux AT sourcemage.org>

enchantment: correct typo in errorcodes

Defined some potion errorcodes as SPELL_SOURCES and SPELL_CACHES, when
they should just be SOURCES and CACHES, respectively.

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

ward: handle sourced includes for config vars

Implemented a recursive descent parser to scan for sourced config files.
With the newly implemented cascading config file system in cauldron,
ward-configvars was unable to properly detect all the config variables
defined across the various files. The two options to fix this were to
maintain a list of all the possible config files, or to write a parser
that would scan all the files (otherwise, it would have to source the
files itself, which could be dangerous if the files contained actual
code). I opted for the parser, because this would additionally ensure
correctness by acting only on the files actually listed for inclusion,
and avoids the pitfall of having a source list that is out of sync with
the actual inclusions.

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

enchantment: remove installer local errorcodes

Now that the error messages are more flexible in liberror (runtime
variables), there is no need to have installer local error codes
defined. Removing them and placing more generalized versions in the
enchantment-wide errorcodes file makes the individual installers more
robust.

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

liberror: enable runtime variables in error msgs

Enable the use of runtime variable substitution when printing error
messages by first evaluating error messages before printing them.

diff --git a/enchantment/errorcodes b/enchantment/errorcodes
index 202218d..1ab9dd5 100644
--- a/enchantment/errorcodes
+++ b/enchantment/errorcodes
@@ -103,13 +103,19 @@ liberror_add_error ERR_POTION_UPDATE_CONFS \
liberror_add_error ERR_POTION_UPDATE_FILESYSTEMS "could not update
filesystems"
liberror_add_error ERR_POTION_UPDATE_KERNEL "could not update kernel config"
liberror_add_error ERR_POTION_UPDATE_MOUNT_POINTS "could not update mount
points"
-liberror_add_error ERR_POTION_UPDATE_SPELL_SOURCES \
+liberror_add_error ERR_POTION_UPDATE_SOURCES \
"could not update spell sources selection"
-liberror_add_error ERR_POTION_UPDATE_SPELL_CACHES \
+liberror_add_error ERR_POTION_UPDATE_CACHES \
"could not update spell caches selection"
liberror_add_error ERR_POTION_UPDATE_PARTITIONS "could not update partitions"
liberror_add_error ERR_POTION_UPDATE_USERS "could not update user/group
config"

+# installer
+liberror_add_error ERR_INSTALLER_FUNCS "could not load \$ENCHANT_INSTALLER
functions file"
+liberror_add_error ERR_INSTALLER_CMD "incorrect usage or unrecognized
command"
+liberror_add_error ERR_INSTALLER_KEYMAP "could not process keymap list"
+liberror_add_error ERR_INSTALLER_MODULES "could not process module list"
+

#-------------------------------------------------------------------------------
##
## This software is free software; you can redistribute it and/or modify
diff --git a/enchantment/shell/bin/enchantment
b/enchantment/shell/bin/enchantment
index eb1e9d0..ed9c528 100755
--- a/enchantment/shell/bin/enchantment
+++ b/enchantment/shell/bin/enchantment
@@ -31,12 +31,6 @@ then
exit 1
fi

-# add local error message(s) and error code(s)
-liberror_add_error ERR_INSTALLER_FUNCS "could not load $ENCHANT_INSTALLER
functions file"
-liberror_add_error ERR_INSTALLER_CHROOT_MOUNT "could not mount chroot
subdirs"
-liberror_add_error ERR_INSTALLER_CHROOT_EXEC "could not execute chroot
command"
-liberror_add_error ERR_INSTALLER_CHROOT_UMOUNT "could not unmount chroot
subdirs"
-
# source installer-specific functions
[[ -f "$ENCHANT_DATA/$ENCHANT_INSTALLER/functions" ]] ||
liberror_die $ERR_INSTALLER_FUNCS
diff --git a/lib/liberror b/lib/liberror
index 3e00ee4..3fba5ee 100755
--- a/lib/liberror
+++ b/lib/liberror
@@ -101,19 +101,19 @@ function liberror_print_error() {
# output using libcolor if available
if [[ "$(type -t libcolor_notice)" == "function" ]]
then
- libcolor_notice "$errmsg" >&$output
+ eval libcolor_notice "$errmsg" >&$output
echo "" >&$output
else
- echo "$errmsg" >&$output
+ eval echo "$errmsg" >&$output
fi
else
# output using libcolor if available
if [[ "$(type -t libcolor_error)" == "function" ]]
then
- libcolor_error "$errmsg" >&$output
+ eval libcolor_error "$errmsg" >&$output
echo "" >&$output
else
- echo "$errmsg" >&$output
+ eval echo "$errmsg" >&$output
fi
fi || return 1

diff --git a/ward/libward b/ward/libward
index ca3374b..8b4fe82 100644
--- a/ward/libward
+++ b/ward/libward
@@ -90,6 +90,56 @@ function ward_get_sources() {
}


#-------------------------------------------------------------------------------
+## @param definition file to parse (required)
+##
+## Gets a list of include files sourced by the definition file passed as the
+## first parameter.
+##
+#-------------------------------------------------------------------------------
+function ward_parse_includes() {
+ local include="$1"
+
+ [[ -z "$include" ]] && liberror_die $ERR_FATAL
+
+ # for every line starting with "source" or ".", grab the argument to be
+ # sourced
+ grep '^[[:space:]]*\(source \|\. \)' "${include[@]}" |
+ sed 's/.*\(source\|\.\) //'
+}
+
+#-------------------------------------------------------------------------------
+## @param definition file to parse (required)
+##
+## Implements a recursive descent parser of include files, scanning each
file in
+## turn and building a list of all sourced include files.
+##
+#-------------------------------------------------------------------------------
+function ward_descend_includes() {
+ local defines=( "$1" )
+ local includes=()
+ local file=""
+
+ [[ "${#defines[@]}" -eq 0 ]] && liberror_die $ERR_FATAL
+
+ # seed the includes by doing a single pass
+ eval includes=( "$(ward_parse_includes ${defines[0]})" )
+
+ # if there aren't any further includes, nothing is sourced so we can stop
+ # descending
+ [[ "${#includes[@]}" -eq 0 ]] && return $ERR_OK
+
+ for file in "${includes[@]}"
+ do
+ if ! echo "${defines[@]}" | grep "$file"
+ then
+ eval defines=( "${defines[@]}" "$file" "$(ward_descend_includes
$file)" )
+ fi
+ done
+
+ echo "${defines[@]}"
+}
+
+#-------------------------------------------------------------------------------
## @param -p base path to sources (optional)
## @param -d base path to definition file (optional)
## @param definition file (required)
@@ -105,7 +155,9 @@ function ward_get_sources() {
function ward_global_variables() {
local fpath="."
local dpath="."
- local defines=""
+ local defines=()
+ local inc=""
+ local vars=()
local file=""

# process any optional parameters
@@ -143,7 +195,7 @@ function ward_global_variables() {
fi

# get the defines file, then drop it from the argument list
- defines="$1"
+ defines=( "$1" )
shift

# if defines is not given with an absolute path, add the base path prefix
@@ -156,6 +208,29 @@ function ward_global_variables() {
liberror_die $ERR_FATAL
fi

+ # recursively descend the definitions files to scan for any files they in
turn
+ # include/source
+ for inc in "${defines[@]}"
+ do
+ #eval defines=( "${defines[@]}" $(ward_descend_includes "$inc") )
+ defines=( "${defines[@]}" $(ward_descend_includes "$inc") )
+ done
+ # pass the data to sort so it can sort and remove duplicates
+ defines=(
+ "$(echo ${defines[@]} | gawk '{for(i=1;i<=NF;i++){print $i}}' | sort -u)"
+ )
+
+ # get a list of all variables defined in the definition file(s)
+ for file in ${defines[@]}
+ do
+ #eval vars=( "${vars[@]}" $(grep '[A-Z][A-Z_]*[0-9]*=' "$file" | cut -d=
-f1) )
+ vars=( "${vars[@]}" $(grep '[A-Z][A-Z_]*[0-9]*=' "$file" | cut -d= -f1) )
+ done
+ # pass the data to sort so it can sort and remove duplicates
+ vars=(
+ "$(echo ${vars[@]} | gawk '{for(i=1;i<=NF;i++){print $i}}' | sort -u)"
+ )
+
while [[ $# -gt 0 ]]
do
file="$1"
@@ -171,7 +246,7 @@ function ward_global_variables() {
# underscores, and trailing numbers
for search in $(grep -o '${\?[A-Z][A-Z_]*[0-9]*' "$file" | sed
's/^\${\?//' | sort -u)
do
- if ! grep -q "$search=" "$defines"
+ if ! echo "${vars[@]}" | grep -q "$search"
then
echo "$(libcolor_file $file): $(libcolor_warn $search)"
fi
@@ -196,6 +271,7 @@ function ward_error_codes() {
local codes=()
local msgcode=""
local count=""
+ local codes=""

# process any optional parameters
while [[ "${1:0:1}" == "-" ]]
@@ -277,6 +353,7 @@ function ward_error_variables() {
local epath="."
local errorcodes=""
local file=""
+ local codes=""

# process any optional parameters
while [[ "${1:0:1}" == "-" ]]
@@ -344,10 +421,7 @@ function ward_error_variables() {
# underscores, and trailing numbers
for search in $(grep -o '${\?[A-Z][A-Z_]*[0-9]*' "$file" | sed
's/^\${\?//' | sort -u)
do
- if [[ "$search" == "ERR_OK" || "$search" == "ERR_FATAL" ]]
- then
- continue
- fi
+ [[ "$search" == "ERR_OK" || "$search" == "ERR_FATAL" ]] && continue

if ! echo " ${codes[*]} " | grep -q " $search "
then
diff --git a/ward/ward-configvars b/ward/ward-configvars
index 6c8a6ca..090787c 100755
--- a/ward/ward-configvars
+++ b/ward/ward-configvars
@@ -73,6 +73,7 @@ then
ward_get_sources "cauldron_sources"
cauldron="$WARD_PATH/../cauldron"
c_conf="$cauldron/etc/cauldron.conf"
+ CAULDRON_CONF="$cauldron/config"

# check cauldron files
libcolor_notice "Checking cauldron config variables"
@@ -86,6 +87,7 @@ then
ward_get_sources "enchantment_sources"
enchantment="$WARD_PATH/../enchantment"
e_conf="$enchantment/etc/enchantment.conf"
+ ENCHANTMENT_CONF="$enchantment/config"

# check enchantment files
libcolor_notice "Checking enchantment config variables"



  • [SM-Commit] GIT changes to master cauldron by Justin Boffemmyer (0bc463669005cfa37e4549f4c05807ac770b82f8), Justin Boffemmyer, 03/25/2011

Archive powered by MHonArc 2.6.24.

Top of Page