Skip to Content.
Sympa Menu

sm-commit - [SM-Commit] GIT changes to master sorcery by Andrew Stitt (fb99a9128edcfe6cf8041e58ab088e23e4b203e7)

sm-commit AT lists.ibiblio.org

Subject: Source Mage code commit list

List archive

Chronological Thread  
  • From: Andrew Stitt <scm AT mail.sourcemage.org>
  • To: sm-commit AT lists.ibiblio.org
  • Subject: [SM-Commit] GIT changes to master sorcery by Andrew Stitt (fb99a9128edcfe6cf8041e58ab088e23e4b203e7)
  • Date: Mon, 19 Feb 2007 17:55:35 -0600

GIT changes to master sorcery by Andrew Stitt <astitt AT sourcemage.org>:

ChangeLog | 14 +++++++++-
usr/sbin/summon | 4 ++
var/lib/sorcery/modules/libapi | 10 +++++--
var/lib/sorcery/modules/libmisc | 53
++++++++++++++++++++++----------------
var/lib/sorcery/modules/libsummon | 37 +++++++++++++++++++-------
5 files changed, 81 insertions(+), 37 deletions(-)

New commits:
commit fb99a9128edcfe6cf8041e58ab088e23e4b203e7
Author: Andrew Stitt <astitt AT sourcemage.org>
Commit: Andrew Stitt <astitt AT sourcemage.org>

fix bug 13458

commit a605ab7e3341fc408fa029ed2341c7e0eba500d6
Author: Andrew Stitt <astitt AT sourcemage.org>
Commit: Andrew Stitt <astitt AT sourcemage.org>

fix bug 13412

commit 3728d83bf80f398486e8c8292a0dd6bf68c13f41
Author: Andrew Stitt <astitt AT sourcemage.org>
Commit: Andrew Stitt <astitt AT sourcemage.org>

fix bug 13356

diff --git a/ChangeLog b/ChangeLog
index dc300cb..b839df0 100644
--- a/ChangeLog
+++ b/ChangeLog
@@ -1,4 +1,16 @@
-2007-10-20 Paul Mahon <pmahon AT sourcemage.org>
+2007-02-19 Andrew Stitt <astitt AT sourcemage.org>
+ * select_list: update documentation and mangle variable names, bug
13458
+
+2007-02-19 Andrew Stitt <astitt AT sourcemage.org>
+ * libsummon, summon: fix bug 13412, summon --raw should work
+ with other summon facilities (force-download, source cache check).
+ Patch from Jaka Kranjc, modified for style/compatibility.
+
+2007-02-19 Andrew Stitt <astitt AT sourcemage.org>
+ * libmisc: fix bug 13356, improve performance of
+ list_find. Slightly modified patch from Jaka Kranjc.
+
+2007-01-20 Paul Mahon <pmahon AT sourcemage.org>
*libmisc: redirect some errors to stderr for bug 13380

2007-01-01 David Brown <dmlb2000 AT gmail.com>
diff --git a/usr/sbin/summon b/usr/sbin/summon
index fc09afd..34840e7 100755
--- a/usr/sbin/summon
+++ b/usr/sbin/summon
@@ -196,10 +196,12 @@ main() {
process_parameters $*

if [ -n "$RAW" ] ; then
- local line rc
+ local line target rc
while read line; do
# eval is needed to preserve quoting
eval set -a $line
+ target="${line%% *}"
+ is_downloaded "$target" && continue
download_src_args "$@" || rc=$?
done
return $rc
diff --git a/var/lib/sorcery/modules/libapi b/var/lib/sorcery/modules/libapi
index 01e9fbe..28fae2b 100755
--- a/var/lib/sorcery/modules/libapi
+++ b/var/lib/sorcery/modules/libapi
@@ -667,9 +667,13 @@ function list_add () {
## return 0 at least one element is in list
## return 1 none of supplied elements is not in list
##
-## Finds if at least one of given elements is in the string. Warning,
-## this function takes real string, not variable name as other list_*
-## functions
+## Finds if at least one of the given elements is in the string. They
+## can be delimited by spaces, tabs or newlines. The search elements
+## must not contain any of these or they won't match. The matching is
+## exact, regular expressions and globbing patterns are not supported.
+##
+## Warning, this function takes a real string, not a variable name as
+## other list_* functions.
## <pre>
## Example:
## if list_find "$MY_LIST" "--with-x"; then
diff --git a/var/lib/sorcery/modules/libmisc b/var/lib/sorcery/modules/libmisc
index b40a8e0..35c6d83 100755
--- a/var/lib/sorcery/modules/libmisc
+++ b/var/lib/sorcery/modules/libmisc
@@ -478,7 +478,7 @@ function iterate()
}

#---------------------------------------------------------------------
-## @param return_var (must not be i, foo, temp, returnvar, stuff or default)
+## @param return_var (must not be i, foo, temp, returnvar, stuff, default,
hashnum, msgstr, result or answer)
## @param default choice
## @param elements, ..
##
@@ -491,9 +491,9 @@ function select_list()
local i
local foo temp number
local returnvar=$1
- local default=$2
+ local _default=$2
local stuff=()
- local default_num=0
+ local _default_num=0

shift 2
hash_unset select_list_hash
@@ -504,12 +504,12 @@ function select_list()
for foo in "$@"; do
message "\t$DEFAULT_COLOR(${stuff[$i]})
$SPELL_COLOR$foo$DEFAULT_COLOR"
hash_put select_list_hash "${stuff[$i]}" "$foo"
- [[ "$foo" ]] && [[ "$foo" == "$default" ]] &&
default_num=${stuff[$i]}
+ [[ "$foo" ]] && [[ "$foo" == "$_default" ]] &&
_default_num=${stuff[$i]}
let i++
done

- local msg="\n${QUERY_COLOR}Which one do you want?
[$default_num]$DEFAULT_COLOR "
- select_list_sub "$returnvar" select_list_hash "$msg" "$default_num"
+ local msg="\n${QUERY_COLOR}Which one do you want?
[$_default_num]$DEFAULT_COLOR "
+ select_list_sub "$returnvar" select_list_hash "$msg" "$_default_num"
hash_unset select_list_hash
}

@@ -526,18 +526,18 @@ function select_list_sub() {
local returnvar=$1
local hashname=$2
local msgstr=$3
- local default=$4
+ local _default=$4

- local result answer
+ local _result _answer

- while [[ ! $result ]] ; do
+ while [[ ! $_result ]] ; do
message -n "$msgstr"
- read -t $PROMPT_DELAY -n 1 answer
- [[ "$answer" ]] || answer=$default
- result="$(hash_get $hashname $answer)"
+ read -t $PROMPT_DELAY -n 1 _answer
+ [[ "$_answer" ]] || _answer=$_default
+ _result="$(hash_get $hashname $_answer)"
done
echo
- eval $returnvar=\"$result\"
+ eval $returnvar=\"$_result\"
}

#---------------------------------------------------------------------
@@ -619,20 +619,29 @@ function real_list_add () {
## return 0 at least one element is in list
## return 1 none of supplied elements is not in list
##
-## Finds if at least one of given elements is in the string. Warning,
-## this function takes real string, not variable name as other list_*
-## functions
+## Finds if at least one of the given elements is in the string. They
+## can be delimited by spaces, tabs or newlines. The search elements
+## must not contain any of these or they won't match. The matching is
+## exact, regular expressions and globbing patterns are not supported.
+##
+## Warning, this function takes a real string, not a variable name as
+## other list_* functions.
##
#---------------------------------------------------------------------
function real_list_find () {
- local i
- local input="$1"
- shift
+ local item token
+ [[ "$1" ]] || return 1
+ local input=$1
+ shift

- for i in $@; do
- eval "echo \" $input \" | grep -q -e \"[[:space:]]$i[[:space:]]\" &&
return 0"
+ for item in $input
+ do
+ for token in "$@"
+ do
+ [[ "$item" == "$token" ]] && return 0
done
- return 1
+ done
+ return 1
}

#---------------------------------------------------------------------
diff --git a/var/lib/sorcery/modules/libsummon
b/var/lib/sorcery/modules/libsummon
index 0ba7356..badeafb 100755
--- a/var/lib/sorcery/modules/libsummon
+++ b/var/lib/sorcery/modules/libsummon
@@ -98,9 +98,6 @@ function real_default_sorcery_download()
## Acquire the source. Check locally unless options insist on not
## doing so.
##
-## Inspects $FORCE_DOWNLOAD and ${FORCE_DOWNLOAD[$srcnum]}
-## if either are set then downloading is forced, a local copy of the
-## file is ignored.
#-------------------------------------------------------------------------
function real_acquire_src() {
$STD_DEBUG
@@ -108,24 +105,44 @@ function real_acquire_src() {
local SVAR="SOURCE${DLNUM}"
local target=${!SVAR}

-
- REASON="for spell ${SPELL_COLOR}${SPELL}${DEFAULT_COLOR}"
-
# maybe we already have the file
# but we can only use it if not FORCE_DOWNLOADing
+ is_downloaded "$target" "$DLNUM" \
+ "for spell ${SPELL_COLOR}${SPELL}${DEFAULT_COLOR} " && return 0
+
+ # else the source must be downloaded/updated
+ download_src "$DLNUM"
+}
+
+#-------------------------------------------------------------------------
+## @param download target
+## @param source number
+## @return 0 if the target already exsists and FORCE_DOWNLOADing is disabled
+## @return 1 otherwise
+##
+## Checks if the download target is already downloaded,
+## Inspects $FORCE_DOWNLOAD and ${FORCE_DOWNLOAD[$srcnum]}
+## if either are set then downloading is forced, a local copy of the
+## file is ignored.
+##
+#-------------------------------------------------------------------------
+function is_downloaded() {
+ local target="$1"
+ local dlnum="${2:-1}"
+ local reason="$3"
+
if file_exists "$SOURCE_CACHE/$target " &&
! [[ ${FORCE_DOWNLOAD} ]] &&
- ! [[ ${FORCE_DOWNLOAD[${DLNUM:-1}]} ]] ; then
+ ! [[ ${FORCE_DOWNLOAD[$dlnum]} ]] ; then
# file_exists does a fuzzy match with gz, tgz and bz2
# lookup what file it actually found and use that for the message
local real_target=$(guess_filename $SOURCE_CACHE/$target)
message "${MESSAGE_COLOR}Found source file" \
"${FILE_COLOR}${real_target}${DEFAULT_COLOR}" \
- "$REASON in ${FILE_COLOR}${SOURCE_CACHE}${DEFAULT_COLOR}"
+ "${reason}in ${FILE_COLOR}${SOURCE_CACHE}${DEFAULT_COLOR}"
return 0
fi
- # else the source must be downloaded/updated
- download_src "$DLNUM"
+ return 1
}

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



  • [SM-Commit] GIT changes to master sorcery by Andrew Stitt (fb99a9128edcfe6cf8041e58ab088e23e4b203e7), Andrew Stitt, 02/19/2007

Archive powered by MHonArc 2.6.24.

Top of Page