Skip to Content.
Sympa Menu

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

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 (fde9501577b26b22f58bb74dfb4f9999ad5fea95)
  • Date: Wed, 2 Apr 2008 12:15:09 -0500

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

ChangeLog | 9 +++++
var/lib/sorcery/modules/libcodex | 28 ++++++++++++++++
var/lib/sorcery/modules/libdepends | 61
++++++++++++++++++++++++++++---------
var/lib/sorcery/modules/libstate | 33 +++++++++++++++++++-
4 files changed, 116 insertions(+), 15 deletions(-)

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

* libcodex: added codex_find_spell_provides which prints the features
the spell is a provider of
* libdepends: added support for recasting of spells that have a
disabled
dependency on a feature which the cast spell is a provider of. Part
of
private_recast_optionals
* libstate: changed a regex in toggle_depends_status to be more
general
added change_spell_provider for silently changing and toggling
providers

this means that cast -O ask-yes sendmail would
ask about php if the dependency on MAIL-TRANSPORT-AGENT is currently
disabled

diff --git a/ChangeLog b/ChangeLog
index b2ee7b7..1c68139 100644
--- a/ChangeLog
+++ b/ChangeLog
@@ -1,3 +1,12 @@
+2008-04-02 Jaka Kranjc <lynxlynxlynx AT sourcemage.org>
+ * libcodex: added codex_find_spell_provides which prints the features
+ the spell is a provider of
+ * libdepends: added support for recasting of spells that have a
disabled
+ dependency on a feature which the cast spell is a provider of. Part
of
+ private_recast_optionals
+ * libstate: changed a regex in toggle_depends_status to be more
general
+ added change_spell_provider for silently changing and toggling
providers
+
2008-03-31 Jaka Kranjc <lynxlynxlynx AT sourcemage.org>
* libmisc: added an esc_provider_str function for queries that look
for
spells that provide the provider, where the initial .* should not be
diff --git a/var/lib/sorcery/modules/libcodex
b/var/lib/sorcery/modules/libcodex
index e67c555..355b414 100755
--- a/var/lib/sorcery/modules/libcodex
+++ b/var/lib/sorcery/modules/libcodex
@@ -709,6 +709,34 @@ function codex_set_current_spell_by_name() {
[ -n "$SPELL_NAME" ] && codex_set_current_spell $SPELL_NAME
}

+#---------------------------------------------------------------------
+## @param spell name
+## Returns the features a spell is a provider off.
+## Example, firefox: GECKO, GRAPHICAL-WEB-BROWSER, WEB-BROWSER,
+## NS-PLUGIN-COMPATIBLE
+##
+#---------------------------------------------------------------------
+function codex_find_spell_provides() {
+ local spell="$1"
+ local feature grimoire
+ local features=$(
+ for grimoire in $(codex_get_all_grimoires); do
+ gawk '/\/'$spell'$/ { print $1 }' \
+ "$grimoire/$PROVIDE_INDEX_FILE"
+ done | sort -u)
+
+ # filter out providers we dont want, so far this is:
+ # a) spells that do not provide something in the first grimoire they are
+ # found in (see note in find_providers)
+ local spell_path=$(codex_find_spell_by_name $spell)
+ smgl_dirname $(smgl_dirname $spell_path) grimoire
+ for feature in $features; do
+ # ensure the first place we look for the spell is a provider
+ grep -q "^$feature $spell_path$" $grimoire/$PROVIDE_INDEX_FILE &&
+ echo $feature
+ done
+}
+

##############################CACHE FUNCTIONS#########################
#---------------------------------------------------------------------
diff --git a/var/lib/sorcery/modules/libdepends
b/var/lib/sorcery/modules/libdepends
index 6eef079..1ebbaf4 100755
--- a/var/lib/sorcery/modules/libdepends
+++ b/var/lib/sorcery/modules/libdepends
@@ -581,9 +581,28 @@ function private_upward_depends() {
fi
}

+# shared code for both loops in private_recast_optionals
+private_recast_optionals_sub() {
+ local spell="$1"
+ local message="$2"
+
+ enabled=""
+ message "$message"
+ if [[ $RECAST_OPTIONALS == always ]]; then
+ enabled=yes
+ else
+ local default=n
+ [[ $RECAST_OPTIONALS == ask-yes ]] && default=y
+ if query "Recast $spell with the dependency enabled?" $default; then
+ enabled=yes
+ fi
+ fi
+}
+
#---------------------------------------------------------------------
## Find spells that optionally depended on the current spell but had the
## dependency disabled, ask if the user wants to recast the spell.
+## Also finds disabled features that the current spell is a provider of.
#---------------------------------------------------------------------
function private_recast_optionals() {
if [[ $RECAST_OPTIONALS ]] && [[ $RECAST_OPTIONALS != ignore ]] ; then
@@ -591,28 +610,42 @@ function private_recast_optionals() {
let j=${#NEW_UP_DEPENDS[*]}
for spell in $(search_depends_status_exact $DEPENDS_STATUS \
'.*' "$1\(([^:]*)\)\?" off optional '.*' '.*'|cut -f1 -d:);
do
-
- enabled=""
- message "$spell" "has a disabled optional dependency on" "$1"
- if [[ $RECAST_OPTIONALS == always ]] ; then
- enabled=yes
- else
- local default=n
- [[ $RECAST_OPTIONALS == ask-yes ]] && default=y
- if query "Recast $spell with dependency enabled?" $default ; then
- enabled=yes
- fi
- fi
+ private_recast_optionals_sub $spell \
+ "$spell has a disabled optional dependency on $1"
if [[ $enabled ]] ; then
NEW_UP_DEPENDS[$j]=$spell
let j++
# toggle the dependency, so the user doesn't get requeried
- toggle_depends_status $DEPENDS_STATUS $spell $1
+ toggle_depends_status $DEPENDS_STATUS $spell "$1(\([^:]*\))?"
spells=( ${spells[*]} $spell )
fi
done
- fi

+ # also check for disabled features that $1 is a provider of
+ local features feature_regex
+ # get the features and build a regex for quicker lookup
+ features=$(codex_find_spell_provides $1)
+ for feature in $features; do
+ feature_regex="$feature\|$feature_regex"
+ done
+ feature_regex=${feature_regex%\\|}
+ for spell in $(search_depends_status_exact $DEPENDS_STATUS \
+ '.*' "($feature_regex)" off optional '.*' '.*'|cut -f1
-d:|sort -u); do
+ private_recast_optionals_sub $spell \
+ "$spell has a disabled optional dependency on $1 as a provider"
+ if [[ $enabled ]] ; then
+ NEW_UP_DEPENDS[$j]=$spell
+ let j++
+ # toggle all the features that $1 provides and set $1 as their
provider
+
+for feature in $features; do
+ change_spell_provider $DEPENDS_STATUS $spell "$1" "$feature" "on"
+done
+
+ spells=( ${spells[*]} $spell )
+ fi
+ done
+ fi
}

###################BEGIN CALLBACKS FROM OUTSIDE#######################
diff --git a/var/lib/sorcery/modules/libstate
b/var/lib/sorcery/modules/libstate
index 533e3e3..65f9b7d 100755
--- a/var/lib/sorcery/modules/libstate
+++ b/var/lib/sorcery/modules/libstate
@@ -249,13 +249,44 @@ function toggle_depends_status() {
local t_status
lock_start_transaction "$depends_status" t_status
awk -F ':' -v OFS=':' \
- '/^'$spell:$dependency'(\([^:]*\))?:(on|off):(optional|suggest):/ \
+ '/^'$spell:$dependency':(on|off):(optional|suggest):/ \
{ if ($3 == "on") $3 = "off"; else $3 = "on"; }
{ print; }' $depends_status > $t_status
lock_commit_transaction "$depends_status"
}

#---------------------------------------------------------------------
+## Changes the $spell's provider of $feature to a $new one. Can also
+## toggle it to be enabled or disabled.
+##
+## @param depends file
+## @param spell
+## @param new provider
+## @param feature
+## @param on/off
+##
+#---------------------------------------------------------------------
+function change_spell_provider() {
+ local depends_status=$1
+ shift
+
+ local spell new_provider feature enabled
+ esc_str "$1" spell
+ esc_str "$2" new_provider
+ esc_str "$3" feature
+ enabled=$4
+
+ local t_status
+ lock_start_transaction "$depends_status" t_status
+ if [[ -z $enabled ]]; then
+ sed -i "s/^$spell:[^:]*($feature):/$spell:$new_provider($feature):/"
$t_status
+ else
+ sed -i
"s/^$spell:[^:]*($feature):[^:]*:/$spell:$new_provider($feature):$enabled:/"
$t_status
+ fi
+ lock_commit_transaction "$depends_status"
+}
+
+#---------------------------------------------------------------------
## Sets up the uncommitted depends file. If the name isn't
## found in the hash table create it. If the file already exists
## move it to the abandoned depends directory and start with a new one.



  • [SM-Commit] GIT changes to master sorcery by Jaka Kranjc (fde9501577b26b22f58bb74dfb4f9999ad5fea95), Jaka Kranjc, 04/02/2008

Archive powered by MHonArc 2.6.24.

Top of Page