Skip to Content.
Sympa Menu

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

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 (8e8bf8f131c429f205349ae09bc15b94dec052df)
  • Date: Wed, 29 Dec 2010 23:10:51 -0600

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

cauldron/errorcodes | 58 ++++++++----
cauldron/etc/config | 52 +++++++++-
cauldron/lib.chroot | 6 -
cauldron/lib.init | 4
cauldron/lib.sorcerous | 6 -
cauldron/lib.toolchain | 143 ++++++++++++++++++++++++++++--
cauldron/libcauldron | 224
++++++-----------------------------------------
ward/cauldron_sources | 14 +-
ward/enchantment_sources | 20 ++--
ward/libward | 198 +++++++++++++++++++++++++++++++++++++----
ward/ward-configvars | 87 ++++++++++--------
ward/ward-errorcodes | 103 +++++++++++----------
ward/ward-functions | 66 +++++++++----
13 files changed, 603 insertions(+), 378 deletions(-)

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

cauldron: update and sync error codes

Update the errorcodes definition file to implement needed error codes
for all the new code, and make sure that the error codes used are
correct across the libraries.

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

cauldron: correct missing/inaccurate config vars

Add missing config variables to the config file, and make sure that the
libraries don't use misnamed variables.

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

ward: frontends learn to run only one project

The frontends (ward-*) will by default run their analyses over both the
cauldron and enchantment sources, but if passed an argument of either
cualdron or enchantment then they will only run over the given project.

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

ward: generalize source file listing

Add a new function to libward for acquiring the list of source files to
run analysis over, and make it general (i.e., not cauldron-specific).

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

ward: make path management more generalized

Don't force path management to be specific to cauldron, and try not to
have hardcoded paths in general. This enables libward to be much more
flexible in handling file arguments so that it can be adapted for other
projects more easily. Also fixed a few leftover instances of
DELINT_PATH->WARD_PATH renamings I missed.

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

cauldron: correct sorcery config vars

Clean up the ordering/formatting of the sorcery-related configuration
variables in etc/config, and add missing eval statements to ensure the
calculated values are used, rather than defining to the commands to run.

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

cauldron: common libs base->common

Move common libraries into their own directory (for install and
reference), and clarify what they are for in the comment header in
libcauldron.

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

cauldron: update enchantment installation

Bring the linking of enchantment installer binaries into the iso main
filesystem in sync with current enchantment implementation. Update the
function comment header accordingly.

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

cauldron: generalize system/iso packaging

Rather than directly relying specifically on mkisofs, allow the user to
redefine the command to be used to whatever their preference is. Also
define a separate function for packaging the system (system.tar.bz2) and
generalize that as well to allow for different archiving/compression
schemes. Both functions now have clear names that follow the API
specification as well.

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

cauldron: remove superfluous libcauldron function

The function to build the system should be handled by a combination of
the functionality provided by lib.toolchain and commands processed by
the front-end. It shouldn't exist as a separate function in libcauldron.
The needed functionality is already present in lib.toolchain, so the
rest is up to the front-end (to appear), and the function can safely be
removed from libcauldron.

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

cauldron: missing source of enchantment config

libcauldron needs to source the enchantment config in order to get
access to ENCHANT_DATA. This may be changed later if a better solution
is worked out, or if support for adding enchantment to non-standard
locations in the generated iso is dropped (such support is not needed
per se, but we want to provide as much flexibility to the user as
possible, unless there is a good reason not to).

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

cauldron: more explicit function header comments

Make some function headers in lib.toolchain a little more explicit as to
what they expect and how they function.

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

cauldron: move build functions from libcauldron

Move 3 functions that were in libcauldron into lib.toolchain, since
their only purpose is in generating the original toolchain/chroot used
to build all the content for the generated iso. Additionally, rename
said functions in line with the API naming scheme.

diff --git a/cauldron/errorcodes b/cauldron/errorcodes
index fe768c5..b702ba2 100644
--- a/cauldron/errorcodes
+++ b/cauldron/errorcodes
@@ -25,6 +25,9 @@ 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

# libcauldron base
ERR_LOAD_LIBRARY=10 # problem loading a library/include
@@ -50,9 +53,10 @@ ERR_COPY_INSTALLER=42 # could not copy installer to ISO
ERR_LINK_INSTALLER=43 # could not copy installer to ISO

# libcauldron final product
-ERR_MKISOFS=50 # could not create final ISO filesystem
-ERR_MK_ISOFS=51 # could not create the final ISO file
-ERR_COMPRESS_ISO=52 # could not compress final ISO file
+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

# lib.chroot
ERR_CHROOT_UNDEF=60 # chroot TARGET is undefined
@@ -66,16 +70,21 @@ ERR_CHROOT_REBUILD=67 # chroot rebuild failed
ERR_CHROOT_NEST=68 # chroot already defined -- nesting not allowed

# lib.init
-ERR_INSTALL_RAMFS=70 # problem installing built initramfs into ISO fs
+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

# lib.sorcerous
-ERR_SORCEROUS_CREATE_CACHE=80 # error creating spell cache
-ERR_SORCEROUS_HOST_SORCERY=81 # sorcery not installed on host
-ERR_SORCEROUS_TARGET_SORCERY=82 # missing target sorcery files
-ERR_SORCEROUS_ISO_SORCERY_CONFIG=83 # couldn't create the ISO local sorcery
config dir
-ERR_SORCEROUS_DOWNLOAD=84 # could not download sorcery
-ERR_SORCEROUS_INSTALL=85 # could not install sorcery into the build dir
-ERR_SORCEROUS_ARCHIVE=86 # target sorcery not set to archive casts
+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

# lib.toolchain
ERR_TOOLCHAIN_CP_CACHE=90 # problem copying spell cache from HOST to
build dir
@@ -87,6 +96,7 @@ 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
@@ -98,6 +108,9 @@ ERR_MSGS=(
"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
@@ -123,9 +136,10 @@ ERR_MSGS=(
"could not link installer programs to usr/sbin/" #
ERR_LINK_INSTALLER

# libcauldron final product
- "could not create the final ISO file" # ERR_MK_ISOFS
- "could not create final ISO filesystem" # ERR_MKISOFS
- "could not compress final ISO file" #
ERR_COMPRESS_ISO
+ "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
@@ -139,20 +153,25 @@ ERR_MSGS=(
"chroot already defined -- nesting not allowed" # ERR_CHROOT_NEST

# lib.init
- "problem installing built initramfs into ISO fs" #
ERR_INSTALL_RAMFS
+ "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_SORCERY
- "could not load host sorcery" #
ERR_SORCEROUS_HOST_SORCERY
+ "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
- "could not build spell cache file" #
ERR_TOOLCHAIN_MAKE
+ "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
@@ -160,6 +179,7 @@ ERR_MSGS=(
"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
)


#-------------------------------------------------------------------------------
diff --git a/cauldron/etc/config b/cauldron/etc/config
index 44d2ab1..8e3403a 100644
--- a/cauldron/etc/config
+++ b/cauldron/etc/config
@@ -9,6 +9,9 @@

# filename of the produced .iso (should follow Cauldron naming
conventions)
CAULDRON_ISO_NAME="${CAULDRON_ISO_NAME:-smgl-devel-$(date
+%Y%m%d).$CAULDRON_ARCH}"
+ # filename of the compressed system archive that goes into the base
of
+ # the iso filesystem for base installation
+ CAULDRON_SYS_NAME="${CAULDRON_SYS_NAME:-system.tar.bz2}"

# the version of the kernel to be used in the .iso
# if empty, then it will default to the version in cauldron
@@ -25,7 +28,10 @@

# branch of sorcery to use in the ISO
CAULDRON_SORCERY_BRANCH="${CAULDRON_SORCERY_BRANCH:-stable}"
- # branch of sorcery to use in the ISO
+ # whether to always download sorcery anew or use an already downloaded
file
+ # if found
+ CAULDRON_FORCE_DOWNLOAD="${CAULDRON_FORCE_DOWNLOAD:-yes}"
+ # 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/}";
@@ -48,6 +54,8 @@
CAULDRON_BASE="${CAULDRON_BASE:-$CAULDRON_HOST/usr/share/smgl}"
# path to the host cauldron library modules
CAULDRON_LIBS="${CAULDRON_LIBS:-$CAULDRON_BASE/cauldron}"
+ # path to Source Mage common library modules
+ CAULDRON_COMMON="${CAULDRON_COMMON:-$CAULDRON_BASE/common}"
# path to the host cauldron configs
CAULDRON_DATA="${CAULDRON_DATA:-$CAULDRON_HOST/etc/cauldron}"

@@ -84,10 +92,35 @@

CAULDRON_SYS_CACHES="${CAULDRON_SYS_CACHES:-$CAULDRON_DATA/$CAULDRON_ARCH/sys.caches}"

# command to enter a chroot
- CAULDRON_CHROOT_CMD=( "${CAULDRON_CHROOT_CMD[@]:-chroot}" )
+ CAULDRON_CHROOT_CMD=( ${CAULDRON_CHROOT_CMD[@]:-chroot} )
+
+ # command to generate the final iso media
+ CAULDRON_MKISO_CMD=( ${CAULDRON_MKISO_CMD[@]:-mkisofs -R
+ -b isolinux/isolinux.bin
+ -c isolinux/boot.cat
+ -no-emul-boot
+ -boot-load-size 4
+ -boot-info-table
+ -o "$CAULDRON_ISO_NAME"
+ "$CAULDRON_ISO"
+ }
+ )
+
+ # command to archive the sys directory
+ CAULDRON_ARCHIVE_CMD=( ${CAULDRON_ARCHIVE_CMD[@]:-tar
+ cf "$CAULDRON_BUILD"/"${CAULDRON_SYS_NAME%.*}"
+ -C "$CAULDRON_SYS"
+ }
+ )
+
+ # command to archive the sys directory
+ CAULDRON_COMPRESS_CMD=( ${CAULDRON_COMPRESS_CMD[@]:-bzip2
+ "${CAULDRON_SYS_NAME%.*}"
+ }
+ )

# command to download a url from the internet
- CAULDRON_URL_DL_CMD=( "${CAULDRON_URL_DL_CMD[@]:-wget}" )
+ CAULDRON_URL_DL_CMD=( ${CAULDRON_URL_DL_CMD[@]:-wget} )

# sorcery cast/dispel/rebuild commands

CAULDRON_SORCERY_PATH="${CAULDRON_SORCERY_PATH:-$CAULDRON_HOST/usr/sbin}"
@@ -102,17 +135,18 @@
# sorcery local config location in the ISO

CAULDRON_ISORCERY_LCONFIG="${CAULDRON_ISORCERY_LCONFIG:-$CAULDRON_BUILD/etc/sorcery/local/config}"

+
CAULDRON_HSORCERY_LIBS="${CAULDRON_HSORCERY_LIBS:-$CAULDRON_HOST/var/lib/sorcery/modules}"

CAULDRON_HSORCERY_CONFIG="${CAULDRON_HSORCERY_CONFIG:-$CAULDRON_HOST/etc/sorcery/config}"

CAULDRON_HSORCERY_LCONFIG="${CAULDRON_HSORCERY_LCONFIG:-$CAULDRON_HOST/etc/sorcery/local/config}"
-
CAULDRON_HSORCERY_LIBS="${CAULDRON_HSORCERY_LIBS:-$CAULDRON_HOST/var/lib/sorcery/modules}"

CAULDRON_HSORCERY_PACKAGES="${CAULDRON_HSORCERY_PACKAGES:-$CAULDRON_HOST/var/state/sorcery/packages}"

CAULDRON_HSORCERY_SPOOL="${CAULDRON_HSORCERY_SPOOL:-$CAULDRON_HOST/var/spool/sorcery}"

- # contains the arch info for the HOST
- CAULDRON_HOST_TRIPLE="${CAULDRON_HOST_TRIPLE:-}"
- CAULDRON_HOST_ARCH_PATH="$(grep 'ARCH_SPECS=' $CAULDORN_HSORCERY_CONFIG |
cut -d= -f2)"
- CAULDRON_HOST_ARCH="$(grep 'ARCHITECTURE=' $CAULDORN_HSORCERY_CONFIG
| cut -d= -f2)"
- CAULDRON_CACHE_EXTENSION="$(grep 'EXTENSION=' $CAULDORN_HSORCERY_CONFIG |
cut -d= -f2)"
+ # contains the arch info for the HOST
+ CAULDRON_HOST_TRIPLE="${CAULDRON_HOST_TRIPLE:-}"
+ CAULDRON_HOST_ARCH_PATH="$(grep ARCH_SPECS= $CAULDRON_HSORCERY_CONFIG
| cut -d= -f2-)"
+
CAULDRON_HOST_CACHE_PATH="${CAULDRON_HOST_CACHE_PATH:-/var/cache/sorcery}"
+ eval CAULDRON_HOST_ARCH="$(grep ARCHITECTURE=
$CAULDRON_HSORCERY_CONFIG | cut -d= -f2-)"
+eval CAULDRON_CACHE_EXTENSION="$(grep EXTENSION= $CAULDRON_HSORCERY_CONFIG |
cut -d= -f2-)"


# vim:ai:tw=80:tabstop=2:softtabstop=2:shiftwidth=2:expandtab
diff --git a/cauldron/lib.chroot b/cauldron/lib.chroot
index a7849f5..9050ad4 100644
--- a/cauldron/lib.chroot
+++ b/cauldron/lib.chroot
@@ -49,7 +49,7 @@ function cauldron_chroot_init() {
cauldron_load_library lib.sorcerous
fi
# source the target sorcery, so we have access to its functions
- cauldron_sorcerous_load "$target" || return $ERR_SORCEROUS_TARGET_SORCERY
+ cauldron_sorcerous_load "$target" || return $ERR_SORCEROUS_TARGET

# everything went OK, so export the chroot definitions
export CAULDRON_CHROOTINIT=1
@@ -186,9 +186,9 @@ function cauldron_chroot_cast_clean() {
# caching should really be turned on from the very beginning though...
if [[ -z "$ARCHIVE" ]]
then
- cauldron_sorcerous_load || return $ERR_TARGET_SORCERY
+ cauldron_sorcerous_load || return $ERR_SORCEROUS_TARGET
fi
- [[ "$ARCHIVE" == "off" ]] && return $ERR_ARCHIVE
+ [[ "$ARCHIVE" == "off" ]] && return $ERR_SORCEROUS_ARCHIVE

# make sure we have a valid chroot of where we will cast
[[ -z "$CAULDRON_CHROOT" ]] && return $ERR_CHROOT_INIT
diff --git a/cauldron/lib.init b/cauldron/lib.init
index 029091a..68a0612 100755
--- a/cauldron/lib.init
+++ b/cauldron/lib.init
@@ -95,7 +95,7 @@ function cauldron_init_make_ramfs() {

mkdir -p "$ramdir" || return $ERR_MK_DIR

- cauldron_init_fs_make "$ramdir" || return $ERR_INIT_FS_MAKE
+ cauldron_init_fs_make "$ramdir" || return $ERR_INIT_MAKE_FS

(
cd "$ramdir"
@@ -279,7 +279,7 @@ function cauldron_init_fs_make() {
cauldron_init_fs_mods "$initfs" &&
cauldron_init_fs_init "$initfs"

- [[ "$?" -gt 0 ]] && return $ERR_INIT_FS_MAKE
+ [[ "$?" -gt 0 ]] && return $ERR_INIT_MAKE_FS

return $ERR_OK
}
diff --git a/cauldron/lib.sorcerous b/cauldron/lib.sorcerous
index 02d6f39..4d7a21c 100644
--- a/cauldron/lib.sorcerous
+++ b/cauldron/lib.sorcerous
@@ -34,12 +34,12 @@ function cauldron_sorcerous_load() {
local local_config="${2:-$CAULDRON_ISORCERY_LCONFIG}"

# source the main config file
- source "$config" || return $ERR_SORCEROUS_CONFIG
+ source "$config" || return $ERR_SORCEROUS_TARGET

# if the local config exists, source it
if [[ -f "$local_config" ]]
then
- source "$local_config" || return $ERR_SORCEROUS_LOCAL_CONFIG
+ source "$local_config" || return $ERR_SORCEROUS_TARGET
fi

return $ERR_OK
@@ -66,7 +66,7 @@ function cauldron_sorcerous_cross_configure() {
if [[ -z modify_config ]]
then
. "$CAULDRON_HSORCERY_LIBS/libtrack" 2> $CAULDRON_NULL ||
- liberror_die $ERR_SORCEROUS_HOST_SORCERY
+ liberror_die $ERR_SORCEROUS_HOST
fi

# make sure the sorcery local config dir exists on the ISO
diff --git a/cauldron/lib.toolchain b/cauldron/lib.toolchain
index f9567d8..7a29778 100644
--- a/cauldron/lib.toolchain
+++ b/cauldron/lib.toolchain
@@ -18,23 +18,59 @@

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


#-------------------------------------------------------------------------------
+##
+## Scans the sorcery archspec files to find the host triplet.
+##
+## Later, this will be used to set the value of HOST_TRIPLE in
+## /etc/cauldron/config after the code to write the config file is in place.
+##
+#-------------------------------------------------------------------------------
+function cauldron_toolchain_host_get() {
+ local specs="${CAULDRON_HOST_ARCH_PATH//\"/}"
+ local search="-perm 400 -type f -name $CAULDRON_HOST_ARCH"
+ local arch_spec=
+ local host_triple=
+
+ # get the value for the HOST triplet from sorcery archspecs
+
+ if [[ "$(find --version | grep -q 'version 4\.1\(\.\|$\)')" ]]
+ then
+ arch_spec="$(find $spec $search -print 2>$CAULDRON_NULL)"
+ else
+ arch_spec="$(find -L $spec $search -print 2>$CAULDRON_NULL)"
+ fi
+
+ # no matching arch spec found
+ [[ -z "$arch_spec" ]] && return $ERR_HOST_TRIPLE
+
+ host_triple="$(grep 'HOST=' $arch_spec | cut -d = -f 2)"
+
+ # no matching host definition
+ [[ -z "$host_triple" ]] && return $ERR_HOST_TRIPLE
+
+ echo "$host_triple"
+
+ return $ERR_OK
+}
+
+#-------------------------------------------------------------------------------
## @param spell
## @param install_log_path
##
## Builds a cache file from the information provided by the install log for
the
-## spell passed as an argument. It expects the provided spell to include the
-## version as a suffix (i.e. bash-3.2).
+## spell passed as an argument using sorcery's create_cache_archive. It
expects
+## the provided spell to include the version as a suffix (i.e. bash-3.2).
##

#-------------------------------------------------------------------------------
function cauldron_toolchain_cache_resurrect() {
local spell="$1"
local install_logs="${2:-$CAULDRON_HOST/var/log/sorcery/install}"
- local cache="$CAULDRON_CACHES/$spell.tar"
+ local cache="$CAULDRON_HOST_CACHE_PATH/$spell.tar"

if [[ -z create_cache_archive ]]
then
. "$CAULDRON_HSORCERY_LIBS/libstate" 2>$CAULDRON_NULL ||
- liberror_die $ERR_SORCEROUS_HOST_SORCERY
+ liberror_die $ERR_SORCEROUS_HOST
fi

# generate the missing cache file using sorcery
@@ -92,7 +128,8 @@ function cauldron_toolchain_cache_gather() {

#-------------------------------------------------------------------------------
## @param spell
##
-## Generates a spell cache by casting the spell and then dispelling it.
+## Generates a spell cache by casting the spell and then dispelling it. This
+## assumes that ARCHIVE is already set to "yes" in the chroot's sorcery
config.
##

#-------------------------------------------------------------------------------
function cauldron_toolchain_cache_cast() {
@@ -182,6 +219,102 @@ function cauldron_toolchain_cache_make() {


#-------------------------------------------------------------------------------
##
+## Generates the base toolchain using the HOST information. This is
+## done by unpacking the cache file for each spell required for the
+## toolchain if it exists. If it does not exist, this may be because
+## caching is disabled on the host machine, or perhaps the cache file
+## was deleted by accident. Otherwise the spell must be cast within
+## a chroot environment in the CAULDRON_BUILD directory.
+##
+#-------------------------------------------------------------------------------
+function cauldron_toolchain_build_host() {
+ local spell=""
+ local version=""
+ local spell_cache=""
+ local host_triple=""
+ local ext="$CAULDRON_CACHE_EXTENSION"
+
+ # get the value for HOST_TRIPLE
+ host_triple="$(cauldron_toolchain_host_get)"
+
+ [[ -z "$host_triple" ]] && return $ERR_HOST_TRIPLE
+
+ # grab the list of spells needed as the base tool-chain which will be
+ # used to create the cross-compile tool-chain
+ for spell in "$CAULDRON_TOOLCHAIN"
+ do
+ # grab the version for the spell from sorcery's state info
+ # on what's installed
+ version="$(grep \"^$spell\" $CAULDRON_HSORCERY_PACKAGES | cut -d: -f4)"
+
+ # check if spell found on the system
+ if [[ -n "$version" ]]
+ then
+ # set SPELL_CACHE as shorthand for SPELL-VERSION-HOST_TRIPLE.tar.bz2
+ spell_cache="${spell}-${version}-${host_triple}.tar${ext}"
+
+ # unpack the cache file, effectively installing
+ # the spell into the BUILD dir
+ # the unpacking is done against the BUILD dir as the root dir, so
+ # this should not touch the HOST filesystem at all
+ tar xjf "$CAULDRON_BUILD/$spell_cache" -C "$CAULDRON_BUILD/" ||
+ return $ERR_UNPACK_CACHE
+
+ # if the tar was successful, then remove the temporary file
+ rm "$CAULDRON_BUILD/$spell_cache" ||
+ return $ERR_RM_CACHE
+ fi
+ done
+
+ return $ERR_OK
+}
+
+#-------------------------------------------------------------------------------
+##
+## This builds the cross-compiler to produce the TARGET binaries.
+##
+#-------------------------------------------------------------------------------
+function cauldron_toolchain_build_cross() {
+ local chroot=0
+
+ # make sure we have a chroot accessible
+ # default to $CAULDRON_BUILD, unless one is already defined
+ if [[ "$CAULDRON_CHROOTINIT" -ne 1 ]]
+ then
+ chroot=1
+ cauldron_chroot_init
+ [[ $? -eq 0 || $? -eq $ERR_CHROOT_NEST ]] || return $ERR_CHROOT_INIT
+ fi
+
+ # build the stage 1 tools
+ cauldron_sorcerous_configure 1 || return $ERR_TOOLCHAIN_STAGE1
+ cauldron_chroot "$CAULDRON_CAST" "binutils" || return $ERR_CHROOT_CAST
+ cauldron_chroot "$CAULDRON_CAST" "gcc" || return $ERR_CHROOT_CAST
+
+ # build glibc (stage 2)
+ cauldron_sorcerous_configure 2 || return $ERR_TOOLCHAIN_STAGE2
+ cauldron_chroot "$CAULDRON_CAST" "glibc" || return $ERR_CHROOT_CAST
+
+ # rebuild gcc (still stage 1, but this time linked against the
+ # cross-glibc
+ cauldron_sorcerous_configure 1 || return $ERR_TOOLCHAIN_STAGE1
+ cauldron_chroot "$CAULDRON_CAST" "gcc" || return $ERR_CHROOT_CAST
+
+ # do a sorcery rebuild inside the BUILD dir to
+ # generate the cross-compile tool-chain (stage 3)
+ cauldron_sorcerous_configure 3 || return $ERR_TOOLCHAIN_STAGE3
+ cauldron_chroot "$CAULDRON_REBUILD" || return $ERR_CHROOT_REBUILD
+
+ # if we had to initialize a default chroot
+ # clean up by shutting it down
+ if [[ "$chroot" -eq 1 ]]
+ then
+ cauldron_chroot_done || return $ERR_CHROOT_DONE
+ fi
+}
+
+#-------------------------------------------------------------------------------
+##
## 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
diff --git a/cauldron/libcauldron b/cauldron/libcauldron
index 685e369..e341bd2 100755
--- a/cauldron/libcauldron
+++ b/cauldron/libcauldron
@@ -31,17 +31,17 @@ function cauldron_fatal_error() {


#-------------------------------------------------------------------------------
##
-## liberror includes - load these first!
+## error handling library includes - load these first!
##

#-------------------------------------------------------------------------------
-. "$CAULDRON_BASE/liberror" 2>$CAULDRON_NULL ||
+. "$CAULDRON_COMMON/liberror" 2>$CAULDRON_NULL ||
cauldron_fatal_error "error: cannot load base library liberror"

# load cauldron error code and message defines
. "$CAULDRON_LIBS/errorcodes" 2>$CAULDRON_NULL ||
cauldron_fatal_error "error: cannot load cauldron error codes"

-. "$CAULDRON_BASE/libcolor" 2>$CAULDRON_NULL ||
+. "$CAULDRON_COMMON/libcolor" 2>$CAULDRON_NULL ||
cauldron_fatal_error "error: cannot load base library libcolor"

# test/set whether color output should be enabled
@@ -75,176 +75,6 @@ cauldron_load_library "lib.init"
cauldron_load_library "lib.toolchain"


#-------------------------------------------------------------------------------
-##
-## Scans the sorcery archspec files to find the host triplet.
-##
-## Later, this will be used to set the value of HOST_TRIPLE in
-## /etc/cauldron/config after the code to write the config file is in place.
-##
-#-------------------------------------------------------------------------------
-function cauldron_get_host_triple() {
- local arch_spec=""
- local host_triple=""
- local spec=""
-
- # get the value for the HOST triplet from sorcery archspecs
- for spec in ${CAULDRON_HOST_ARCH_PATH[@]}
- do
- local search="-perm 400 -type f -name $CAULDRON_HOST_ARCH"
-
- if [[ "$(find --version | grep -q 'version 4\.1\(\.\|$\)')" == 1 ]]
- then
- arch_spec="$(find $spec $search -print 2>$CAULDRON_NULL)"
- else
- arch_spec="$(find -L $spec $search -print 2>$CAULDRON_NULL)"
- fi
-
- [[ -n "$arch_spec" ]] && break
- done
-
- host_triple="$(grep 'HOST=' $arch_spec | cut -d = -f 2)"
-
- echo "$host_triple"
-}
-
-#-------------------------------------------------------------------------------
-##
-## Generates the base toolchain using the HOST information. This is
-## done by unpacking the cache file for each spell required for the
-## toolchain if it exists. If it does not exist, this may be because
-## caching is disabled on the host machine, or perhaps the cache file
-## was deleted by accident. Otherwise the spell must be cast within
-## a chroot environment in the CAULDRON_BUILD directory.
-##
-#-------------------------------------------------------------------------------
-function cauldron_base_toolchain() {
- local spell=""
- local version=""
- local spell_cache=""
- local host_triple=""
- local ext="$CAULDRON_CACHE_EXTENSION"
-
- # get the value for HOST_TRIPLE
- host_triple="$(cauldron_get_host_triple)"
-
- [[ -z "$host_triple" ]] && return $ERR_HOST_TRIPLE
-
- # grab the list of spells needed as the base tool-chain which will be
- # used to create the cross-compile tool-chain
- for spell in "$CAULDRON_TOOLCHAIN"
- do
- # grab the version for the spell from sorcery's state info
- # on what's installed
- version="$(grep ^$spell $CAULDRON_HSORCERY_PACKAGES | cut -d: -f4)"
-
- # check if spell found on the system
- if [[ -n "$version" ]]
- then
- # set SPELL_CACHE as shorthand for SPELL-VERSION-HOST_TRIPLE.tar.bz2
- spell_cache="${spell}-${version}-${host_triple}.tar${ext}"
-
- # check to see if there is already a cache file from sorcery
- # this check could be based on spell-{names,versions} reported by
- # gaze/sorcery/dispel. Mirroring code in dispel might be the best bet,
- # since that has to find the version currently installed anyway.
- if [[ -f "$CAULDRON_HSORCERY_SPOOL/$spell_cache" ]]
- then
- # found a cache file, copy it to the BUILD dir
- cp "$CAULDRON_HSORCERY_SPOOL/$spell_cache" "$CAULDRON_BUILD" ||
- return $ERR_CP_CACHE
- else
- # couldn't find a cache file, so we'll need to build one
- if [[ -z cauldron_build_host_cache_file ]]
- then
- cauldron_load_library "lib.hostcache"
- fi
- cauldron_build_host_cache_file "$spell" ||
- return $ERR_BUILD_CACHE
- fi
-
- # unpack the cache file, effectively installing
- # the spell into the BUILD dir
- # the unpacking is done against the BUILD dir as the root dir, so
- # this should not touch the HOST filesystem at all
- tar xjf "$CAULDRON_BUILD/$spell_cache" -C "$CAULDRON_BUILD/" ||
- return $ERR_UNPACK_CACHE
-
- # if the tar was successful, then remove the temporary file
- rm "$CAULDRON_BUILD/$spell_cache" ||
- return $ERR_RM_CACHE
- # the spell is not present on the HOST system
- else
- # cast the spell inside a chroot to get the cache
- cauldron_chroot "$CAULDRON_CAST" "$spell" || return $ERR_CHROOT
- fi
- done
-
- return $ERR_OK
-}
-
-#-------------------------------------------------------------------------------
-##
-## This builds the cross-compiler to produce the TARGET binaries.
-##
-#-------------------------------------------------------------------------------
-function cauldron_cross_toolchain() {
- # build the stage 1 tools
- cauldron_configure_toolchain 1 || return $ERR_TOOLCHAIN_STAGE1
- cauldron_chroot "$CAULDRON_CAST" "binutils" || return $ERR_CHROOT_CAST
- cauldron_chroot "$CAULDRON_CAST" "gcc" || return $ERR_CHROOT_CAST
-
- # build glibc (stage 2)
- cauldron_configure_toolchain 2 || return $ERR_TOOLCHAIN_STAGE2
- cauldron_chroot "$CAULDRON_CAST" "glibc" || return $ERR_CHROOT_CAST
-
- # rebuild gcc (still stage 1, but this time linked against the
- # cross-glibc
- cauldron_configure_toolchain 1 || return $ERR_TOOLCHAIN_STAGE1
- cauldron_chroot "$CAULDRON_CAST" "gcc" || return $ERR_CHROOT_CAST
-
- # do a sorcery rebuild inside the BUILD dir to
- # generate the cross-compile tool-chain (stage 3)
- cauldron_configure_toolchain 3 || return $ERR_TOOLCHAIN_STAGE3
- cauldron_chroot "$CAULDRON_REBUILD" || return $ERR_CHROOT_REBUILD
-}
-
-#-------------------------------------------------------------------------------
-## @param target_spells
-##
-## Performs cast on the list of spells needed for installation to the target
-## system. "target_spells" is a list of spells that will be needed to install
-## into the target system from the iso.
-##
-#-------------------------------------------------------------------------------
-function cauldron_build_target_system() {
- local target_spells="$1"
- local spell=""
-
- # 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...
- if [[ -z "$ARCHIVE" ]]
- then
- cauldron_sorcerous_load || return $ERR_TARGET_SORCERY
- fi
- [[ "$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
- # cache, and then dispel it from the system so that it isn't wasting
space
- # on the ISO filesystem (any spells cast here should be those not
required
- # for the functioning of the ISO itself, only to be installed to the
target
- # system).
- cauldron_chroot "$CAULDRON_CAST" "$spell" || return $ERR_CHROOT_CAST
- cauldron_chroot "$CAULDRON_DISPEL" "$spell" || return $ERR_CHROOT_DISPEL
- done
-
- return $ERR_OK
-}
-
-#-------------------------------------------------------------------------------
## @param cleanfile
##
## Cleans out unneeded files that were used to generate the ISO, but should
@@ -275,26 +105,33 @@ function cauldron_clean_iso_system() {


#-------------------------------------------------------------------------------
##
+## Packages the sys directory into a compressed tarball to be placed in the
iso
+## filesystem as system.tar.bz2.
+##
+#-------------------------------------------------------------------------------
+function cauldron_package_sys() {
+ "${CAULDRON_ARCHIVE_CMD[@]}" || return $ERR_SYS_PACKAGE
+
+ "${CAULDRON_COMPRESS_CMD[@]}" "$CAULDRON_BUILD/$CAULDRON_SYS_NAME" ||
+ return $ERR_SYS_COMPRESS
+
+ return $ERR_OK
+}
+
+#-------------------------------------------------------------------------------
+##
## Builds the ISO filesystem using the generated ISO data and the filename
## set in the cauldron config file.
##

#-------------------------------------------------------------------------------
-function cauldron_mkisofs() {
- mkisofs -R \
- -b isolinux/isolinux.bin \
- -c isolinux/boot.cat \
- -no-emul-boot \
- -boot-load-size 4 \
- -boot-info-table \
- -o "$CAULDRON_ISO_NAME" \
- "$CAULDRON_BUILD" ||
- return $ERR_MKISOFS
+function cauldron_package_iso() {
+ "${CAULDRON_MKISO_CMD[@]}" || return $ERR_ISO_PACKAGE

if [[ "$CAULDRON_KEEPISO" == "yes" ]] ;
then
- bzip2 -k "$CAULDRON_ISO_NAME" || return $ERR_COMPRESS_ISO
+ bzip2 -k "$CAULDRON_ISO_NAME" || return $ERR_ISO_COMPRESS
else
- bzip2 "$CAULDRON_ISO_NAME" || return $ERR_COMPRESS_ISO
+ bzip2 "$CAULDRON_ISO_NAME" || return $ERR_ISO_COMPRESS
fi

return $ERR_OK
@@ -339,13 +176,18 @@ function cauldron_source_enchantment() {
##
## The installer(s) can currently be shell or menu (future: X?). In theory it
## should support any installer, as long as it's packaged in its own
directory
-## and the name of that dir is passed as the arg. This behavior may change in
-## the future though.
+## and the name of that dir is included in CAULDRON_INSTALLERS, and the
binary
+## to execute for that installer is named enchantment* (i.e., enchantment
+## (shell) or enchantment-menu). This behavior may change in the future
though.
##

#-------------------------------------------------------------------------------
function cauldron_add_installers() {
local installer=""

+ # no need to return error if cauldron_source_enchantment fails, because it
+ # runs liberror_die itself on error, which causes an exit
+ [[ -z $ENCHANT_DATA ]] && cauldron_source_enchantment
+
# make sure CAULDRON_BUILD/ENCHANT_DATA exists
mkdir -p "$ENCHANT_DATA" || return $ERR_INSTALLER_DIR

@@ -353,9 +195,9 @@ function cauldron_add_installers() {
do
cp -r "$CAULDRON_LIBS/enchantment/$installer" "$ENCHANT_DATA/" ||
return $ERR_COPY_INSTALLER
-
- ln -sf "$ENCHANT_DATA/$installer"/bin/* "$CAULDRON_BUILD/usr/sbin/" ||
- return $ERR_LINK_INSTALLER
+ ln -sf "$ENCHANT_DATA/$installer"/bin/enchantment* \
+ "$CAULDRON_BUILD/usr/sbin/" ||
+ return $ERR_LINK_INSTALLER
done

return $ERR_OK
@@ -382,7 +224,7 @@ function cauldron_prepare() {
then
cauldron_load_library lib.sorcerous
fi
- cauldron_sorcerous_install "$CAULDRON_BUILD" || return $ERR_SORCERY_INSTALL
+ cauldron_sorcerous_install "$CAULDRON_BUILD" || return
$ERR_SORCEROUS_INSTALL

# cauldron is a spell
# there is a spoon
diff --git a/ward/cauldron_sources b/ward/cauldron_sources
index 43d4712..fe63737 100644
--- a/ward/cauldron_sources
+++ b/ward/cauldron_sources
@@ -17,13 +17,13 @@
##

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

-cauldron_srcs=(
- "$cauldron/cauldron"
- "$cauldron/libcauldron"
- "$cauldron/lib.chroot"
- "$cauldron/lib.init"
- "$cauldron/lib.sorcerous"
- "$cauldron/lib.toolchain"
+sources=(
+ "cauldron"
+ "libcauldron"
+ "lib.chroot"
+ "lib.init"
+ "lib.sorcerous"
+ "lib.toolchain"
)


#-------------------------------------------------------------------------------
diff --git a/ward/enchantment_sources b/ward/enchantment_sources
index e24fc73..badeb7d 100644
--- a/ward/enchantment_sources
+++ b/ward/enchantment_sources
@@ -17,16 +17,16 @@
##

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

-enchantment_srcs=(
- "$enchantment/libenchantment"
- "$enchantment/lib.chroot"
- "$enchantment/lib.i18n"
- "$enchantment/lib.install"
- "$enchantment/lib.potion"
- "$enchantment/shell/bashrc"
- "$enchantment/shell/functions"
- "$enchantment/shell/bin/enchantment"
- "$enchantment/modules/*/{enter,exit,potion}/*"
+sources=(
+ "libenchantment"
+ "lib.chroot"
+ "lib.i18n"
+ "lib.install"
+ "lib.potion"
+ "shell/bashrc"
+ "shell/functions"
+ "shell/bin/enchantment"
+ "modules/*/{enter,exit,potion}/*"
)


#-------------------------------------------------------------------------------
diff --git a/ward/libward b/ward/libward
index db60d46..b0a448a 100644
--- a/ward/libward
+++ b/ward/libward
@@ -22,6 +22,9 @@ export LC_COLLATE="C"
# ensure that WARD_PATH has a value
WARD_PATH="${WARD_PATH:-$(dirname $0)}"

+###
+# TODO: these paths should not be hardcoded in the future
+###
# load liberror (this is not optional)
if ! . "$WARD_PATH/../lib/liberror"
then
@@ -37,23 +40,115 @@ then
fi


#-------------------------------------------------------------------------------
-## @param definition file
-## @param source1 [source2 source3...]
+## @param -p path to sources (optional)
+## @param project (required)
+##
+## Pulls in the definitions of which source files to ward for the given
project.
+## If passed -p as an optional flag, the argument to -p is used as the base
path
+## for pulling in the source file definitons from. This path defaults to
+## WARD_PATH.
+##
+#-------------------------------------------------------------------------------
+function ward_get_sources() {
+ local path="$WARD_PATH"
+ local project=""
+
+ # process any optional parameters
+ while [[ "${1:0:1}" == "-" ]]
+ do
+ case "$1" in
+ "-p")
+ path="${2%/}"
+ shift 2
+ ;;
+ *)
+ libcolor_error "error: invalid function parameter $1"
+ echo ""
+ liberror_die $ERR_FATAL
+ ;;
+ esac
+ done
+
+ # make sure we have a good source file path component
+ if [[ ! -d "$path" ]]
+ then
+ echo "error: source file search path not recognized"
+ liberror_die $ERR_FATAL
+ fi
+
+ project="$1"
+
+ # if file is not given with an absolute path, add the base path prefix
+ [[ "${project:0:1}" != "/" ]] && project="$path/$project"
+
+ # source the list of source files to examine
+ if ! . "$project"
+ then
+ echo "error: could not load $project"
+ exit $ERR_FATAL
+ fi
+}
+
+#-------------------------------------------------------------------------------
+## @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 variables used in source1 (source2, source3, etc.) are
## defined in the definition file. Any 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.
+## they were found in via libcolor_file. Both base paths default to the
current
+## working directory if not supplied.
##

#-------------------------------------------------------------------------------
function ward_global_variables() {
+ local fpath="."
+ local dpath="."
local defines=""
local file=""

+ # process any optional parameters
+ while [[ "${1:0:1}" == "-" ]]
+ do
+ case "$1" in
+ "-p")
+ fpath="${2%/}"
+ shift 2
+ ;;
+ "-d")
+ dpath="${2%/}"
+ shift 2
+ ;;
+ *)
+ libcolor_error "error: invalid function parameter $1"
+ echo ""
+ liberror_die $ERR_FATAL
+ ;;
+ esac
+ done
+
+ # 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 "$dpath" ]]
+ then
+ echo "error: variable definition file search path not recognized"
+ liberror_die $ERR_FATAL
+ fi
+
# get the defines file, then drop it from the argument list
defines="$1"
shift

+ # if defines is not given with an absolute path, add the base path prefix
+ [[ "${defines:0:1}" != "/" ]] && defines="$dpath/$defines"
+
# make sure the defines file exists, otherwise we can't check anything
if [[ ! -f "$defines" ]]
then
@@ -66,6 +161,9 @@ function ward_global_variables() {
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
@@ -82,20 +180,51 @@ function ward_global_variables() {
}


#-------------------------------------------------------------------------------
-## @param error code file
+## @param -p base path to sources (optional)
+## @param error code file (required)
##
## Ensures that the error code file itself is properly defined, making sure
that
## for every error code there is a matching error message, and for every
error
-## message there is a matching error code.
+## message there is a matching error code. The base path defaults to the
current
+## working directory if not supplied.
##

#-------------------------------------------------------------------------------
function ward_error_codes() {
- local errorcodes="$1"
+ local path="."
+ local errorcodes=""
local leader=" "
local codes=()
local msgcode=""
local count=""

+ # process any optional parameters
+ while [[ "${1:0:1}" == "-" ]]
+ do
+ case "$1" in
+ "-p")
+ path="${2%/}"
+ shift 2
+ ;;
+ *)
+ libcolor_error "error: invalid function parameter $1"
+ echo ""
+ liberror_die $ERR_FATAL
+ ;;
+ esac
+ done
+
+ # make sure we have a good errorcodes file path component
+ if [[ ! -d "$path" ]]
+ then
+ echo "error: error code file search path not recognized"
+ liberror_die $ERR_FATAL
+ fi
+
+ errorcodes="$1"
+
+ # if errorcodes is not given with an absolute path, add the base path
prefix
+ [[ "${errorcodes:0:1}" != "/" ]] && errorcodes="$path/$errorcodes"
+
# make sure the defines file exists, otherwise we can't check anything
if [[ ! -f "$errorcodes" ]]
then
@@ -154,17 +283,20 @@ function ward_error_codes() {
}


#-------------------------------------------------------------------------------
-## @param directory where function definition files are stored
-## @param source1 [source2 source3...]
+## @param -p base path to sources (optional)
+## @param -l base path to libraries (optional)
+## @param source1 [source2 source3...] (required)
##
## Tests whether any functions used in source1 (source2, source3, etc.) are
## defined. Any functions that are used but not defined in the corresponding
## definition file are output via libcolor_warn, preceded by the file they
were
-## found in via libcolor_file.
+## found in via libcolor_file. Both base paths default to the current working
+## directory if not supplied.
##

#-------------------------------------------------------------------------------
function ward_functions() {
- local path=""
+ local fpath="."
+ local lpath="."
local file=""
local prefix=""
local list=""
@@ -177,17 +309,38 @@ function ward_functions() {
liberror_die $ERR_FATAL
fi

- # get the defines file, then drop it from the argument list
- path="$1"
- shift
+ # process any optional parameters
+ while [[ "${1:0:1}" == "-" ]]
+ do
+ case "$1" in
+ "-p")
+ fpath="${2%/}"
+ shift 2
+ ;;
+ "-l")
+ lpath="${2%/}"
+ shift 2
+ ;;
+ *)
+ libcolor_error "error: invalid function parameter $1"
+ echo ""
+ liberror_die $ERR_FATAL
+ ;;
+ esac
+ done
+
+ # 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 got a good path component
- if [[ ! -d "$WARD_PATH/../$path" ]]
+ # make sure we have a good library path component
+ if [[ ! -d "$lpath" ]]
then
echo "error: library search path not recognized"
liberror_die $ERR_FATAL
- else
- path="$WARD_PATH/../$path"
fi

while [[ $# -gt 0 ]]
@@ -195,6 +348,9 @@ function ward_functions() {
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

list=($(grep -o "^[ ]*[a-z]\+_[a-z_]\+" "$file" | sed 's/^ *//' | sort
-u))
@@ -214,16 +370,16 @@ function ward_functions() {
[[ "$prefix" == "enchant" ]] && prefix="enchantment"

# check for the function in a library file matching the prefix
- if [[ -f "$path/lib$prefix" ]]
+ if [[ -f "$lpath/lib$prefix" ]]
then
- if grep -q "^function $function() {" "$path/lib$prefix"
+ if grep -q "^function $function() {" "$lpath/lib$prefix"
then
matched="yes"
break
fi
- elif [[ -f "$path/lib.$prefix" ]]
+ elif [[ -f "$lpath/lib.$prefix" ]]
then
- if grep -q "^function $function() {" "$path/lib.$prefix"
+ if grep -q "^function $function() {" "$lpath/lib.$prefix"
then
matched="yes"
break
diff --git a/ward/ward-configvars b/ward/ward-configvars
index cd7ba23..2b60dd1 100755
--- a/ward/ward-configvars
+++ b/ward/ward-configvars
@@ -19,13 +19,7 @@

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


-WARD_PATH="${DELINT_PATH:-$(dirname $0)}"
-
-cauldron="$WARD_PATH/../cauldron"
-c_conf="$cauldron/etc/config"
-
-enchantment="$WARD_PATH/../enchantment"
-e_conf="$enchantment/etc/config"
+WARD_PATH="${WARD_PATH:-$(dirname $0)}"

if ! . "$WARD_PATH/libward"
then
@@ -33,19 +27,6 @@ then
exit 1
fi

-# source the list of cauldron source files to examine
-if ! . "$WARD_PATH/cauldron_sources"
-then
- echo "error: could not load cauldron_sources"
- exit $ERR_FATAL
-fi
-# source the list of enchantment source files to examine
-if ! . "$WARD_PATH/enchantment_sources"
-then
- echo "error: could not load enchantment_sources"
- exit $ERR_FATAL
-fi
-
function ward_print_usage() {
cat << EndUsage
Usage: $(basename $0) [-n]
@@ -61,29 +42,57 @@ function ward_usage() {
exit $ERR_FATAL
}

-# check if color should be disabled
-if [[ "$1" == "-n" ]]
+while [[ "$#" -gt 0 ]]
+do
+ case "$1" in
+ # check if color should be disabled
+ "-n")
+ LIBCOLOR_NOCOLOR="yes"
+ ;;
+ # check if the user only wants to process cauldron
+ "cauldron")
+ PROCESS_ENCHANTMENT="no"
+ ;;
+ # check if the user only wants to process enchantment
+ "enchantment")
+ PROCESS_CAULDRON="no"
+ ;;
+ # unknown argument
+ *)
+ ward_print_usage
+ ;;
+ esac
+ shift
+done
+
+PROCESS_CAULDRON="${PROCESS_CAULDRON:-yes}"
+PROCESS_ENCHANTMENT="${PROCESS_ENCHANTMENT:-yes}"
+
+if [[ "$PROCESS_CAULDRON" == "yes" ]]
then
- if [[ "$#" -eq 1 ]]
- then
- LIBCOLOR_NOCOLOR="yes"
- shift
- else
- ward_usage
- fi
+ ward_get_sources "cauldron_sources"
+ cauldron="$WARD_PATH/../cauldron"
+ c_conf="$cauldron/etc/config"
+
+ # check cauldron files
+ libcolor_notice "Checking cauldron config variables"
+ echo ""
+ ward_global_variables -p "$cauldron" "$c_conf" "${sources[@]}" | \
+ grep -v '[^A-Z_]ERR_[A-Z_]*'
fi

-# check cauldron files
-libcolor_notice "Checking cauldron config variables"
-echo ""
-ward_global_variables "$c_conf" "${cauldron_srcs[@]}" | \
- grep -v '[^A-Z_]ERR_[A-Z_]*'
+if [[ "$PROCESS_ENCHANTMENT" == "yes" ]]
+then
+ ward_get_sources "enchantment_sources"
+ enchantment="$WARD_PATH/../enchantment"
+ e_conf="$enchantment/etc/config"

-# check enchantment files
-libcolor_notice "Checking enchantment config variables"
-echo ""
-ward_global_variables "$e_conf" "${enchantment_srcs[@]}" | \
- grep -v '[^A-Z_]ERR_[A-Z_]*'
+ # check enchantment files
+ libcolor_notice "Checking enchantment config variables"
+ echo ""
+ ward_global_variables -p "$enchantment" "$e_conf" "${sources[@]}" | \
+ grep -v '[^A-Z_]ERR_[A-Z_]*'
+fi


#-------------------------------------------------------------------------------
##
diff --git a/ward/ward-errorcodes b/ward/ward-errorcodes
index 46316c1..5628b8b 100755
--- a/ward/ward-errorcodes
+++ b/ward/ward-errorcodes
@@ -17,13 +17,7 @@
##

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

-WARD_PATH="${DELINT_PATH:-$(dirname $0)}"
-
-cauldron="$WARD_PATH/../cauldron"
-c_codes="$cauldron/errorcodes"
-
-enchantment="$WARD_PATH/../enchantment"
-e_codes="$enchantment/errorcodes"
+WARD_PATH="${WARD_PATH:-$(dirname $0)}"

if ! . "$WARD_PATH/libward"
then
@@ -31,19 +25,6 @@ then
exit 1
fi

-# source the list of cauldron source files to examine
-if ! . "$WARD_PATH/cauldron_sources"
-then
- echo "error: could not load cauldron_sources"
- exit $ERR_FATAL
-fi
-# source the list of enchantment source files to examine
-if ! . "$WARD_PATH/enchantment_sources"
-then
- echo "error: could not load enchantment_sources"
- exit $ERR_FATAL
-fi
-
function ward_print_usage() {
cat << EndUsage
Usage: $(basename $0) [-n]
@@ -59,39 +40,67 @@ function ward_usage() {
exit $ERR_FATAL
}

-# check if color should be disabled
-if [[ "$1" == "-n" ]]
-then
- if [[ "$#" -eq 1 ]]
- then
- LIBCOLOR_NOCOLOR="yes"
- shift
- else
- ward_usage
- fi
-fi
+while [[ "$#" -gt 0 ]]
+do
+ case "$1" in
+ # check if color should be disabled
+ "-n")
+ LIBCOLOR_NOCOLOR="yes"
+ ;;
+ # check if the user only wants to process cauldron
+ "cauldron")
+ PROCESS_ENCHANTMENT="no"
+ ;;
+ # check if the user only wants to process enchantment
+ "enchantment")
+ PROCESS_CAULDRON="no"
+ ;;
+ # unknown argument
+ *)
+ ward_print_usage
+ ;;
+ esac
+ shift
+done
+
+PROCESS_CAULDRON="${PROCESS_CAULDRON:-yes}"
+PROCESS_ENCHANTMENT="${PROCESS_ENCHANTMENT:-yes}"

# check cauldron error codes/messages files for internal consistency
-libcolor_notice "Checking cauldron errorcodes for internal consistency"
-echo ""
-ward_error_codes "$c_codes"
+if [[ "$PROCESS_CAULDRON" == "yes" ]]
+then
+ ward_get_sources "cauldron_sources"
+ cauldron="$WARD_PATH/../cauldron"
+ c_codes="$cauldron/errorcodes"

-# check cauldron files
-libcolor_notice "Checking cauldron sources for undefined error codes"
-echo ""
-ward_global_variables "$c_codes" "${cauldron_srcs[@]}" | \
- grep '[^A-Z_]ERR_[A-Z_]*'
+ libcolor_notice "Checking cauldron errorcodes for internal consistency"
+ echo ""
+ ward_error_codes "$c_codes"
+
+ # check cauldron files
+ libcolor_notice "Checking cauldron sources for undefined error codes"
+ echo ""
+ ward_global_variables -p "$cauldron" "$c_codes" "${sources[@]}" | \
+ grep '[^A-Z_]ERR_[A-Z_]*'
+fi

# check enchantment error codes/messages files for internal consistency
-libcolor_notice "Checking enchantment errorcodes for internal consistency"
-echo ""
-ward_error_codes "$e_codes"
+if [[ "$PROCESS_ENCHANTMENT" == "yes" ]]
+then
+ ward_get_sources "enchantment_sources"
+ enchantment="$WARD_PATH/../enchantment"
+ e_codes="$enchantment/errorcodes"

-# check enchantment files
-libcolor_notice "Checking enchantment sources for undefined error codes"
-echo ""
-ward_global_variables "$e_codes" "${enchantment_srcs[@]}" | \
- grep '[^A-Z_]ERR_[A-Z_]*'
+ libcolor_notice "Checking enchantment errorcodes for internal consistency"
+ echo ""
+ ward_error_codes "$e_codes"
+
+ # check enchantment files
+ libcolor_notice "Checking enchantment sources for undefined error codes"
+ echo ""
+ ward_global_variables -p "$enchantment" "$e_codes" "${sources[@]}" | \
+ grep '[^A-Z_]ERR_[A-Z_]*'
+fi


#-------------------------------------------------------------------------------
##
diff --git a/ward/ward-functions b/ward/ward-functions
index bccb66c..06c55c6 100755
--- a/ward/ward-functions
+++ b/ward/ward-functions
@@ -19,11 +19,7 @@

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


-WARD_PATH="${DELINT_PATH:-$(dirname $0)}"
-
-cauldron="$WARD_PATH/../cauldron"
-
-enchantment="$WARD_PATH/../enchantment"
+WARD_PATH="${WARD_PATH:-$(dirname $0)}"

if ! . "$WARD_PATH/libward"
then
@@ -59,27 +55,53 @@ function ward_usage() {
exit $ERR_FATAL
}

-# check if color should be disabled
-if [[ "$1" == "-n" ]]
+while [[ "$#" -gt 0 ]]
+do
+ case "$1" in
+ # check if color should be disabled
+ "-n")
+ LIBCOLOR_NOCOLOR="yes"
+ ;;
+ # check if the user only wants to process cauldron
+ "cauldron")
+ PROCESS_ENCHANTMENT="no"
+ ;;
+ # check if the user only wants to process enchantment
+ "enchantment")
+ PROCESS_CAULDRON="no"
+ ;;
+ # unknown argument
+ *)
+ ward_print_usage
+ ;;
+ esac
+ shift
+done
+
+PROCESS_CAULDRON="${PROCESS_CAULDRON:-yes}"
+PROCESS_ENCHANTMENT="${PROCESS_ENCHANTMENT:-yes}"
+
+if [[ "$PROCESS_CAULDRON" == "yes" ]]
then
- if [[ "$#" -eq 1 ]]
- then
- LIBCOLOR_NOCOLOR="yes"
- shift
- else
- ward_usage
- fi
+ ward_get_sources "cauldron_sources"
+ cauldron="$WARD_PATH/../cauldron"
+
+ # check cauldron files
+ libcolor_notice "Checking cauldron functions"
+ echo ""
+ ward_functions -p "$cauldron" -l "$cauldron" "${sources[@]}"
fi

-# check cauldron files
-libcolor_notice "Checking cauldron functions"
-echo ""
-ward_functions "cauldron" "${cauldron_srcs[@]}"
+if [[ "$PROCESS_ENCHANTMENT" == "yes" ]]
+then
+ ward_get_sources "enchantment_sources"
+ enchantment="$WARD_PATH/../enchantment"

-# check enchantment files
-libcolor_notice "Checking enchantment functions"
-echo ""
-ward_functions "enchantment" "${enchantment_srcs[@]}"
+ # check enchantment files
+ libcolor_notice "Checking enchantment functions"
+ echo ""
+ ward_functions -p "$enchantment" -l "$enchantment" "${sources[@]}"
+fi


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



  • [SM-Commit] GIT changes to master cauldron by Justin Boffemmyer (8e8bf8f131c429f205349ae09bc15b94dec052df), Justin Boffemmyer, 12/30/2010

Archive powered by MHonArc 2.6.24.

Top of Page