Skip to Content.
Sympa Menu

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

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 (0a7194e710f4ebfa4503b593ab56eb52e4341e25)
  • Date: Wed, 14 Sep 2011 12:27:58 -0500

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

ChangeLog | 1 +
usr/sbin/cast | 10 ++++------
var/lib/sorcery/modules/libcast | 24 ++++++++++++++++++------
var/lib/sorcery/modules/libresurrect | 24 ++++++++++++++++++------
4 files changed, 41 insertions(+), 18 deletions(-)

New commits:
commit 0a7194e710f4ebfa4503b593ab56eb52e4341e25
Author: Jaka Kranjc <lynxlynxlynx AT sourcemage.org>
Commit: Jaka Kranjc <lynxlynxlynx AT sourcemage.org>

libcast, cast: rather dispel conflicts during cast_spell

(juhu!)

diff --git a/ChangeLog b/ChangeLog
index dd8bc40..940a78e 100755
--- a/ChangeLog
+++ b/ChangeLog
@@ -2,6 +2,7 @@
* config: unset GREP_OPTIONS in case the user set it to something bad
* libstage: ensure the install log is sorted #33
* gaze: only search for files in gaze-from
+ * libcast, cast: rather dispel conflicts during cast_spell

2011-08-18 Jaka Kranjc <lynxlynxlynx AT sourcemage.org>
* gaze: fixed gaze from not finding "[", fixes #41
diff --git a/usr/sbin/cast b/usr/sbin/cast
index 5def4fb..60977f6 100755
--- a/usr/sbin/cast
+++ b/usr/sbin/cast
@@ -216,6 +216,8 @@ function cast_spell() { (
run_details
load_build_api || return 1

+ dispel_conflicts $SPELL || return 1
+
# show_downloading tail -f's (essentially) the download log as it
# comes in, or if downloading is complete, cats the download log, in
# either case it blocks until downloading is complete by the presence of
@@ -421,11 +423,6 @@ function pass_two() {
return 1
fi

- if ! dispel_conflicts; then
- #FIXME: only break the conflictees, not the whole cast
- error_message "There was a problem with dispelling the conflicts.
Bailing out!"
- return 1
- fi
echo

rm -f $TMP_DIR/pass_three.done # don't return until this file exists
@@ -707,7 +704,7 @@ function pass_five() {
message "${DEFAULT_COLOR}"
message "${MESSAGE_COLOR}Spells that have been removed due to conflicts:"
message "-----------------------------------------------${QUERY_COLOR}"
- for item in `cat $CONFLICT_LIST 2>/dev/null`; do
+ for item in $(cut -d" " -f2- $CONFLICT_LIST 2>/dev/null); do
message "$item"
done | sort | column
message "${DEFAULT_COLOR}"
@@ -905,6 +902,7 @@ elif [ ${0:0:5} != "/tmp/" ]; then
mk_tmp_dirs backup /tmp/cast
export CAST_BACKUPDIR=$TMP_DIR
mk_tmp_dirs cast
+ export CAST_TMPDIR=$TMP_DIR

export SAFE_CAST="$TMP_DIR/casting.safe"
export SUCCESS_LIST="$TMP_DIR/success_list"
diff --git a/var/lib/sorcery/modules/libcast b/var/lib/sorcery/modules/libcast
index 97765f2..00f2e73 100755
--- a/var/lib/sorcery/modules/libcast
+++ b/var/lib/sorcery/modules/libcast
@@ -97,10 +97,13 @@ function query_conflicts() {
local ignore_conflict=$1
local output=${2:-$CONFLICT_LIST}

+ # skip if the spell was already processed (avoids a double query for
in-cast resurrects)
+ [[ -s $output ]] && awk -v s=$SPELL '{ if ($1 == s) {rc=1} } END {exit
!rc}' $output && return 0
+
if [[ -x $SCRIPT_DIRECTORY/CONFLICTS ]]; then
local CONFLICTS=$(run_spell_file CONFLICTS conflicts) || return 1

- local tmp to_dispel=""
+ local tmp conflicts to_dispel=""
for tmp in $CONFLICTS; do
local spell_and_default
explode $tmp ':' spell_and_default
@@ -114,12 +117,15 @@ function query_conflicts() {
text="$text ${SPELL_COLOR}${spell_and_default[0]}${MESSAGE_COLOR}?"

if query "$text" ${spell_and_default[1]}; then
- echo ${spell_and_default[0]} >> $output
+ list_add conflicts "${spell_and_default[0]}"
else
log_failure_reason "conflicts"
return 1
fi
done
+ if [[ $conflicts ]]; then
+ echo $SPELL $conflicts >> $output
+ fi
fi

return 0
@@ -127,11 +133,13 @@ function query_conflicts() {

#---------------------------------------------------------------------
## Dispels the spells that are scheduled for a dispel due to conflicting
+## @param spell whose conflicts to dispel
## @param file containing the list of conflicts
#---------------------------------------------------------------------
function dispel_conflicts() {
- local conflict_list=${1:-$CONFLICT_LIST}
- local spell
+ local spell=$1
+ local conflict_list=${2:-$CONFLICT_LIST}
+ local conflict

if [[ -s $conflict_list ]]; then
message "${MESSAGE_COLOR}Dispelling conflicts...$DEFAULT_COLOR"
@@ -139,8 +147,12 @@ function dispel_conflicts() {
return 0
fi

- for spell in $(sort -u $conflict_list); do
- dispel --nosustain --noqueue $spell || return 1
+ # no conflict is repeated, since we use list_add (idempotent) to construct
it
+ for conflict in $(awk '{ if($1 == "'$1'") { $1=""; print $0;} }'
"$conflict_list"); do
+ # don't break if it was already removed by another conflict
+ if spell_ok $conflict; then
+ dispel --nosustain --noqueue $conflict || return 1
+ fi
done
}

diff --git a/var/lib/sorcery/modules/libresurrect
b/var/lib/sorcery/modules/libresurrect
index fbf1f92..7daae48 100755
--- a/var/lib/sorcery/modules/libresurrect
+++ b/var/lib/sorcery/modules/libresurrect
@@ -272,16 +272,28 @@ function resurrect_spell() { (
fi

# 9) remove conflicts, but not self-conflicts, they make no sense
- local conflicts=$TMP_DIR/list.of.conflicts
- > $conflicts
- query_conflicts $SPELL $conflicts
- if [[ $? == 0 ]] && dispel_conflicts $conflicts; then
- rm $conflicts
+ # be extra careful to get the right list, since we may be called from
within cast
+ local conflicts;
+ if [[ -z $CAST_TMPDIR ]]; then
+ conflicts="$TMP_DIR/list.of.conflicts"
+ > "$conflicts"
else
- rm $conflicts
+ conflicts="$CAST_TMPDIR/conflict_list" # the original $CONFLICT_LIST
+ fi
+ # we need the CONFLICTS file for this, but it wasn't unpacked yet
+ # change the SCRIPT_DIRECTORY out of the tablet (in the making) for this
+ # TODO: unpack just this file instead if it turns out there are problems
+ local tmp="$SCRIPT_DIRECTORY"
+ SCRIPT_DIRECTORY=$(codex_find_spell_by_name $SPELL)
+ query_conflicts $SPELL "$conflicts"
+ if [[ $? == 0 ]] && dispel_conflicts $SPELL "$conflicts"; then
+ rm "$conflicts"
+ else
+ rm "$conflicts"
resurrect_fail
return 1
fi
+ SCRIPT_DIRECTORY="$tmp"

#####
# Start of critical region



  • [SM-Commit] GIT changes to master sorcery by Jaka Kranjc (0a7194e710f4ebfa4503b593ab56eb52e4341e25), Jaka Kranjc, 09/14/2011

Archive powered by MHonArc 2.6.24.

Top of Page