Skip to Content.
Sympa Menu

sm-commit - [SM-Commit] GIT changes to master sorcery by Jaka Kranjc (71e05ef9831445f631979a8606df98f9ac30341d)

sm-commit AT lists.ibiblio.org

Subject: Source Mage code commit list

List archive

Chronological Thread  
  • From: Jaka Kranjc <scm AT sourcemage.org>
  • To: sm-commit AT lists.ibiblio.org
  • Subject: [SM-Commit] GIT changes to master sorcery by Jaka Kranjc (71e05ef9831445f631979a8606df98f9ac30341d)
  • Date: Tue, 22 Jan 2008 10:37:59 -0600

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

ChangeLog | 9 ++++-
var/lib/sorcery/modules/libstate | 64
++++++++++++++++++++++-----------------
2 files changed, 45 insertions(+), 28 deletions(-)

New commits:
commit 71e05ef9831445f631979a8606df98f9ac30341d
Author: Jaka Kranjc <lynxlynxlynx AT sourcemage.org>
Commit: Jaka Kranjc <lynxlynxlynx AT sourcemage.org>

disabled locking in add_depends

commit c6cc9523263093515d5bc17c2e48c3ed13bcb68b
Author: Jaka Kranjc <lynxlynxlynx AT sourcemage.org>
Commit: Jaka Kranjc <lynxlynxlynx AT sourcemage.org>

simplified the parameter check in add_depends and moved it before the
possible removal of dependency info

commit cd58de89f7411d62f8bad8ac2ba82a9729ec2abf
Author: Jaka Kranjc <lynxlynxlynx AT sourcemage.org>
Commit: Jaka Kranjc <lynxlynxlynx AT sourcemage.org>

locking in search_depends_status is too expensive

commit 8f3ffc288ee0f0e7fdd3ecf7cfa41f3a9bced40a
Author: Jaka Kranjc <lynxlynxlynx AT sourcemage.org>
Commit: Jaka Kranjc <lynxlynxlynx AT sourcemage.org>

ammended a changelog entry

commit 1f51424de6cf28ec87e46423be100d6d3d8d70f5
Author: Jaka Kranjc <lynxlynxlynx AT sourcemage.org>
Commit: Jaka Kranjc <lynxlynxlynx AT sourcemage.org>

libstate: fixed a possible regression

commit f2a349bb80639c19db62cdb3cd79f1402a0fd82b
Author: Jaka Kranjc <lynxlynxlynx AT sourcemage.org>
Commit: Jaka Kranjc <lynxlynxlynx AT sourcemage.org>

libstate: moved the subshell from the callers into query_spell_status and
sped it up for a tiny bit due to expensive locking
awk:sed = 0:1

diff --git a/ChangeLog b/ChangeLog
index 492625a..202adf7 100644
--- a/ChangeLog
+++ b/ChangeLog
@@ -1,5 +1,12 @@
+2008-01-22 Jaka Kranjc <lynxlynxlynx AT sourcemage.org>
+ * libstate: moved the subshell from the callers into
query_spell_status and
+ sped it up for a tiny bit due to expensive locking
+ locking in search_depends_status is too expensive
+ simplified the parameter check in add_depends and moved it before
the
+ possible removal of dependency info; disabled locking
+
2008-01-21 Jaka Kranjc <lynxlynxlynx AT sourcemage.org>
- * liblock: don't overwrite the lock list in lock_start_transaction
+ * liblock: don't overwrite the lock list in lock_start_transaction
#13345
don't quit when removing the old lock list
fixed typos in error messages
* libdepends: fixed a regression introduced in 2008-01-16
diff --git a/var/lib/sorcery/modules/libstate
b/var/lib/sorcery/modules/libstate
index 9b3160d..6c9f3ec 100755
--- a/var/lib/sorcery/modules/libstate
+++ b/var/lib/sorcery/modules/libstate
@@ -33,22 +33,18 @@ function add_depends()
local depends_status=$1
shift

+ # ensure the info is valid (perhaps add check that spells exist?)
+ list_find "on off" "$3" || return 1
+ list_find "required optional runtime suggest" "$4" || return 1
+
# Allow add_depends to override previous ones for the same pair of spells
search_depends_status "$depends_status" "$1" "$2" >/dev/null &&
remove_depends_status "$depends_status" "$1" "$2"

-
- #ensure the info is valid (perhaps add check that spells exist?)
- if ( [[ $3 != on ]] && [[ $3 != off ]] ) ||
- ( [[ $4 != required ]] && [[ $4 != optional ]] &&
- [[ $4 != runtime ]] && [[ $4 != suggest ]]; ); then
- return 1
- fi
-
local t_status
- lock_start_transaction "$depends_status" t_status
+# lock_start_transaction "$depends_status" t_status
echo "$1:$2:$3:$4:$5:$6" >> "$t_status"
- lock_commit_transaction "$depends_status"
+# lock_commit_transaction "$depends_status"

return 0

@@ -132,7 +128,7 @@ function search_depends_status_simple()
## @param depends file
## @param spell
## @param depends (optional)
-## @Stdout mathing lines
+## @Stdout matching lines
## In case you want to search by spell or dependency in $1
##
## Arguments can be regexp
@@ -147,13 +143,13 @@ function search_depends_status()
local depends_status=$1
shift

- lock_file "$depends_status"
+# lock_file "$depends_status"
if [[ -z $2 ]]; then
grep "^`esc_str "$1"`:" "$depends_status"
else
- grep "^`esc_str "$1:$2"`:" "$depends_status"
+ grep "^`esc_str "$1"`:`esc_str "$2"`:" "$depends_status"
fi
- unlock_file "$depends_status"
+# unlock_file "$depends_status"
}


@@ -606,11 +602,12 @@ function search_spell_status() {
#---------------------------------------------------------------------
##
## @param spell ( [A-Za-z0-9_-] )
-## @param version ( may not contain space,
+## @param version (optional and may not contain spaces or colons,
## '.' and '*' have special meaning)
+## @param variable to set
## @Stdout last matching line ( only one even if there are more )
##
-## Searches the SPELL_STATUS file for a spell and optionaly
+## Searches the SPELL_STATUS file for a spell and optionally
## a version.
##
## Prints out the matching spell's status
@@ -621,14 +618,20 @@ function search_spell_status() {
function query_spell_status()
{ #$1=spell, $2=(OPT)version

- local version
- version=`esc_str ${2:-".*"}`
+ local version return_var __status rc
+ if [[ -z $3 ]]; then
+ version=".*"
+ return_var="$2"
+ else
+ version=`esc_str ${2:-".*"}`
+ return_var="$3"
+ fi

lock_file "$SPELL_STATUS"
- tac $SPELL_STATUS | grep -m 1 "^$1:.*:.*:$version$" | \
- cut -d ":" -f 3
+ __status=$(sed -n "/^$1:.*:\(.*\):$version$/ { s,,\1,; h }; $ {x; p}"
"$SPELL_STATUS")
rc=$?
unlock_file "$SPELL_STATUS"
+ eval "$return_var=\"\$__status\""

return $rc
}
@@ -640,7 +643,9 @@ function query_spell_status()
## @return 0 if the given spell's status is "installed"
#---------------------------------------------------------------------
function real_spell_installed() {
- [ "$( query_spell_status $1 )" == "installed" ];
+ local status
+ query_spell_status "$1" status
+ [[ $status == installed ]]
}


@@ -651,7 +656,9 @@ function real_spell_installed() {
##
#---------------------------------------------------------------------
function real_spell_held() {
- [ "$( query_spell_status $1 )" == "held" ];
+ local status
+ query_spell_status "$1" status
+ [[ $status == held ]]
}

#---------------------------------------------------------------------
@@ -661,8 +668,9 @@ function real_spell_held() {
## @return 0 if the given spell's status is "installed" or "held"
#---------------------------------------------------------------------
function real_spell_ok() {
- local res="$( query_spell_status $1 )"
- [ "$res" == "installed" ] || [ "$res" == "held" ]
+ local status
+ query_spell_status "$1" status
+ [[ $status == installed ]] || [[ $status == held ]]
}


@@ -734,7 +742,9 @@ function real_is_depends_enabled() {
##
#---------------------------------------------------------------------
function real_spell_exiled() {
- [ "$( query_spell_status $1 )" == "exiled" ];
+ local status
+ query_spell_status "$1" status
+ [[ $status == exiled ]]
}


@@ -808,7 +818,7 @@ function set_exiled () {
local MY_STATUS

for TO_EXILE in $@; do
- MY_STATUS=$(query_spell_status "$TO_EXILE")
+ query_spell_status "$TO_EXILE" MY_STATUS
case "$MY_STATUS" in
"" )
add_spell_status $TO_EXILE exiled 0.0
@@ -846,7 +856,7 @@ function set_unexiled () {
local MY_STATUS
local TO_UNEXILE
for TO_UNEXILE in $@; do
- MY_STATUS=$(query_spell_status "$TO_UNEXILE")
+ query_spell_status "$TO_UNEXILE" MY_STATUS
if [ x"$MY_STATUS" == x"exiled" ]; then
remove_spell $TO_UNEXILE
else



  • [SM-Commit] GIT changes to master sorcery by Jaka Kranjc (71e05ef9831445f631979a8606df98f9ac30341d), Jaka Kranjc, 01/22/2008

Archive powered by MHonArc 2.6.24.

Top of Page