sm-commit AT lists.ibiblio.org
Subject: Source Mage code commit list
List archive
[SM-Commit] GIT changes to master cauldron by Justin Boffemmyer (9a6f23e4313273f71dd3d7855406e4b2b826f53c)
- 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 (9a6f23e4313273f71dd3d7855406e4b2b826f53c)
- Date: Thu, 30 Jun 2011 18:40:46 -0500
GIT changes to master cauldron by Justin Boffemmyer <flux AT sourcemage.org>:
cauldron/lib/errorcodes | 3 -
cauldron/lib/lib.chroot | 75
+++++++++++++++++++++++++++++++++++++++++++--
cauldron/lib/lib.init | 3 -
cauldron/lib/lib.toolchain | 8 +---
cauldron/lib/libcauldron | 2 -
5 files changed, 79 insertions(+), 12 deletions(-)
New commits:
commit 9a6f23e4313273f71dd3d7855406e4b2b826f53c
Author: Justin Boffemmyer <flux AT sourcemage.org>
Commit: Justin Boffemmyer <flux AT sourcemage.org>
cauldron: test if chroot successfully loaded
The previous commit more properly initializes/cleans up chroots based on
the users/dependees. That only leaves the chroot detection code to be
updated. This commit introduces a new function specifically for testing
whether there is a currently loaded chroot, and can also test whether it
matches a given path to ensure that a desired chroot is the current one.
This commit also brings the rest of the libraries that depend on chroot
functionality in sync with the new code, including updating the chroot
error code definitions.
diff --git a/cauldron/lib/errorcodes b/cauldron/lib/errorcodes
index 2589b3f..ccc4415 100644
--- a/cauldron/lib/errorcodes
+++ b/cauldron/lib/errorcodes
@@ -64,12 +64,11 @@ liberror_add_error ERR_SYS_COMPRESS "could not compress
final sys archive"
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_CURRENT "chroot not current or not defined"
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
liberror_add_error ERR_INIT_INSTALL_RAMFS \
diff --git a/cauldron/lib/lib.chroot b/cauldron/lib/lib.chroot
index 12a35a7..2336bb4 100644
--- a/cauldron/lib/lib.chroot
+++ b/cauldron/lib/lib.chroot
@@ -139,6 +139,77 @@ function cauldron_chroot_done() {
}
#-------------------------------------------------------------------------------
+## @param -q [quiet -- don't output anything, just test] (optional)
+## @param chroot path (optional)
+##
+## Determines the current chroot. If called with no parameters, it will
return
+## (echo) the path of the current chroot. If provided the chroot path
parameter,
+## it will test whether the provided path matches the current chroot, and
will
+## return an error if they don't match.
+##
+#-------------------------------------------------------------------------------
+function cauldron_chroot_current() {
+ local num="${#CAULDRON_CHROOT[*]}"
+ local current=""
+ local target=""
+ local match=0
+ local quiet=0
+
+ # check if we should disable output
+ if [[ "$1" == "-q" ]]
+ then
+ quiet=1
+ shift
+ fi
+ target="$1"
+
+ # use the correct index into the array (indexing starts from 0, but count
of
+ # elements starts from 1)
+ [[ "$num" -gt 0 ]] && ((num--))
+ current="${CAULDRON_CHROOT[num]}"
+
+ # if there is no current chroot, then return immediately (no sense testing
if
+ # anything matches the currently defined chroot when there is none)
+ [[ -z "$current" ]] && return $ERR_CHROOT_CURRENT
+
+ # make sure that the chroot is also present in LIBCHROOT_PATHS and
+ # LIBCHROOT_USERS
+ for ((index=0; index < "${#LIBCHROOT_PATHS[@]}"; index++))
+ do
+ if [[ "$current" == "${LIBCHROOT_PATHS[index]}" ]]
+ then
+ if [[ "${LIBCHROOT_USERS[index]}" -ge 1 ]]
+ then
+ match=1
+ fi
+ fi
+ done
+
+ # if the currently defined chroot doesn't match a loaded chroot in
+ # LIBCHROOT_PATHS and LIBCHROOT_USERS, then there is something wrong and
the
+ # chroot should probably be reloaded
+ [[ "$match" -eq 0 ]] && return $ERR_CHROOT_CURRENT
+
+ if [[ -n "$target" ]]
+ then
+ # test if the target path doesn't match the currently defined chroot
command
+ # target path -- if it does match, then we can just do nothing till the
end
+ # of the function where we return ERR_OK; if it doesn't match, return
error
+ # here
+ if [[ "$target" != "$current" ]]
+ then
+ # the target chroot doesn't match the current chroot
+ return $ERR_CHROOT_CURRENT
+ fi
+ else
+ # output the currently loaded chroot
+ echo "$current"
+ fi
+
+ return $ERR_OK
+}
+
+#-------------------------------------------------------------------------------
## @param command plus args to execute inside the chroot
##
## Executes the command given as the first parameter and any args that follow
@@ -146,11 +217,11 @@ function cauldron_chroot_done() {
##
#-------------------------------------------------------------------------------
function cauldron_chroot() {
- if [[ "$CAULDRON_CHROOTINIT" -eq 1 ]]
+ if cauldron_chroot_current -q
then
"${CAULDRON_CHROOT[@]}" $* || return $ERR_CHROOT_EXEC
else
- return $ERR_CHROOT_NOT_INIT
+ return $ERR_CHROOT_CURRENT
fi
return $ERR_OK
diff --git a/cauldron/lib/lib.init b/cauldron/lib/lib.init
index d40b102..c1de0ed 100644
--- a/cauldron/lib/lib.init
+++ b/cauldron/lib/lib.init
@@ -268,8 +268,7 @@ function cauldron_init_fs_busybox() {
"$build/etc/sorcery/local/busybox.config" ||
return $ERR_CP_FILE
- cauldron_chroot_init "$build"
- [[ $? -eq 0 || $? -eq $ERR_CHROOT_NEST ]] || return $ERR_CHROOT_INIT
+ cauldron_chroot_init "$build" || return $ERR_CHROOT_INIT
cauldron_chroot_cast "busybox" || return $ERR_CHROOT_CAST
diff --git a/cauldron/lib/lib.toolchain b/cauldron/lib/lib.toolchain
index d9b900a..4e5e5f2 100644
--- a/cauldron/lib/lib.toolchain
+++ b/cauldron/lib/lib.toolchain
@@ -275,8 +275,7 @@ function cauldron_toolchain_cache_cast() {
# make sure we have a chroot accessible
# default to $CAULDRON_BUILD, unless one is already defined
- cauldron_chroot_init
- [[ $? -eq $ERR_OK || $? -eq $ERR_CHROOT_NEST ]] || return $ERR_CHROOT_INIT
+ cauldron_chroot_init || return $ERR_CHROOT_INIT
# generate the caches for the needed spells
cauldron_chroot_cast_clean "$spells" || return $ERR_TOOLCHAIN_CAST
@@ -421,11 +420,10 @@ function cauldron_toolchain_build_cross() {
# make sure we have a chroot accessible
# default to $CAULDRON_BUILD, unless one is already defined
- if [[ "$CAULDRON_CHROOTINIT" -ne 1 ]]
+ if ! cauldron_chroot_current -q
then
chroot=1
- cauldron_chroot_init
- [[ $? -eq 0 || $? -eq $ERR_CHROOT_NEST ]] || return $ERR_CHROOT_INIT
+ cauldron_chroot_init || return $ERR_CHROOT_INIT
fi
# build the stage 1 tools
diff --git a/cauldron/lib/libcauldron b/cauldron/lib/libcauldron
index 7a84969..e269678 100644
--- a/cauldron/lib/libcauldron
+++ b/cauldron/lib/libcauldron
@@ -107,7 +107,7 @@ function cauldron_clean_iso_system() {
[[ -z "$cleanfile" ]] && return $ERR_CLEAN_FILE
- [[ -z "$CAULDRON_CHROOT" ]] && return $ERR_CHROOT_INIT
+ cauldron_chroot_current -q || return $ERR_CHROOT_CURRENT
for i in $(sort -r $cleanfile)
do
- [SM-Commit] GIT changes to master cauldron by Justin Boffemmyer (9a6f23e4313273f71dd3d7855406e4b2b826f53c), Justin Boffemmyer, 06/30/2011
Archive powered by MHonArc 2.6.24.