[SM-Commit] GIT changes to master sorcery by Jaka Kranjc (13597fc5b7f8297571c974555062a9e87a7dfb95)

Jaka Kranjc scm at sourcemage.org
Thu Jun 19 12:32:40 EDT 2008


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

 ChangeLog                          |    2 
 var/lib/sorcery/modules/libsorcery |  101 ++++++++++++++++++++++++++++++-------
 2 files changed, 85 insertions(+), 18 deletions(-)

New commits:
commit 13597fc5b7f8297571c974555062a9e87a7dfb95
Author: Jaka Kranjc <lynxlynxlynx at sourcemage.org>
Commit: Jaka Kranjc <lynxlynxlynx at sourcemage.org>

    fixed held spells getting queued in the old compatibility mode

commit f88747bd28d368d66b553ea7a3d913016676da2e
Author: Jaka Kranjc <lynxlynxlynx at sourcemage.org>
Commit: Jaka Kranjc <lynxlynxlynx at sourcemage.org>

    libsorcery: use the new fast method in sorcery queue-security too
    
    todo: does_spell_need_update + more code reuse

diff --git a/ChangeLog b/ChangeLog
index a67e3fa..73a2296 100644
--- a/ChangeLog
+++ b/ChangeLog
@@ -1,5 +1,7 @@
 2008-06-19 Jaka Kranjc <lynxlynxlynx at sourcemage.org>
 	* sorcery.8: clarify the sorcery default subcommands with examples #14528
+	* libsorcery: use the new fast method in sorcery queue-security too
+	  fixed held spells getting queued in the old compatibility mode
 
 2008-06-18 Jaka Kranjc <lynxlynxlynx at sourcemage.org>
 	* config: made the rest of the previously overridable variables overridable
diff --git a/var/lib/sorcery/modules/libsorcery b/var/lib/sorcery/modules/libsorcery
index 446836c..574f739 100755
--- a/var/lib/sorcery/modules/libsorcery
+++ b/var/lib/sorcery/modules/libsorcery
@@ -975,7 +975,7 @@ function update_install_queue()  {
       sed -i 's,^\(\S*\)\s.*$,\1,' $tmp_queue
     fi
   else # use the old slow method
-    get_all_spells_with_status ok > $recheck_queue
+    get_all_spells_with_status installed > $recheck_queue
   fi
   if [[ -s $recheck_queue ]]; then
     (
@@ -1005,28 +1005,93 @@ function update_install_queue()  {
 function update_security_install_queue()  {
   local line spell page_dir info curr_sec_patch=0
   local tmp_queue=$TMP_DIR/install_queue
+  local recheck_queue=$TMP_DIR/recheck_queue
   touch $tmp_queue
 
   message  "${CHECK_COLOR}Generating the list of spells to update for" \
            "security reasons... ${DEFAULT_COLOR} "
-  for  line  in  `all_spell_status`;  do
-    #0=spell, 1=date, 2=status, 3=version
-    explode "$line" ":" "info"
-    spell=${info[0]}
-    status=${info[2]}
-
-    ( # do this in a subshell in case a spell mis-behaves and exits we
-      # still want queueing to work
-      if  [[  "$status"  ==  "installed"  ]] &&
-          codex_set_current_spell_by_name  $spell &&
-          tablet_find_spell_dir $spell page_dir ; then
-        tablet_get_security_patch $page_dir curr_sec_patch &&
-        if (( "${SECURITY_PATCH:-0}" >  "$curr_sec_patch" )) ; then
-          echo $spell >> $tmp_queue
-        fi
-      fi
+  if [[ -z $OLD_QUEUING_METHOD ]]; then
+    tablet_check_version_cache $VERSION_STATUS || return 1
+    local grimoire
+    for grimoire in $(codex_get_all_grimoires); do
+      cat $grimoire/$VERSION_INDEX_FILE 2>/dev/null
+    done |
+    awk -v i=$VERSION_STATUS -v verbose=$VERBOSE_QUEUING '
+      # decide what to print - just the spell or also the reason
+      function needs_update(                diff) {
+        if (verbose == "on") {
+          diff = factor[4] - $4
+          if (diff > 0) {
+            if (diff > 1) {
+              print $1, "Security update (" diff " times!)."
+            } else {
+              print $1, "Security update."
+            }
+          }
+        } else {
+          if ($4 < factor[4]) {
+            print $1
+          }
+        }
+      }
+
+      {
+        if ( ! ($1 in map)) {
+          map[$1]=$0;
+        }
+      }
+
+      END {
+        while (getline < i) {
+          if ($1 in map) {
+            split(map[$1], factor);
+            needs_update();
+          } else {
+            # multiversioned spell - do it the old way
+            print $1 > "/dev/stderr";
+          }
+        }
+      } ' > $tmp_queue 2> $recheck_queue
+    local spell
+    for spell in $(get_all_spells_with_status held); do
+      sed -i "/^$spell\( \|$\)/d" $tmp_queue $recheck_queue
+    done
+    if [[ $VERBOSE_QUEUING == on ]]; then
+      local message
+      while read spell message; do
+        message "$SPELL_COLOR$spell$DEFAULT_COLOR: $message"
+      done < $tmp_queue
+      sed -i 's,^\(\S*\)\s.*$,\1,' $tmp_queue
+    fi
+  else # use the old slow method
+    get_all_spells_with_status installed > $recheck_queue
+  fi
+  if [[ -s $recheck_queue ]]; then
+    (
+      count=0
+      size=$(wc -l < $recheck_queue)
+      while read spell; do
+          let count++
+          progress_bar $count $size 50
+          if codex_set_current_spell_by_name $spell &&
+             tablet_find_spell_dir $spell page_dir; then
+            tablet_get_security_patch $page_dir curr_sec_patch &&
+            diff=$(( ${SECURITY_PATCH:-0} - $curr_sec_patch ))
+            if (( $diff > 0 )); then
+              echo $spell >> $tmp_queue
+              clear_line
+              if (( $diff > 1 )); then
+                message "$SPELL_COLOR$spell$DEFAULT_COLOR: Security update ($diff times!)."
+              else
+                message "$SPELL_COLOR$spell$DEFAULT_COLOR: Security update."
+              fi
+            fi
+          fi
+      done < $recheck_queue
+      clear_line
     )
-  done
+    rm $recheck_queue
+  fi
 
   lock_file $INSTALL_QUEUE
   rm  -f  $INSTALL_QUEUE



More information about the SM-Commit mailing list