Skip to Content.
Sympa Menu

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

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 (ff89da3e2f7024490eba7be5890a66f722f05145)
  • Date: Thu, 24 Mar 2011 22:07:35 -0500

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

cauldron/errorcodes | 223 ++++++++++++-----------------------
cauldron/etc/config | 2
cauldron/lib.sorcerous | 5
enchantment/errorcodes | 236
+++++++++++---------------------------
enchantment/shell/bin/enchantment | 15 --
lib/liberror | 34 +++++
ward/libward | 131 ++++++++++++++++-----
ward/ward-errorcodes | 4
8 files changed, 299 insertions(+), 351 deletions(-)

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

liberror: function for errorcode creation/handling

There is now a function for adding new error codes with corresponding
messages. This eases the burden of maintaining lists of error codes, as
developers no longer need to track error code numbers directly, and also
coalesces a code and its message into a single line rather than the
developer having to maintain them separately. This also has the result
of cleaner and smaller code.

The original method of directly modifying the error code values and
error message array can still be used when low-level error code access
is required, but the new method (via liberror_add_error) is now the
preferred method for defining error codes and messages. All defined
errors in both the cauldron and enchantment components have been
converted to this new method. Ward has also accordingly been updated to
handle testing the error codes via the new method.

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

cauldron: modify setting/usage of sorcery url

Allow more direct modification of the sorcery download url by running
wget directly on SORCERY_URL, rather than a combination of
SORCERY_URL/SORCERY_PKG. This also allows the download url to be
different from the downloaded package name.

diff --git a/cauldron/errorcodes b/cauldron/errorcodes
index b702ba2..8bee67e 100644
--- a/cauldron/errorcodes
+++ b/cauldron/errorcodes
@@ -18,169 +18,104 @@

#-------------------------------------------------------------------------------
# ERROR definitions

#-------------------------------------------------------------------------------
+
# base error codes
-ERR_OK=0 # everything is good
-ERR_FATAL=1 # fatal error (missing cauldron libs, etc.)
-ERR_MK_DIR=2 # couldn't make directory
-ERR_DIR_EXISTS=3 # directory already exists
-ERR_FILE_NOT_FOUND=5 # requested file not found
-ERR_DIR_NOT_FOUND=6 # requested dir not found
-ERR_CP_FILE=7 # could not copy file
-ERR_CHMOD_FILE=8 # could not chmod file
-ERR_RM_FILES=9 # could not remove files
+liberror_add_error ERR_MK_DIR "could not make directory"
+liberror_add_error ERR_DIR_EXISTS "directory already exists"
+liberror_add_error ERR_FILE_NOT_FOUND "requested file not found"
+liberror_add_error ERR_DIR_NOT_FOUND "requested directory not found"
+liberror_add_error ERR_CP_FILE "could not copy file"
+liberror_add_error ERR_CHMOD_FILE "could not chmod file"
+liberror_add_error ERR_RM_FILES "could not remove files"

# libcauldron base
-ERR_LOAD_LIBRARY=10 # problem loading a library/include
-ERR_CLEANUP_BUILD=11 # could not clean up build dir
-ERR_CLEANUP_TMP=12 # could not clean up tmp dir
+liberror_add_error ERR_LOAD_LIBRARY "problem loading library"
+liberror_add_error ERR_CLEANUP_BUILD "could not clean up build directory"
+liberror_add_error ERR_CLEANUP_TMP "could not clean up temporary directory"

# libcauldron build
-ERR_UNPACK_CACHE=20 # couldn't unpack spell cache inside build dir
-ERR_RM_CACHE=21 # couldn't remove spell cache after unpacking in
build
-ERR_HOST_TRIPLE=22 # couldn't get host triple for builds
-ERR_BUILD_SPOOL=23 # build directory sorcery spool does not exist
-ERR_RESOLV=24 # resolv.conf missing in the build dir
+liberror_add_error ERR_UNPACK_CACHE \
+ "could not unpack spell cache inside build directory"
+liberror_add_error ERR_RM_CACHE \
+ "could not remove spell cache after unpacking in build"
+liberror_add_error ERR_HOST_TRIPLE "could not get host triple for builds"
+liberror_add_error ERR_BUILD_SPOOL "build directory sorcery spool does not
exist"
+liberror_add_error ERR_RESOLV "resolv.conf missing in the build directory"

# libcauldron cleaner files
-ERR_CLEAN_CLEANER=30 # missing cleaner files
-ERR_CLEAN_DIR=31 # failed to clean dir from ISO
-ERR_CLEAN_FILE=32 # failed to clean file from ISO
+liberror_add_error ERR_CLEAN_CLEANER "cleaner files could not be found"
+liberror_add_error ERR_CLEAN_DIR "failed to clean directory from iso"
+liberror_add_error ERR_CLEAN_FILE "failed to clean file from iso"

# libcauldron enchantment
-ERR_ENCHANT_CONFIG=40 # could not source enchant config
-ERR_INSTALLER_DIR=41 # could not create the ISO installer dir
-ERR_COPY_INSTALLER=42 # could not copy installer to ISO
-ERR_LINK_INSTALLER=43 # could not copy installer to ISO
+liberror_add_error ERR_ENCHANT_CONFIG "could not source enchant config"
+liberror_add_error ERR_INSTALLER_DIR \
+ "could not create the iso installer directory"
+liberror_add_error ERR_COPY_INSTALLER "could not copy installer to iso"
+liberror_add_error ERR_LINK_INSTALLER "could not link installer in iso"

# libcauldron final product
-ERR_ISO_PACKAGE=50 # could not create the final ISO file
-ERR_ISO_COMPRESS=51 # could not compress final ISO file
-ERR_SYS_PACKAGE=52 # could not package final SYS archive
-ERR_SYS_COMPRESS=53 # could not compress final SYS archive
+liberror_add_error ERR_ISO_PACKAGE "could not create final iso file"
+liberror_add_error ERR_ISO_COMPRESS "could not compress final iso file"
+liberror_add_error ERR_SYS_PACKAGE "could not package final sys file"
+liberror_add_error ERR_SYS_COMPRESS "could not compress final sys archive"

# lib.chroot
-ERR_CHROOT_UNDEF=60 # chroot TARGET is undefined
-ERR_CHROOT_INIT=61 # couldn't init chroot
-ERR_CHROOT_DONE=62 # couldn't close chroot
-ERR_CHROOT_NOT_INIT=63 # chroot isn't initialized
-ERR_CHROOT_EXEC=64 # could not execute chroot command
-ERR_CHROOT_CAST=65 # chroot cast failed
-ERR_CHROOT_DISPEL=66 # chroot dispel failed
-ERR_CHROOT_REBUILD=67 # chroot rebuild failed
-ERR_CHROOT_NEST=68 # chroot already defined -- nesting not allowed
+liberror_add_error ERR_CHROOT_UNDEF "chroot target is undefined"
+liberror_add_error ERR_CHROOT_INIT "could not init chroot"
+liberror_add_error ERR_CHROOT_DONE "could not close chroot"
+liberror_add_error ERR_CHROOT_NOT_INIT "chroot not initialized"
+liberror_add_error ERR_CHROOT_EXEC "could not execute chroot command"
+liberror_add_error ERR_CHROOT_CAST "chroot cast failed"
+liberror_add_error ERR_CHROOT_DISPEL "chroot dispel failed"
+liberror_add_error ERR_CHROOT_REBUILD "chroot rebuild failed"
+liberror_add_error ERR_CHROOT_NEST "chroot already defined"

# lib.init
-ERR_INIT_INSTALL_RAMFS=70 # problem installing built initramfs into ISO fs
-ERR_INIT_INSTALL_RD=71 # problem installing built initramdisk into ISO fs
-ERR_INIT_MAKE_RAMFS=72 # could not build initramfs
-ERR_INIT_MAKE_RD=73 # could not build initramdisk
-ERR_INIT_MAKE_FS=73 # could not make filesystem for initramfs/ramdisk
+liberror_add_error ERR_INIT_INSTALL_RAMFS \
+ "problem installing built initramfs into iso"
+liberror_add_error ERR_INIT_INSTALL_RD \
+ "problem installing built initramdisk into iso"
+liberror_add_error ERR_INIT_MAKE_RAMFS "could not build initramfs"
+liberror_add_error ERR_INIT_MAKE_RD "could not build initramdisk"
+liberror_add_error ERR_INIT_MAKE_FS \
+ "could not make filesystem for initramfs/ramdisk"

# lib.sorcerous
-ERR_SORCEROUS_ARCHIVE=80 # target sorcery not set to archive casts
-ERR_SORCEROUS_TARGET=81 # missing target sorcery files
-ERR_SORCEROUS_HOST=82 # sorcery not installed on host
-ERR_SORCEROUS_CREATE_CACHE=83 # error creating spell cache
-ERR_SORCEROUS_ISO_SORCERY_CONFIG=84 # couldn't create the ISO local sorcery
config dir
-ERR_SORCEROUS_DOWNLOAD=85 # could not download sorcery
-ERR_SORCEROUS_UNPACK=86 # could not unpack a valid sorcery
install
-ERR_SORCEROUS_INSTALL=87 # could not install sorcery into the
build dir
+liberror_add_error ERR_SORCEROUS_ARCHIVE \
+ "target sorcery not set to archive casts"
+liberror_add_error ERR_SORCEROUS_TARGET "target sorcery files not found"
+liberror_add_error ERR_SORCEROUS_HOST "host sorcery not found"
+liberror_add_error ERR_SORCEROUS_CREATE_CACHE "could not create spell cache"
+liberror_add_error ERR_SORCEROUS_ISO_SORCERY_CONFIG \
+ "could not create local sorcery config directory in iso"
+liberror_add_error ERR_SORCEROUS_DOWNLOAD "could not download sorcery"
+liberror_add_error ERR_SORCEROUS_UNPACK \
+ "could not unpack a valid sorcery install"
+liberror_add_error ERR_SORCEROUS_INSTALL \
+ "could not install sorcery into build directory"

# lib.toolchain
-ERR_TOOLCHAIN_CP_CACHE=90 # problem copying spell cache from HOST to
build dir
-ERR_TOOLCHAIN_BUILD_CACHE=91 # problem building cache file from spell
install info
-ERR_TOOLCHAIN_STAGE1=92 # cross-toolchain failed at stage 1
-ERR_TOOLCHAIN_STAGE2=93 # cross-toolchain failed at stage 2
-ERR_TOOLCHAIN_STAGE3=94 # cross-toolchain failed at stage 3
-ERR_TOOLCHAIN_CAST=95 # failed to cast toolchain spell
-ERR_TOOLCHAIN_DISPEL=96 # failed to dispel toolchain spell
-ERR_TOOLCHAIN_GATHER=97 # failed to generate toolchain spell cache
-ERR_TOOLCHAIN_SORCERY=98 # sorcery not installed in toolchain chroot
-ERR_TOOLCHAIN_RESURRECT=99 # could not resurrect spell using sorcery
-
-
-# error messages
-ERR_MSGS=(
- # base error codes
- "operation succeeded" # ERR_OK
- "fatal error" # ERR_FATAL
- "could not make directory" # ERR_MK_DIR
- "directory already exists" # ERR_DIR_EXISTS
- "file not found" #
ERR_FILE_NOT_FOUND
- "directory not found" #
ERR_DIR_NOT_FOUND
- "could not copy file" # ERR_CP_FILE
- "could not chmod file" # ERR_CHMOD_FILE
- "could not remove files" # ERR_RM_FILES
-
- # libcauldron base
- "could not load cauldron library" #
ERR_LOAD_LIBRARY
- "could not clean up build dir" #
ERR_CLEANUP_BUILD
- "could not clean up tmp dir" # ERR_CLEANUP_TMP
-
- # libcauldron build
- "could not unpack spell cache in build dir" #
ERR_UNPACK_CACHE
- "could not remove temporary spell cache file" # ERR_RM_CACHE
- "could not get host triple needed for builds" # ERR_HOST_TRIPLE
- "build directory sorcery spool does not exist" # ERR_BUILD_SPOOL
- "resolv.conf missing in the build dir" # ERR_RESOLV
-
- # libcauldron cleaner files
- "cleanfile not found" #
ERR_CLEAN_CLEANER
- "failed to clean dir from ISO" # ERR_CLEAN_DIR
- "failed to clean file from ISO" # ERR_CLEAN_FILE
-
- # libcauldron enchantment
- "could not source enchant config" #
ERR_ENCHANT_CONFIG
- "couldn't create the installer dir" #
ERR_INSTALLER_DIR
- "could not copy installer to ISO" #
ERR_COPY_INSTALLER
- "could not link installer programs to usr/sbin/" #
ERR_LINK_INSTALLER
-
- # libcauldron final product
- "could not package the final ISO file" # ERR_ISO_PACKAGE
- "could not compress final ISO file" #
ERR_ISO_COMPRESS
- "could not package the final SYS file" # ERR_SYS_PACKAGE
- "could not compress final SYS file" #
ERR_SYS_COMPRESS
-
- # lib.chroot
- "target chroot dir undefined" #
ERR_CHROOT_UNDEF
- "could not init chroot" # ERR_CHROOT_INIT
- "could not clean up chroot" # ERR_CHROOT_DONE
- "cauldron chroot not initialized" #
ERR_CHROOT_NOT_INIT
- "could not execute chroot command" # ERR_CHROOT_EXEC
- "chroot cast failed" # ERR_CHROOT_CAST
- "chroot dispel failed" #
ERR_CHROOT_DISPEL
- "chroot rebuild failed" #
ERR_CHROOT_REBUILD
- "chroot already defined -- nesting not allowed" # ERR_CHROOT_NEST
-
- # lib.init
- "problem installing built initramfs into ISO fs" #
ERR_INIT_INSTALL_RAMFS
- "problem installing built initramdisk into ISO fs" #
ERR_INIT_INSTALL_RD
- "could not build initramfs" #
ERR_INIT_MAKE_RAMFS
- "could not build initramdisk" #
ERR_INIT_MAKE_RD
- "could not make filesystem for initramfs/ramdisk" #
ERR_INIT_MAKE_FS
-
- # lib.sorcerous
- "sorcery not set to archive" #
ERR_SORCEROUS_ARCHIVE
- "could not load target sorcery" #
ERR_SORCEROUS_TARGET
- "could not load host sorcery" #
ERR_SORCEROUS_HOST
- "could not create spell cache" #
ERR_SORCEROUS_CREATE_CACHE
- "couldn't create ISO sorcery local config dir" #
ERR_SORCEROUS_ISO_SORCERY_CONFIG
- "could not download sorcery" #
ERR_SORCEROUS_DOWNLOAD
- "could not unpack a valid sorcery install" #
ERR_SORCEROUS_UNPACK
- "could not install sorcery into the build dir" #
ERR_SORCEROUS_INSTALL
-
- # lib.toolchain
- "could not copy spell cache file to build dir" #
ERR_TOOLCHAIN_CP_CACHE
- "could not build spell cache file" #
ERR_TOOLCHAIN_BUILD_CACHE
- "cross-toolchain failed at stage 1" #
ERR_TOOLCHAIN_STAGE1
- "cross-toolchain failed at stage 2" #
ERR_TOOLCHAIN_STAGE2
- "cross-toolchain failed at stage 3" #
ERR_TOOLCHAIN_STAGE3
- "failed to cast toolchain spell" #
ERR_TOOLCHAIN_CAST
- "failed to dispel toolchain spell" #
ERR_TOOLCHAIN_DISPEL
- "failed to generate toolchain spell cache" #
ERR_TOOLCHAIN_GATHER
- "sorcery not installed in toolchain chroot" #
ERR_TOOLCHAIN_SORCERY
- "could not resurrect spell using sorcery" #
ERR_TOOLCHAIN_RESURRECT
- )
+liberror_add_error ERR_TOOLCHAIN_CP_CACHE \
+ "could not copy toolchain spell cache from host system into build
directory"
+liberror_add_error ERR_TOOLCHAIN_BUILD_CACHE \
+ "could not build toolchain cache file from spell install info"
+liberror_add_error ERR_TOOLCHAIN_STAGE1 \
+ "cross-toolchain stage 1 failed"
+liberror_add_error ERR_TOOLCHAIN_STAGE2 \
+ "cross-toolchain stage 2 failed"
+liberror_add_error ERR_TOOLCHAIN_STAGE3 \
+ "cross-toolchain stage 3 failed"
+liberror_add_error ERR_TOOLCHAIN_CAST \
+ "could not cast toolchain spell cache"
+liberror_add_error ERR_TOOLCHAIN_DISPEL \
+ "could not dispel toolchain spell cache"
+liberror_add_error ERR_TOOLCHAIN_GATHER \
+ "could not generate toolchain spell cache"
+liberror_add_error ERR_TOOLCHAIN_SORCERY \
+ "sorcery not found in toolchain root"
+liberror_add_error ERR_TOOLCHAIN_RESURRECT \
+ "could not resurrect spell using sorcery"


#-------------------------------------------------------------------------------
##
diff --git a/cauldron/etc/config b/cauldron/etc/config
index 8e3403a..1b0dfcb 100644
--- a/cauldron/etc/config
+++ b/cauldron/etc/config
@@ -34,7 +34,7 @@
# name of the sorcery file to download

CAULDRON_SORCERY_PKG="${CAULDRON_SORCERY_PACKAGE:-sorcery-${CAULDRON_SORCERY_BRANCH}.tar.bz2}"
# URL to download sorcery from
-
CAULDRON_SORCERY_URL="${CAULDRON_SORCERY_URL:-http://download.sourcemage.org/sorcery/}";
+
CAULDRON_SORCERY_URL="${CAULDRON_SORCERY_URL:-http://download.sourcemage.org/sorcery/$CAULDRON_SORCERY_PKG}";

# list of installers to include in the ISO
CAULDRON_INSTALLERS=(
diff --git a/cauldron/lib.sorcerous b/cauldron/lib.sorcerous
index 4d7a21c..71233a8 100644
--- a/cauldron/lib.sorcerous
+++ b/cauldron/lib.sorcerous
@@ -98,8 +98,7 @@ function cauldron_sorcerous_cross_configure() {

#-------------------------------------------------------------------------------
function cauldron_sorcerous_download() {
local spool="${1:-$CAULDRON_BUILD/var/spool/sorcery}"
- local sorcery_url="${CAULDRON_SORCERY_URL%/}"
- local sorcery="$CAULDRON_SORCERY_PKG"
+ local sorcery_url="${CAULDRON_SORCERY_URL}"
local url_get=( "${CAULDRON_URL_DL_CMD[@]}" )

# ensure the spool dir exists for getting spell sources
@@ -112,7 +111,7 @@ function cauldron_sorcerous_download() {
# run in a subshell as an easy way of not messing with the working
directory
(
cd "$spool"
- "${url_get[@]}" "$sorcery_url/$sorcery" ||
+ "${url_get[@]}" "$sorcery_url" ||
return $ERR_SORCEROUS_DOWNLOAD
)
fi &&
diff --git a/enchantment/errorcodes b/enchantment/errorcodes
index f01c202..202218d 100644
--- a/enchantment/errorcodes
+++ b/enchantment/errorcodes
@@ -19,184 +19,96 @@
# ERROR definitions

#-------------------------------------------------------------------------------
# base error codes
-ERR_OK=0 # everything is good
-ERR_FATAL=1 # fatal error (missing cauldron libs, etc.)
-ERR_MK_DIR=2 # couldn't make directory
-ERR_DIR_EXISTS=3 # directory already exists
-ERR_FILE_NOT_FOUND=5 # requested file not found
-ERR_DIR_NOT_FOUND=6 # requested dir not found
+liberror_add_error ERR_MK_DIR "could not make directory"
+liberror_add_error ERR_DIR_EXISTS "directory already exists"
+liberror_add_error ERR_FILE_NOT_FOUND "requested file not found"
+liberror_add_error ERR_DIR_NOT_FOUND "requested directory not found"

# libenchantment base
-ERR_LOAD_LIBRARY=10 # could not load enchantment library
-ERR_PREPARE=11 # could not initialize enchantment
-ERR_CLEANUP=12 # could not clean up after finishing
+liberror_add_error ERR_LOAD_LIBRARY "could not load enchantment library"
+liberror_add_error ERR_PREPARE "could not initialize enchantment"
+liberror_add_error ERR_CLEANUP "could not clean up after finishing"

# libenchantment module processing
-ERR_GET_CURRENT=20 # could not get current module
-ERR_GET_NEXT=21 # could not get next module
-ERR_GET_PREV=22 # could not get previous module
-ERR_SET_CURRENT=24 # could not set current module
-ERR_SET_NEXT=25 # could not set next module
-ERR_SET_PREV=26 # could not set previous module
+liberror_add_error ERR_GET_CURRENT "could not get current module"
+liberror_add_error ERR_GET_NEXT "could not get next module"
+liberror_add_error ERR_GET_PREV "could not get previous module"
+liberror_add_error ERR_SET_CURRENT "could not set current module"
+liberror_add_error ERR_SET_NEXT "could not set next module"
+liberror_add_error ERR_SET_PREV "could not set previous module"

# history
-ERR_HISTORY_BACK=31 # could not go back in install history
-ERR_HISTORY_FORWARD=32 # could not go forward in install history
+liberror_add_error ERR_HISTORY_BACK "could not go back in install history"
+liberror_add_error ERR_HISTORY_FORWARD "could not go forward in install
history"

# lib.chroot
-ERR_CHROOT_INIT=40 # could not initialize chroot
-ERR_CHROOT_NOT_INIT=41 # tried to use the chroot but its not initialized
-ERR_CHROOT_UNDEF=42 # chroot command undefined
-ERR_CHROOT_EXEC=43 # could not execute chroot command
-ERR_CHROOT_DONE=44 # could not properly clean up chroot
+liberror_add_error ERR_CHROOT_INIT "could not initialized chroot"
+liberror_add_error ERR_CHROOT_NOT_INIT "chroot not initialized"
+liberror_add_error ERR_CHROOT_UNDEF "chroot command undefined"
+liberror_add_error ERR_CHROOT_EXEC "could not execute chroot command"
+liberror_add_error ERR_CHROOT_DONE "could not properly clean up chroot"

# lib.i18n keymap
-ERR_KEYMAP_EXIT=50 # keymap processing finished
-ERR_KEYMAP_PREFIX=51 # invalid keymap prefix
-ERR_KEYMAP_LIST=52 # keymap list empty or not provided
-ERR_KEYMAP_LIST_SIZE=53 # invalid list size provided
-ERR_KEYMAP_INPUT=54 # invalid user input
-ERR_KEYMAP_LOAD=55 # could not load selected keymap
-ERR_KEYMAP_GET=56 # could not get selected keymap
-ERR_KEYMAP_SET=57 # could not set selected keymap
+liberror_add_error ERR_KEYMAP_EXIT "keymap processing finished"
+liberror_add_error ERR_KEYMAP_PREFIX "invalid keymap prefix"
+liberror_add_error ERR_KEYMAP_LIST "keymap list empty or not provided"
+liberror_add_error ERR_KEYMAP_LIST_SIZE "invalid list size provided"
+liberror_add_error ERR_KEYMAP_INPUT "invalid user input"
+liberror_add_error ERR_KEYMAP_LOAD "could not load selected keymap"
+liberror_add_error ERR_KEYMAP_GET "could not get selected keymap"
+liberror_add_error ERR_KEYMAP_SET "could not set selected keymap"

# lib.install
-ERR_INSTALL_DIR=60 # could not install directory
-ERR_INSTALL_FILE=61 # could not install file
-ERR_INSTALL_CACHES=62 # could not install spell caches
-ERR_INSTALL_SOURCES=63 # could not install spell sources
-ERR_INSTALL_KERNEL=64 # could not install kernel image
-ERR_INSTALL_KMODS=65 # could not install kernel modules
-ERR_INSTALL_DEPMOD=66 # could not perform depmod in install
+liberror_add_error ERR_INSTALL_DIR "could not install directory"
+liberror_add_error ERR_INSTALL_FILE "could not install file"
+liberror_add_error ERR_INSTALL_CACHES "could not install spell caches"
+liberror_add_error ERR_INSTALL_SOURCES "could not install spell sources"
+liberror_add_error ERR_INSTALL_KERNEL "could not install kernel image"
+liberror_add_error ERR_INSTALL_KMODS "could not install kernel modules"
+liberror_add_error ERR_INSTALL_DEPMOD "could not perform depmod in install"

# lib.module
-ERR_MODULE_NONE=70 # no modules found
-ERR_MODULE_SCRIPT=71 # could not process module script
-ERR_MODULE_ENTER=72 # could not process module entry
-ERR_MODULE_EXIT=73 # could not process module exit
-ERR_MODULE_GET_NUM=74 # could not get number of current module
-
-# lib.potion base
-ERR_POTION_UPDATE=80 # could not process installer state
-ERR_POTION_DIR=81 # potion directory is missing
-ERR_POTION_CACHE_FILE=82 # couldn't copy file into potion dir
-ERR_POTION_ARCHIVE_FORMAT=83 # unknown archive format
-ERR_POTION_ARCHIVE=84 # could not build archive of potion
-ERR_POTION_COMPRESS=85 # could not compress potion archive
+liberror_add_error ERR_MODULE_NONE "no modules found"
+liberror_add_error ERR_MODULE_SCRIPT "could not process module script"
+liberror_add_error ERR_MODULE_ENTER "could not process module entry"
+liberror_add_error ERR_MODULE_EXIT "could not process module exit"
+liberror_add_error ERR_MODULE_GET_NUM "could not get number of current
module"
+
+# lib.potion
+liberror_add_error ERR_POTION_DIR "potion directory not found"
+liberror_add_error ERR_POTION_GET_HASHSUM "could not read hashsum of file"
+liberror_add_error ERR_POTION_SET_HASHSUM "could not store hashsum of file"
+liberror_add_error ERR_POTION_CACHE_FILE \
+ "could not copy file into potion directory"
+liberror_add_error ERR_POTION_ARCHIVE_FORMAT "unknown archive format"
+liberror_add_error ERR_POTION_ARCHIVE "could not make potion archive"
+liberror_add_error ERR_POTION_COMPRESS "could not compress potion archive"

# lib.potion gets
-ERR_POTION_GET_HASHSUM=90 # could not read hashsum of file
-ERR_POTION_GET_BOOTLOADER=91 # could not read bootloader config
-ERR_POTION_GET_CONFS=92 # could not read target system configs
-ERR_POTION_GET_FILESYSTEMS=93 # could not read filesystems
-ERR_POTION_GET_KERNEL=94 # could not read kernel config
-ERR_POTION_GET_MOUNT_POINTS=95 # could not read mount points
-ERR_POTION_GET_OPT_SPELLS=96 # could not read optional spell selection
-ERR_POTION_GET_PARTITIONS=97 # could not read partitions
-ERR_POTION_GET_USERS=98 # could not read user/group config
-
-# lib.potion checks
-ERR_POTION_SET_HASHSUM=100 # could not store hashsum of file
-ERR_POTION_CHK_BOOTLOADER=101 # could not store bootloader config
-ERR_POTION_CHK_CONFS=102 # could not store target system configs
-ERR_POTION_CHK_FILESYSTEMS=104 # could not store filesystems
-ERR_POTION_CHK_KERNEL=104 # could not store kernel config
-ERR_POTION_CHK_MOUNT_POINTS=105 # could not store mount points
-ERR_POTION_CHK_OPT_SPELLS=106 # could not store optional spell selection
-ERR_POTION_CHK_PARTITIONS=107 # could not store partitions
-ERR_POTION_CHK_USERS=108 # could not store user/group config
-
-# error messages
-ERR_MSGS=(
- # base error codes
- "operation succeeded" # ERR_OK
- "fatal error" # ERR_FATAL
- "could not make directory" # ERR_MK_DIR
- "directory already exists" # ERR_DIR_EXISTS
- "file not found" #
ERR_FILE_NOT_FOUND
- "directory not found" #
ERR_DIR_NOT_FOUND
-
- # libenchantment base
- "could not load enchantment library" #
ERR_LOAD_LIBRARY
- "could not initialize enchantment" # ERR_PREPARE
- "could not clean up after finishing" # ERR_CLEANUP
-
- # libenchantment module processing
- "could not get current module" # ERR_GET_CURRENT
- "could not get next module" # ERR_GET_NEXT
- "could not get previous module" # ERR_GET_PREV
- "could not set current module" # ERR_SET_CURRENT
- "could not set next module" # ERR_SET_NEXT
- "could not set previous module" # ERR_SET_PREV
-
- # history
- "could not go back in install history" #
ERR_HISTORY_BACK
- "could not go forward in install history" #
ERR_HISTORY_FORWARD
-
- # lib.chroot
- "could not initialize chroot" # ERR_CHROOT_INIT
- "tried to use the chroot but its not initialized" #
ERR_CHROOT_NOT_INIT
- "chroot command undefined" #
ERR_CHROOT_UNDEF
- "could not execute chroot command" # ERR_CHROOT_EXEC
- "could not properly clean up chroot" # ERR_CHROOT_DONE
-
- # lib.i18n keymap
- "keymap processing finished" # ERR_KEYMAP_EXIT
- "invalid keymap prefix" #
ERR_KEYMAP_PREFIX
- "keymap list empty or not provided" # ERR_KEYMAP_LIST
- "invalid list size provided" #
ERR_KEYMAP_LIST_SIZE
- "invalid user input" #
ERR_KEYMAP_INPUT
- "could not load selected keymap" # ERR_KEYMAP_LOAD
- "could not get selected keymap" # ERR_KEYMAP_GET
- "could not set selected keymap" # ERR_KEYMAP_SET
-
- # lib.install
- "could not install directory" # ERR_INSTALL_DIR
- "could not install file" #
ERR_INSTALL_FILE
- "could not install spell caches" #
ERR_INSTALL_CACHES
- "could not install spell sources" #
ERR_INSTALL_SOURCES
- "could not install kernel image" #
ERR_INSTALL_KERNEL
- "could not install kernel modules" #
ERR_INSTALL_KMODS
- "could not perform depmod in install" #
ERR_INSTALL_DEPMOD
-
- # lib.module
- "no modules found" # ERR_MODULE_NONE
- "could not process module script" #
ERR_MODULE_SCRIPT
- "could not process module entry" #
ERR_MODULE_ENTER
- "could not process module exit" # ERR_MODULE_EXIT
- "could not get number of current module" #
ERR_MODULE_GET_NUM
-
- # lib.potion base
- "could not process installer state" #
ERR_POTION_UPDATE
- "potion directory is missing" # ERR_POTION_DIR
- "could not cache file" #
ERR_POTION_CACHE_FILE
- "unknown archive format" #
ERR_POTION_ARCHIVE_FORMAT
- "could not create potion archive" #
ERR_POTION_ARCHIVE
- "could not compress potion archive" #
ERR_POTION_COMPRESS
-
- # lib.potion gets
- "could not read hashsum of file" #
ERR_POTION_GET_HASHSUM
- "could not read bootloader config" #
ERR_POTION_GET_BOOTLOADER
- "could not read target system configs" #
ERR_POTION_GET_CONFS
- "could not read filesystems" #
ERR_POTION_GET_FILESYSTEMS
- "could not read kernel config" #
ERR_POTION_GET_KERNEL
- "could not read mount points" #
ERR_POTION_GET_MOUNT_POINTS
- "could not read optional spell selection" #
ERR_POTION_GET_OPT_SPELLS
- "could not read partitions" #
ERR_POTION_GET_PARTITIONS
- "could not read user/group config" #
ERR_POTION_GET_USERS
-
- # lib.potion checks
- "could not store hashsum of file" #
ERR_POTION_SET_HASHSUM
- "could not store bootloader config" #
ERR_POTION_CHK_BOOTLOADER
- "could not store target system configs" #
ERR_POTION_CHK_CONFS
- "could not store filesystems" #
ERR_POTION_CHK_FILESYSTEMS
- "could not store kernel config" #
ERR_POTION_CHK_KERNEL
- "could not store mount points" #
ERR_POTION_CHK_MOUNT_POINTS
- "could not store optional spell selection" #
ERR_POTION_CHK_OPT_SPELLS
- "could not store partitions" #
ERR_POTION_CHK_PARTITIONS
- "could not store user/group config" #
ERR_POTION_CHK_USERS
-
- )
+liberror_add_error ERR_POTION_GET_BOOTLOADER "could not read bootloader
config"
+liberror_add_error ERR_POTION_GET_CONFS "could not read target system
configs"
+liberror_add_error ERR_POTION_GET_FILESYSTEMS "could not read filesystems"
+liberror_add_error ERR_POTION_GET_KERNEL "could not read kernel config"
+liberror_add_error ERR_POTION_GET_MOUNT_POINTS "could not read mount points"
+liberror_add_error ERR_POTION_GET_OPT_SPELLS \
+ "could not read optional spell selection"
+liberror_add_error ERR_POTION_GET_PARTITIONS "could not read partitions"
+liberror_add_error ERR_POTION_GET_USERS "could not read user/group config"
+
+# lib.potion updates
+liberror_add_error ERR_POTION_UPDATE_BOOTLOADER \
+ "could not update bootloader config"
+liberror_add_error ERR_POTION_UPDATE_CONFS \
+ "could not update target system configs"
+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 \
+ "could not update spell sources selection"
+liberror_add_error ERR_POTION_UPDATE_SPELL_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"


#-------------------------------------------------------------------------------
##
diff --git a/enchantment/shell/bin/enchantment
b/enchantment/shell/bin/enchantment
index ace4603..2182c51 100755
--- a/enchantment/shell/bin/enchantment
+++ b/enchantment/shell/bin/enchantment
@@ -33,17 +33,10 @@ then
fi

# add local error message(s) and error code(s)
-ERR_INSTALLER_FUNCS="$(echo $((${#ERR_MSGS[*]}+1)))"
-ERR_INSTALLER_CHROOT_MOUNT="$(echo $((${#ERR_MSGS[*]}+2)))"
-ERR_INSTALLER_CHROOT_EXEC="$(echo $((${#ERR_MSGS[*]}+3)))"
-ERR_INSTALLER_CHROOT_UMOUNT="$(echo $((${#ERR_MSGS[*]}+4)))"
-$enchant_shell_err_msgs=(
- "could not load $ENCHANT_INSTALLER functions file"
- "could not mount chroot subdirs"
- "could not execute chroot command"
- "could not unmount chroot subdirs"
- )
-$ERR_MSGS=( "$ERR_MSGS" "${enchant_shell_err_msgs[*]}" )
+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" ]] ||
diff --git a/lib/liberror b/lib/liberror
index b73eaeb..3e00ee4 100755
--- a/lib/liberror
+++ b/lib/liberror
@@ -36,9 +36,43 @@ ERR_MSGS=(
)


#-------------------------------------------------------------------------------
+# Internal definitions - do not use in external/public code!
+#-------------------------------------------------------------------------------
+# error counter -- for internal use only!
+LIBERR_ERRCODE_COUNT=2
+
+#-------------------------------------------------------------------------------
# Function definitions

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

#-------------------------------------------------------------------------------
+## @param error name (required)
+## @param error message (required)
+##
+## Defines the given error code with corresponding name and message.
+## Automatically assigns the next available number to the error code.
+## Usage example:
+## liberror_add_error ERR_EXAMPLE "example error message"
+##
+#-------------------------------------------------------------------------------
+function liberror_add_error() {
+ local code="$1"
+ local msg="$2"
+
+ [[ -z "$code" || -z "$msg" ]] && return $ERR_FATAL
+
+ [[ "$LIBERR_ERRCODE_COUNT" -ge 255 ]] && return $ERR_FATAL
+
+ # define the error code itself
+ eval "$code"=$LIBERR_ERRCODE_COUNT
+
+ # define a corresponding message in the message array
+ ERR_MSGS[$LIBERR_ERRCODE_COUNT]="$msg"
+ ((LIBERR_ERRCODE_COUNT++))
+
+ return $ERR_OK
+}
+
+#-------------------------------------------------------------------------------
## @param error number
## @param output stream (default is 1 [stdout], 2 for stderr)
##
diff --git a/ward/libward b/ward/libward
index b0a448a..ca3374b 100644
--- a/ward/libward
+++ b/ward/libward
@@ -235,50 +235,125 @@ function ward_error_codes() {
liberror_die $ERR_FATAL
fi

- if ! source "$errorcodes" 2 > /dev/null
- then
- libcolor_error "error: could not source error code file "
- libcolor_file "$errorcodes"
- echo ""
- fi
-
# get the list of defined error codes
- codes=( $(grep -o '^ERR_[A-Z_]\+[0-9]*' "$errorcodes" | grep -v
'ERR_MSGS') )
+ codes=( $(gawk '/liberror_add_error/ {print $2}' "$errorcodes") )
+
+ # get the list of defined error messages
+ eval msgs=(
+ $(gawk \
+ '/liberror_add_error/ {if($3 == "\\"){getline} sub(/^[^"]*"/,"\"");
print}' \
+ "$errorcodes"
+ )
+ )

# test if the number of messages matches the number of error codes
- if [[ "${#codes[@]}" -ne "${#ERR_MSGS[@]}" ]]
+ if [[ "${#codes[@]}" -ne "${#msgs[@]}" ]]
then
libcolor_error "error: "
libcolor_error "number of error codes not equal to number of messages"
echo ""
libcolor_error "${leader}codes: ${#codes[@]}"
echo ""
- libcolor_error "${leader}messages: ${#ERR_MSGS[@]}"
+ libcolor_error "${leader}messages: ${#msgs[@]}"
echo ""
fi
+}

- # for every error code defined, make sure there is a corresponding message
- for ((count=0; "$count" < "${#codes[@]}"; count++))
+#-------------------------------------------------------------------------------
+## @param -p base path to sources (optional)
+## @param -d base path to definition file (optional)
+## @param definition file (required)
+## @param source1 [source2 source3...] (required)
+##
+## Tests whether any error variables used in source1 (source2, source3, etc.)
+## are defined in the errorr definition file. Any error variables that are
used
+## but not defined in the definition file are output via libcolor_warn,
preceded
+## by the file they were found in via libcolor_file. Both base paths default
to
+## the current working directory if not supplied.
+##
+#-------------------------------------------------------------------------------
+function ward_error_variables() {
+ local fpath="."
+ local epath="."
+ local errorcodes=""
+ local file=""
+
+ # process any optional parameters
+ while [[ "${1:0:1}" == "-" ]]
do
- if ! grep -q "${codes[count]}\$" "$errorcodes"
- then
- libcolor_error "error: ${codes[count]}: "
- libcolor_error "DEFINED but has no corresponding message"
- echo ""
- fi
+ case "$1" in
+ "-p")
+ fpath="${2%/}"
+ shift 2
+ ;;
+ "-d")
+ epath="${2%/}"
+ shift 2
+ ;;
+ *)
+ libcolor_error "error: invalid function parameter $1"
+ echo ""
+ liberror_die $ERR_FATAL
+ ;;
+ esac
done

- # for every error message defined, make sure there is a corresponding code
- for ((count=0; "$count" < "${#ERR_MSGS[@]}"; count++))
+ # make sure we have a good source file path component
+ if [[ ! -d "$fpath" ]]
+ then
+ echo "error: source file search path not recognized"
+ liberror_die $ERR_FATAL
+ fi
+
+ # make sure we have a good definition file path component
+ if [[ ! -d "$epath" ]]
+ then
+ echo "error: error code file search path not recognized"
+ liberror_die $ERR_FATAL
+ fi
+
+ # get the defines file, then drop it from the argument list
+ errorcodes="$1"
+ shift
+
+ # if defines is not given with an absolute path, add the base path prefix
+ [[ "${errorcodes:0:1}" != "/" ]] && errorcodes="$epath/$errorcodes"
+
+ # make sure the defines file exists, otherwise we can't check anything
+ if [[ ! -f "$errorcodes" ]]
+ then
+ echo "error: error code file not found"
+ liberror_die $ERR_FATAL
+ fi
+
+ # get the list of defined error codes
+ codes=( $(gawk '/liberror_add_error/ {print $2}' "$errorcodes") )
+
+ while [[ $# -gt 0 ]]
do
- msgcode=$(grep "${ERR_MSGS[count]}.*# " "$errorcodes" | sed 's/.*# //')
-
- if ! grep -q "^${msgcode}=" "$errorcodes"
- then
- libcolor_error "error: $msgcode: "
- libcolor_error "NOT DEFINED but message is"
- echo ""
- fi
+ file="$1"
+ shift
+
+ # if file is not given with an absolute path, add the base path prefix
+ [[ "${file:0:1}" != "/" ]] && file="$fpath/$file"
+
+ [[ -f "$file" ]] || continue
+
+ # as per the API specification, all global variables are required to be
+ # uppercase, and must begin with a letter, containing only letters,
+ # 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
+
+ if ! echo " ${codes[*]} " | grep -q " $search "
+ then
+ echo "$(libcolor_file $file): $(libcolor_warn $search)"
+ fi
+ done
done
}

diff --git a/ward/ward-errorcodes b/ward/ward-errorcodes
index 5628b8b..8b934c1 100755
--- a/ward/ward-errorcodes
+++ b/ward/ward-errorcodes
@@ -80,7 +80,7 @@ then
# check cauldron files
libcolor_notice "Checking cauldron sources for undefined error codes"
echo ""
- ward_global_variables -p "$cauldron" "$c_codes" "${sources[@]}" | \
+ ward_error_variables -p "$cauldron" "$c_codes" "${sources[@]}" | \
grep '[^A-Z_]ERR_[A-Z_]*'
fi

@@ -98,7 +98,7 @@ then
# check enchantment files
libcolor_notice "Checking enchantment sources for undefined error codes"
echo ""
- ward_global_variables -p "$enchantment" "$e_codes" "${sources[@]}" | \
+ ward_error_variables -p "$enchantment" "$e_codes" "${sources[@]}" | \
grep '[^A-Z_]ERR_[A-Z_]*'
fi




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

Archive powered by MHonArc 2.6.24.

Top of Page