[SM-Commit] GIT changes to master sorcery by Jaka Kranjc (3de7e51c25f6dc38dc2c6fe4320a0872e31cdf0b)

Jaka Kranjc scm at sourcemage.org
Mon Dec 29 15:01:40 EST 2008


GIT changes to master sorcery by Jaka Kranjc <lynxlynxlynx at sourcemage.org>:

 ChangeLog                        |    5 +++++
 usr/sbin/cast                    |   26 +++++++++++++++++++++++++-
 var/lib/sorcery/modules/libcodex |    3 ++-
 3 files changed, 32 insertions(+), 2 deletions(-)

New commits:
commit 3de7e51c25f6dc38dc2c6fe4320a0872e31cdf0b
Author: Jaka Kranjc <lynxlynxlynx at sourcemage.org>
Commit: Jaka Kranjc <lynxlynxlynx at sourcemage.org>

        * libcodex: made codex_find_grimoire also check dirs under $CODEX_ROOT
        * cast: -g now verifies the grimoires and offers to fetch them if they
          are not present

diff --git a/ChangeLog b/ChangeLog
index 1e50658..6381038 100644
--- a/ChangeLog
+++ b/ChangeLog
@@ -1,3 +1,8 @@
+2008-12-29 Jaka Kranjc <lynxlynxlynx at sourcemage.org>
+	* libcodex: made codex_find_grimoire also check dirs under $CODEX_ROOT
+	* cast: -g now verifies the grimoires and offers to fetch them if they
+	  are not present
+
 2008-12-23 Jaka Kranjc <lynxlynxlynx at sourcemage.org>
 	* gaze, gaze.1: solidified the gaze from matching and added optional
 	  regex support (pass -regex)
diff --git a/usr/sbin/cast b/usr/sbin/cast
index 56c4e90..b1beb0b 100755
--- a/usr/sbin/cast
+++ b/usr/sbin/cast
@@ -105,7 +105,7 @@ function process_parameters()  {
            --no-opts)  export NO_OPTIMIZATION_FLAGS=1; COMPILE="-c"; shift 1  ;;
                   -V)  export VOYEUR_OVERRIDE="$2";                  shift 2  ;;
               --deps)  export  DEPS_ONLY="$1";                       shift 1  ;;
-      -g|--grimoire*)  export OVERRIDE_GRIMOIRES="$2";               shift 2  ;;
+      -g|--grimoire*)  override_grimoires "$2";                      shift 2  ;;
     -r|--reconfigure)  RECONFIGURE="$1"; COMPILE="-c";               shift 1  ;;
     -R|--recast-down)  RECAST_DOWN="$1";                             shift 1  ;;
       -B|--recast-up)  RECAST_UP="$1";                               shift 1  ;;
@@ -204,6 +204,30 @@ function get_option() {
 }
 
 #---------------------------------------------------------------------
+## Check that we have all the passed grimoires and use them to
+## override the default selection (all)
+#---------------------------------------------------------------------
+function override_grimoires() {
+  local grimoires=$1
+  local grimoire
+
+  for grimoire in $grimoires; do
+    if ! codex_find_grimoire $grimoire > /dev/null; then
+      error_message "Grimoire $grimoire does not exist!"
+      if query "Do you want to add it?" y; then
+        scribe add $grimoire || exit 13
+        echo
+      else
+        list_remove grimoires $grimoire
+      fi
+    fi
+  done
+  [[ -z $grimoires ]] && message "Using default grimoire selection!\n"
+
+  export OVERRIDE_GRIMOIRES="$grimoires"
+}
+
+#---------------------------------------------------------------------
 ## Cast a single spell. When this function is called, all dependencies
 ## have been taken care of and we are allowed to cast this.
 ## @Globals SPELL
diff --git a/var/lib/sorcery/modules/libcodex b/var/lib/sorcery/modules/libcodex
index db3c248..5ce28fd 100755
--- a/var/lib/sorcery/modules/libcodex
+++ b/var/lib/sorcery/modules/libcodex
@@ -145,7 +145,8 @@ function codex_find_grimoire() {
 
   local cfg_idx
   let cfg_idx=0
-  for cfg_grimoire in $(codex_get_all_grimoires); do
+  for cfg_grimoire in $(codex_get_all_grimoires) $CODEX_ROOT/*; do
+    [[ -d $cfg_grimoire ]] || continue
     # this will be empty if "$foo" matches the glob "*$bar"
     match=$(eval echo ${cfg_grimoire%%*$cfg_lookup})
     # if empty, echo and succeed



More information about the SM-Commit mailing list