Skip to Content.
Sympa Menu

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

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 (d6cc8d753c78ddbd5ecee6ad352e90d7cca718a2)
  • Date: Mon, 8 Sep 2008 13:47:08 -0500

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

ChangeLog | 9 +
usr/sbin/cast | 13 +-
usr/sbin/dispel | 72 -------------
usr/sbin/resurrect | 182
+++++++++++++++++++++++++++++++++++
var/lib/sorcery/modules/libresurrect | 5
var/lib/sorcery/modules/libsorcery | 2
6 files changed, 205 insertions(+), 78 deletions(-)

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

* dispel: moved the downgrade code into a separate tool
* resurrect: added script for resurrecting spells, currently an
improved version of dispel -d; check out its --help; man page wanted
* libresurrect, libsorcery, cast: renamed resurrect to resurrect_spell
to not conflict with the new binar... err script
* cast: don't resurrect the spell if it needs an update (duh! why
didn't I think of this earlier)
added some more debug statements for the summary

diff --git a/ChangeLog b/ChangeLog
index e6c97cb..5103a8b 100644
--- a/ChangeLog
+++ b/ChangeLog
@@ -1,3 +1,12 @@
+2008-09-08 Jaka Kranjc <lynxlynxlynx AT sourcemage.org>
+ * dispel: moved the downgrade code into a separate tool
+ * resurrect: added script for resurrecting spells, currently an
+ improved version of dispel -d; check out its --help; man page wanted
+ * libresurrect, libsorcery, cast: renamed resurrect to resurrect_spell
+ to not conflict with the new binar... err script
+ * cast: don't resurrect the spell if it needs an update
+ added some more debug statements for the summary
+
2008-09-06 Jaka Kranjc <lynxlynxlynx AT sourcemage.org>
* libmisc: made log_failure_reason idempotent and added an optional
arg
* libdepends: improved the way exiled spells are handled for the cast
diff --git a/usr/sbin/cast b/usr/sbin/cast
index b3e55d3..5d5f79f 100755
--- a/usr/sbin/cast
+++ b/usr/sbin/cast
@@ -547,8 +547,8 @@ function pass_three() {
## @Globals SPELL COMPILE
## Sets SPELL to spellname.
## Calls trigger "pre_cast"
-## If COMPILE is not set and it can be resurrected
-## (can_resurrect SPELL) it calls resurrect with SPELL as argument.
+## If COMPILE is not set, the spell doesn't need an update and it can
+## be resurrected (can_resurrect SPELL) it calls resurrect with SPELL.
## Otherwise it calls cast_spell.
## If resurrect or cast_spell returned 0 it calls trigger "cast"
## (Is being called by make)
@@ -569,7 +569,9 @@ function pass_four() {
if [[ ! $VERSION ]] ; then
message "Can't find spell version for some reason, is $SPELL a spell?"
else
- can_resurrect $SPELL $VERSION &> /dev/null && do_resurrect=yes
+ can_resurrect $SPELL $VERSION &> /dev/null &&
+ ! does_spell_need_update $SPELL &> /dev/null &&
+ do_resurrect=yes
fi
fi

@@ -580,7 +582,7 @@ function pass_four() {

local rc
if [[ "$do_resurrect" == "yes" ]] ; then
- resurrect $SPELL $VERSION
+ resurrect_spell $SPELL $VERSION
rc=$?
# this is here for safety in case resurrect bails out somewhere
# we didnt expect it to
@@ -633,6 +635,9 @@ function pass_five() {
debug "pass_five" "SUCCESS LIST is : `cat $SUCCESS_LIST 2>/dev/null`"
debug "pass_five" "FAILED LIST is : `cat $FAILED_LIST 2>/dev/null`"
debug "pass_five" "CONFLICT LIST is : `cat $CONFLICT_LIST 2>/dev/null`"
+ debug "pass_five" "CHECK_TRIGGERS_SUCCESS is : `cat
$CHECK_TRIGGERS_SUCCESS 2>/dev/null`"
+ debug "pass_five" "bad_spells is : `hash_get_table_fields bad_spells`"
+ debug "pass_five" "to_cast is : `hash_get_table_fields to_cast`"

if [ -s $SUCCESS_LIST ] ; then

diff --git a/usr/sbin/dispel b/usr/sbin/dispel
index 74a4a80..5a7ca4e 100755
--- a/usr/sbin/dispel
+++ b/usr/sbin/dispel
@@ -81,76 +81,8 @@ EOF
## @param Previous version
#-----
function downgrade() {
-
- SPELL=$1
- REQUESTED_VERSION=$2
- find_cache "$INSTALL_CACHE/$SPELL-$REQUESTED_VERSION-$HOST" CACHE_COMP
-
- if [[ -n $REQUESTED_VERSION && ! -f $CACHE_COMP ]]; then
- message "${FILE_COLOR}$CACHE_COMP" \
- "${PROBLEM_COLOR}was not found." \
- "${DEFAULT_COLOR}"
- return 1
- fi
-
- if spell_installed $SPELL; then
- message "Dispelling $SPELL $(installed_version $SPELL) ..."
- dispel_spell $SPELL
- if [ $? != 0 ] ; then
- message "${PROBLEM_COLOR}Unable to downgrade" \
- "${SPELL_COLOR}${SPELL}${DEFAULT_COLOR}" \
- "dispel failed"
- DISPEL_EXIT_STATUS=${DISPEL_EXIT_STATUS:-1}
- return 1
- fi
- fi
-
- if spell_held $SPELL; then
- message "${PROBLEM_COLOR}Unable to downgrade" \
- "${SPELL_COLOR}${SPELL}${DEFAULT_COLOR}" \
- "because it is held, please unhold it first."
- DISPEL_EXIT_STATUS=${DISPEL_EXIT_STATUS:-1}
- return 1
- fi
-
- if spell_exiled $SPELL; then
- message "${PROBLEM_COLOR}Unable to downgrade" \
- "${SPELL_COLOR}${SPELL}${DEFAULT_COLOR}" \
- "because it is exiled, please unexile it first."
- return 1
- fi
-
- local version versions chosen_version
- versions=$(find $INSTALL_CACHE -name "$SPELL-*-$HOST.*" -printf "%f\n" |
- sed "s,^$SPELL-\(\S*\)-$HOST\.\S*$,\1," |
- while read version; do
- # we need to ignore other spells with similar names due to laxed
matching
- # for example, wine-gecko would match when searching for wine, but we
can
- # check if wine + gecko is a spell. We do that by comparing version
parts
- if ! codex_find_spell_by_name "$SPELL-${version%%-*}" &>/dev/null; then
- local version2="${version#*-}"
- if ! codex_find_spell_by_name
"$SPELL-${version%%-*}-${version2%%-*}" &>/dev/null; then
- echo $version
- fi
- fi
- done | sort -r)
- if [[ -z $versions ]]; then
- error_message "${PROBLEM_COLOR}Unable to downgrade" \
- "${SPELL_COLOR}${SPELL}${DEFAULT_COLOR}" \
- "because no cache was found."
- return 1
- fi
- # skip the query if there is only one candidate version
- if [[ $(wc -l <<< "$versions") != 1 ]]; then
- select_list chosen_version "$REQUESTED_VERSION" $versions
- else
- chosen_version="$versions"
- fi
-
- SUCCESS_LIST=/dev/null
- resurrect $SPELL $chosen_version
-
- return 0
+ resurrect $1 -v "$2"
+ DISPEL_EXIT_STATUS=$?
}

#-----
diff --git a/usr/sbin/resurrect b/usr/sbin/resurrect
new file mode 100755
index 0000000..df81e03
--- /dev/null
+++ b/usr/sbin/resurrect
@@ -0,0 +1,182 @@
+#!/bin/bash
+#---------------------------------------------------------------------
+##
+## @Synopsis This utility lets resurrect spells - install them from
+## @Synopsis caches (install, downgrade, upgrade)
+##
+## @Copyright
+##
+## Copyright 2008 by the Source Mage Team
+##
+#---------------------------------------------------------------------
+
+function help() {
+ cat << EOF
+Resurrects the spell(s) if there is a cache available.
+
+Examples:
+resurrect aalib bb
+resurrect gemrb -v 0.3.0
+resurrect -l nano joe elvis
+
+resurrect [parameters] spell [version]
+resurrect [-l] spell [spell2] [spell3] ...
+
+Optional Parameters:
+-l, --latest use the latest available version (cache)
+-v, --version <version> use the specified version
+-h, --help will just print this help
+
+You can invoke resurrect with spell names only or also specify the desired
+version via -v (this only works for a single spell!).
+If no version is passed, resurrect will show the available ones and
+ask you which to resurrect, defaulting to the latest.
+If -l is passed, the latest (newest mtime) version will be resurrected
without querying.
+If both -v and -l are specified, the -l option is ignored.
+EOF
+ exit 1
+}
+
+function do_resurrect() {
+ local spell=$1
+ local requested_version=$USE_VERSION
+ local cache
+ local error_base="${PROBLEM_COLOR}Unable to resurrect $SPELL_COLOR$spell"
+ error_base="$error_base$DEFAULT_COLOR because$PROBLEM_COLOR"
+
+ if [[ -n $requested_version ]]; then
+ # use the version for only one spell in case more were specified
(illegal)
+ unset USE_VERSION
+
+ find_cache "$INSTALL_CACHE/$spell-$requested_version-$HOST" cache
+ if [[ ! -f $cache ]]; then
+ error_message "$error_base no cache for version $requested_version" \
+ "was found.$DEFAULT_COLOR"
+ return 1
+ fi
+ fi
+
+ if spell_held $spell; then
+ error_message "$error_base it is held, please unhold it
first.$DEFAULT_COLOR"
+ return 1
+ fi
+
+ if spell_exiled $spell; then
+ error_message "$error_base it is exiled, please unexile it
first.$DEFAULT_COLOR"
+ return 1
+ fi
+
+ if spell_installed $spell; then
+ message "Dispelling $spell $(installed_version $spell) ..."
+ dispel_spell $spell
+ if [[ $? != 0 ]]; then
+ error_message "$error_base the dispel failed.$DEFAULT_COLOR"
+ return 1
+ fi
+ fi
+
+ local chosen_version
+ if [[ -n $requested_version ]]; then
+ chosen_version=$requested_version
+ else
+ # find the available versions, regardless of compression
+ local version versions
+ versions=$(find $INSTALL_CACHE -name "$spell-*-$HOST.*" -printf "%f\n" |
+ sed "s,^$spell-\(\S*\)-$HOST\.\S*$,\1," |
+ while read version; do
+ # we need to ignore other spells with similar names due to laxed
matching
+ # for example, wine-gecko would match when searching for wine, but
we can
+ # check if wine + gecko is a spell. We do that by comparing version
parts
+ if ! codex_find_spell_by_name "$spell-${version%%-*}" &>/dev/null;
then
+ local version2="${version#*-}"
+ if ! codex_find_spell_by_name
"$spell-${version%%-*}-${version2%%-*}" &>/dev/null; then
+ echo $version
+ fi
+ fi
+ done | sort -r)
+
+ if [[ -z $versions ]]; then
+ error_message "$error_base no cache was found.$DEFAULT_COLOR"
+ return 1
+ fi
+
+ # skip the query if there is only one candidate version
+ if [[ $(wc -l <<< "$versions") == 1 ]]; then
+ chosen_version="$versions"
+ else
+ if [[ -n $USE_LATEST ]]; then
+ # determine the latest version by checking modification time
+ chosen_version=$(
+ for version in $versions; do
+ # output: mtime version
+ stat --printf "%Y $version\n"
$INSTALL_CACHE/$spell-$version-$HOST.*
+ done | sort -g -r | head -n1 | cut -d" " -f2
+ )
+ else
+ select_list chosen_version "" $versions
+ fi
+ fi
+ fi
+
+ SUCCESS_LIST=/dev/null
+ resurrect_spell $spell $chosen_version
+}
+
+#---------------------------------------------------------------------
+## Parse the arguments and start resurrecting. If the version is
+## specified, the -l option is ignored.
+#---------------------------------------------------------------------
+function main() {
+ local arguments resurrectee USE_LATEST USE_VERSION
+
+ while [[ -n $1 ]]; do
+ if [[ ${1:0:1} == "-" ]]; then
+ case "$1" in
+ --help|-h) help ;;
+ --latest|-l) [[ -z $USE_VERSION ]] && USE_LATEST=on ;;
+ --version|-v) USE_VERSION="$2"
+ shift
+ unset USE_LATEST
+ ;;
+ *) help ;;
+ esac
+ else
+ codex_does_spell_exist $1 && list_add arguments $1
+ fi
+ shift
+ done
+
+ for resurrectee in $arguments; do
+ do_resurrect $resurrectee
+ echo
+ done
+}
+
+. /etc/sorcery/config
+if [[ $UID -gt 0 ]]; then
+ echo "Enter the root password, please."
+ exec su -c "resurrect $@" root
+else
+ main "$@"
+fi
+
+#---------------------------------------------------------------------
+##=back
+##
+##=head1 LICENSE
+##
+## 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
+## the Free Software Foundation; either version 2 of the License, or
+## (at your option) any later version.
+##
+## This software is distributed in the hope that it will be useful,
+## but WITHOUT ANY WARRANTY; without even the implied warranty of
+## MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the
+## GNU General Public License for more details.
+##
+## You should have received a copy of the GNU General Public License
+## along with this software; if not, write to the Free Software
+## Foundation, Inc., 59 Temple Place, Suite 330, Boston, MA 02111-1307 USA
+##
+#---------------------------------------------------------------------
diff --git a/var/lib/sorcery/modules/libresurrect
b/var/lib/sorcery/modules/libresurrect
index c4a820f..b7d2525 100755
--- a/var/lib/sorcery/modules/libresurrect
+++ b/var/lib/sorcery/modules/libresurrect
@@ -64,7 +64,7 @@ function can_resurrect() {
##
## FIXME: some of the informative message calls might work better as debug
messages
#------------------------------------------------------------------------
-function resurrect() { (
+function resurrect_spell() { (
debug "libresurrect" "resurrect - $*"
local SPELL=$1
local VERSION=$2
@@ -449,7 +449,6 @@ function internal_install_config_file() {
# copy the new one in (plus leading directories)
mkdir -p "$(smgl_dirname "$to")" &&
cp -pv "$from" "$to"
-
# to get here the file must exist
elif test -d "$to"; then
message "Trying to install a file ($from) to what was a directory ($to),
I dont know what to do!"
@@ -638,7 +637,7 @@ function resurrect_success() {
clear_line
activity_log "resurrect" "$SPELL" "$VERSION" "success"
message "${RESURRECT_COLOR}Resurrected spell: ${SPELL_COLOR}${SPELL}" \
- "${DEFAULT_COLOR} version ${VERSION_COLOR}${VERSION}" \
+ "${DEFAULT_COLOR}version ${VERSION_COLOR}${VERSION}" \
"${DEFAULT_COLOR}"
}

diff --git a/var/lib/sorcery/modules/libsorcery
b/var/lib/sorcery/modules/libsorcery
index fa831ae..80f8092 100755
--- a/var/lib/sorcery/modules/libsorcery
+++ b/var/lib/sorcery/modules/libsorcery
@@ -381,7 +381,7 @@ function spell_recover() {
unlock_resources "solo" "cast"
local current_version=$(installed_version $SPELL)
SUCCESS_LIST=/dev/null
- resurrect $SPELL $current_version
+ resurrect_spell $SPELL $current_version

exit 130
}



  • [SM-Commit] GIT changes to master sorcery by Jaka Kranjc (d6cc8d753c78ddbd5ecee6ad352e90d7cca718a2), Jaka Kranjc, 09/08/2008

Archive powered by MHonArc 2.6.24.

Top of Page