[SM-Commit] BZR Change 26 to stage-root sorcery by David Brown <dmlb2000 at dmlb2004>

scm at mail.sourcemage.org scm at mail.sourcemage.org
Mon Apr 24 00:25:03 EDT 2006


------------------------------------------------------------
revno: 26
committer: David Brown <dmlb2000 at dmlb2004>
branch nick: stage-root
timestamp: Sun 2006-04-23 21:22:09 -0700
message:
  merged from devel sorcery
    ------------------------------------------------------------
    merged: astitt at sourcemage.org-20060424014818-3d7be36d78d14708
    committer: Andrew Stitt <astitt at sourcemage.org>
    branch nick: devel-hack4
    timestamp: Sun 2006-04-23 18:48:18 -0700
    message:
      fix bug 8070, make changelog viewing timeout
    ------------------------------------------------------------
    merged: astitt at sourcemage.org-20060424004600-7410dcc139b66a71
    committer: Andrew Stitt <astitt at sourcemage.org>
    branch nick: devel-hack4
    timestamp: Sun 2006-04-23 17:46:00 -0700
    message:
      fix bug 9415, add some sanity checking to summon
    ------------------------------------------------------------
    merged: astitt at sourcemage.org-20060424001110-98d1bde767df28d7
    committer: Andrew Stitt <astitt at sourcemage.org>
    branch nick: devel-hack4
    timestamp: Sun 2006-04-23 17:11:10 -0700
    message:
      svn should be non-interactive
    ------------------------------------------------------------
    merged: astitt at sourcemage.org-20060421153115-bb5ea4d0fd2f72f4
    committer: Andrew Stitt <astitt at sourcemage.org>
    branch nick: devel
    timestamp: Fri 2006-04-21 08:31:15 -0700
    message:
      fix bug 11372, and some other summon issues

=== modified file 'ChangeLog'
--- ChangeLog	
+++ ChangeLog	
@@ -1,3 +1,19 @@
+2006-04-23 Andrew Stitt <astitt at sourcemage.org>
+	* libsorcery: fix bug 8070, add pager timeout for changelog viewing
+	* config: add a pager timeout, and use less -F instead of -E,
+	  see if people like -F better than -E.
+
+2006-04-23 Andrew Stitt <astitt at sourcemage.org>
+	* libsummon: fix bug 9415, do some sanity checking in summon
+
+2006-04-23 Andrew Stitt <astitt at sourcemage.org>
+	* dl_handlers/dl_svn: Do no interactive prompting
+
+2006-04-21 Andrew Stitt <astitt at sourcemage.org>
+	* libsummon: fix bug 11372, bad spells can make us unlock the wrong
+	  resource, causing subsequent summons to hang. Also fix return code
+	  propagation.
+
 2006-04-14 Andrew Stitt <astitt at sourcemage.org>
 	* libmisc: add forkless basename and dirname functions using
 	  bash variable expansions.

=== modified file 'etc/sorcery/config'
--- etc/sorcery/config	
+++ etc/sorcery/config	
@@ -19,6 +19,7 @@
          VIEW_REPORTS=${VIEW_REPORTS:=on}
                VOYEUR=${VOYEUR:=on}
          PROMPT_DELAY=${PROMPT_DELAY:=150}
+        PAGER_TIMEOUT=${PAGER_TIMEOUT:=150}
            MAX_CABALS=${MAX_CABALS:=16}
            NET_SELECT=${NET_SELECT:=off}
             MD5SUM_DL=${MD5SUM_DL:=ask_risky}
@@ -52,7 +53,7 @@
                     # -X: dont do screen init and deinit, gaze install
                     # of a small spell is effectively useless otherwise as the
                     # screen is cleared afterwards.
-                PAGER=${PAGER:=less -R -E -X -f}
+                PAGER=${PAGER:=less -R -F -X -f}
              FILEPROG=${FILEPROG:=file}
            DIALOGPROG=${DIALOGPROG:=dialog}
 

=== modified file 'var/lib/sorcery/modules/dl_handlers/dl_svn'
--- var/lib/sorcery/modules/dl_handlers/dl_svn	
+++ var/lib/sorcery/modules/dl_handlers/dl_svn	
@@ -37,13 +37,13 @@
     local URL SVN_ROOT SVN_MODULE SVN_TAG
     url_crack "$url" "$hints"
 
-    local svn_args=""
+    local svn_args="--non-interactive "
     if list_find "$hints" "parse_username" ; then
       local USER_PASS=$(echo $SVN_ROOT|sed 's#.*//\(.*\)@.*#\1#')
       local SVN_ROOT=$(echo $SVN_ROOT|sed 's#//\(.*\)@#//#')
       local USER=${USER_PASS%:*};
       local PASS=${USER_PASS#*:};
-      svn_args="--username $USER --password $PASS"
+      svn_args="--username $USER --password $PASS "
     fi
 
     if test -d $target; then

=== modified file 'var/lib/sorcery/modules/libsorcery'
--- var/lib/sorcery/modules/libsorcery	
+++ var/lib/sorcery/modules/libsorcery	
@@ -960,7 +960,6 @@
 ##
 #---------------------------------------------------------------------
 function get_new_changes() {
-    local PAGER2="$(override_pager)"
     local msg="$1"
     local date="$2"
     # This needs some explaination:
@@ -990,7 +989,9 @@
         echo "$msg"
         echo
         echo "$changelog"
-      } | $PAGER2
+      }  > $TMP_DIR/pagerdata
+      timeout_pager "$TMP_DIR/pagerdata"
+      rm $TMP_DIR/pagerdata
     else
       echo "$msg"
       echo
@@ -998,9 +999,26 @@
     fi
 }
 
-function override_pager() {
-  #placeholder for a proper fix for http://bugs.sourcemage.org/show_bug.cgi?id=8070
-  if [ "$PAGER" == "less" ]; then echo "more"; else echo "$PAGER"; fi
+
+#---------------------------------------------------------------------
+## Pager with timeouts, cannot be used from a pipe.
+## Invokes a subshell in case there are other background jobs running
+#---------------------------------------------------------------------
+function timeout_pager() { (
+  $PAGER "$@" &
+  sleep 1
+  for ((i=0;i<PAGER_TIMEOUT*10;i++)) ; do
+    jobs &>/dev/null # this makes bash clean up so the next line works
+    [[ "$(jobs)" ]] || return 0
+    sleep .1
+  done
+  jobs -p|xargs kill
+  jobs &>/dev/null # hide the [Done [2] blah blah] message
+  stty sane
+  if query "\nPager timeout, continue viewing $@" n; then
+    $PAGER "$@"
+  fi
+) 2>/dev/null # hides less complaining that it was killed
 }
 
 #---------------------------------------------------------------------

=== modified file 'var/lib/sorcery/modules/libsummon'
--- var/lib/sorcery/modules/libsummon	
+++ var/lib/sorcery/modules/libsummon	
@@ -49,7 +49,6 @@
       persistent_save
       # save the rc, then unlock
       rc=$?
-      unlock_resources "summon" "${SPELL}"
 
       if [[ $rc == 0 ]]; then
         activity_log "summon" "$SPELL"  "$VERSION" "success"
@@ -59,10 +58,10 @@
 
       # this actually only returns from the subshell, not the function
       return $rc
-    ) &&
-    popd &>/dev/null
+    ) && popd &>/dev/null
+    rc=$?
     rm -rf $dl_dir
-    rc=$?
+    unlock_resources "summon" "${SPELL}"
   fi
   return $rc
 }
@@ -240,9 +239,16 @@
     rm -rf $new_target
   elif [[ "$summon_type" == file ]] ; then
     # there is no penalty for guessing tree when the result is a file
-
     if [[ $summon_target != $target ]] ; then
-      mv -f $summon_target $target
+      mv -f "$summon_target" "$target"
+    fi
+    local type
+    if ! source_sanity "$target" "type"; then
+      message "${PROBLEM_COLOR}Sanity check of${DEFAULT_COLOR}" \
+              "${FILE_COLOR}${target}${DEFAULT_COLOR}" \
+              "${PROBLEM_COLOR}failed:${DEFAULT_COLOR}"
+      message "$type"
+      return 1
     fi
   else
     message "${PROBLEM_COLOR}Unknown download type: \"$summon_type\""\
@@ -407,6 +413,32 @@
   fi
   return 0
 }
+
+#---------------------------------------------------------------------
+## Perform rudimentary source sanity checks on summoned files.
+## Currently only checks that tarballs are not html 404 notices.
+## Some sites, notably sourceforge, break http by having missing files
+## do a 30X redirect to a 404 html file which when downloaded has a
+## 200 (OK) status. Other sites do 30X redirect to the new location of
+## the requested file, which then successfully downloads (which is
+## the correct thing to do). We catch that here rather than wait for
+## file verification to catch it.
+#---------------------------------------------------------------------
+function source_sanity() {
+  [[ "$1" ]] && return 0
+  [[ "$SUMMON_SANITY" == off ]] && return 0
+  if [[ "$1" != "${1%.tar.bz2}" ]] ||
+     [[ "$1" != "${1%.tar.gz}" ]] ||
+     [[ "$1" != "${1%.tgz}" ]]; then
+    local _type=$(file "$1")
+    if echo $_type | grep -iq HTML ||
+       echo $_type | grep -iq ascii ; then
+      upvar "$2" "$_type"
+      return 1
+    fi
+  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




More information about the SM-Commit mailing list