Skip to Content.
Sympa Menu

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

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 (f8069eb76bbd1f2727c678ffadba336f1cd9d2aa)
  • Date: Tue, 8 Apr 2008 14:44:57 -0500

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

ChangeLog | 19 ++++++
etc/sorcery/config | 1
usr/sbin/alter | 13 ++--
usr/sbin/dispel | 2
var/lib/sorcery/modules/build_api/api2 | 2
var/lib/sorcery/modules/build_api/common | 6 +-
var/lib/sorcery/modules/libresurrect | 18 +-----
var/lib/sorcery/modules/libsorcery | 49 ++++++-----------
var/lib/sorcery/modules/libtrack | 87
+++++++++++++++++++++++++------
var/lib/sorcery/modules/libunpack | 43 +++++++++++----
10 files changed, 158 insertions(+), 82 deletions(-)

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

* libtrack: added find_cache, a function similar to
guess_filename for
finding caches from part of their name
added construct_cache_name which currently just appends
$ARCHIVEBIN
modified create_cache_archive to be more generic
* alter, dispel, common: use the new functions to be more
abstract; now
caches created with a different compressor than the current
work too
* libunpack: added optional params to unpack_uncompress and a
wrapper for
caches uncompress_unpack_cache
* libressurect: fixed can_resurrect to accept other extensions
made ressurect use the new unpack_uncompress wrapper
* libsorcery: made spell_recover use ressurect
set_compression_type now distinguishes between compressors and
archivers;
tar is now saved to ARCHIVEBIN, EXTENSION holds the compressed
extension
* config: added a default for ARCHIVEBIN
* api2: preserve the return status in run_pre_install
* all this was part of bug #14218, FIXMEs and planned support for
other
compressors and archivers

initial testing shows no problems, but please tell me if you start seeing
any
wierd behaviour

diff --git a/ChangeLog b/ChangeLog
index f2aaaf2..7a993da 100644
--- a/ChangeLog
+++ b/ChangeLog
@@ -1,3 +1,22 @@
+2008-04-08 Jaka Kranjc <lynxlynxlynx AT sourcemage.org>
+ * libtrack: added find_cache, a function similar to guess_filename for
+ finding caches from part of their name
+ added construct_cache_name which currently just appends $ARCHIVEBIN
+ modified create_cache_archive to be more generic
+ * alter, dispel, common: use the new functions to be more abstract;
now
+ caches created with a different compressor than the current work too
+ * libunpack: added optional params to unpack_uncompress and a wrapper
for
+ caches uncompress_unpack_cache
+ * libressurect: fixed can_resurrect to accept other extensions
+ made ressurect use the new unpack_uncompress wrapper
+ * libsorcery: made spell_recover use ressurect
+ set_compression_type now distinguishes between compressors and
archivers;
+ tar is now saved to ARCHIVEBIN, EXTENSION holds the compressed
extension
+ * config: added a default for ARCHIVEBIN
+ * api2: preserve the return status in run_pre_install
+ * all this was part of bug #14218, FIXMEs and planned support for
other
+ compressors and archivers
+
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
diff --git a/etc/sorcery/config b/etc/sorcery/config
index 6af7757..31a10f0 100755
--- a/etc/sorcery/config
+++ b/etc/sorcery/config
@@ -24,6 +24,7 @@ shopt -u expand_aliases
NET_SELECT=${NET_SELECT:=off}
MD5SUM_DL=${MD5SUM_DL:=ask_risky}
CLEAN_SOURCE=${CLEAN_SOURCE:=off}
+ ARCHIVEBIN=${ARCHIVEBIN:=tar}
COMPRESSBIN=${COMPRESSBIN:=bzip2}
EXTENSION=${EXTENSION:=.bz2}
SET_TERM_TITLE=${SET_TERM_TITLE:=off}
diff --git a/usr/sbin/alter b/usr/sbin/alter
index cc76bdb..3d57e2e 100755
--- a/usr/sbin/alter
+++ b/usr/sbin/alter
@@ -31,7 +31,7 @@ EOF
MD5_LOG=$MD5SUM_LOGS/$SPELL-$VERSION
C_LOG=$TMP_DIR/$SPELL-$VERSION.compile.log
C_LOG_COMP=$COMPILE_LOGS/$SPELL-$VERSION$EXTENSION
- CACHE=$INSTALL_CACHE/$SPELL-$VERSION-$HOST.tar
+ construct_cache_name "$INSTALL_CACHE/$SPELL-$VERSION-$HOST" CACHE
CACHE_COMP=${CACHE}${EXTENSION}
rm -f "$C_LOG" 2> /dev/null
touch "$C_LOG"
@@ -136,13 +136,16 @@ function alter_md5_mend() {
sed -e 's/.*/\\:&: d/' |
sed -i -f - "$MD5SUM_LOGS/$SPVER"
if [ "$ARCHIVE" != "off" ]; then
- if [ "$COMPRESSBIN" == "tar" ]; then
+ local cache
+ find_cache "$INSTALL_CACHE/$SPVER-" cache
+ local compressor=$(guess_compressor "$cache")
+ if [[ $compressor == tar ]]; then
echo "$SPFLS" |
- tar -f $INSTALL_CACHE/$SPVER-*.tar \
+ tar -f $cache \
-kx -T /dev/stdin -C "$STORE" 2> /dev/null
else
echo "$SPFLS" |
- tar --"$COMPRESSBIN" -f $INSTALL_CACHE/$SPVER-*.tar$EXTENSION \
+ tar --use-compress-program $compressor -f $cache \
-kx -T /dev/stdin -C "$STORE" 2> /dev/null
fi
fi
@@ -162,7 +165,7 @@ function alter_md5_mend() {
echo -n "$RESULTS" > "$STORE/tmp/sorcery/$SPELL-$VERSION-backup.md5"
find * > "$INST_LOG"
create_md5list "$INST_LOG" "$MD5S_LOG" # relative to STORE instead of
absolute
- CACHE="$INSTALL_CACHE/$SPELL-$VERSION-$HOST.tar"
+ construct_cache_name "$INSTALL_CACHE/$SPELL-$VERSION-$HOST" CACHE
CACHE_COMP="${CACHE}${EXTENSION}"
# No install log nor compile cache needed or wanted since we are
# only doing md5sum deletions from other spells, the undeleted
diff --git a/usr/sbin/dispel b/usr/sbin/dispel
index d3a0de7..3ac7f61 100755
--- a/usr/sbin/dispel
+++ b/usr/sbin/dispel
@@ -83,7 +83,7 @@ function downgrade() {

SPELL=$1
REQUESTED_VERSION=$2
- CACHE_COMP="$INSTALL_CACHE/$SPELL-$REQUESTED_VERSION-$HOST.tar$EXTENSION"
+ find_cache "$INSTALL_CACHE/$SPELL-$REQUESTED_VERSION-$HOST" CACHE_COMP

if [[ -n $REQUESTED_VERSION && ! -f $CACHE_COMP ]]; then
message "${FILE_COLOR}$CACHE_COMP" \
diff --git a/var/lib/sorcery/modules/build_api/api2
b/var/lib/sorcery/modules/build_api/api2
index 1c83680..824a89b 100755
--- a/var/lib/sorcery/modules/build_api/api2
+++ b/var/lib/sorcery/modules/build_api/api2
@@ -190,8 +190,10 @@ function run_pre_install() {
fi

run_spell_file PRE_INSTALL pre_install
+ local rc=$?
echo "Compile log for $SPELL $VERSION Completed Build on `date -u`" >>
$C_LOG
pwd > $S_PWD
+ return $rc
}


diff --git a/var/lib/sorcery/modules/build_api/common
b/var/lib/sorcery/modules/build_api/common
index bdf1796..9ea8182 100755
--- a/var/lib/sorcery/modules/build_api/common
+++ b/var/lib/sorcery/modules/build_api/common
@@ -230,10 +230,12 @@ function run_spell_success() {
local MD5_LOG="$MD5SUM_LOGS/$SPELL-$VERSION"
local TMP_INST_LOG="$TMP_DIR/$SPELL-$VERSION.install"
local TMP_MD5_LOG="$TMP_DIR/$SPELL-$VERSION.md5"
- local CACHE="$INSTALL_CACHE/$SPELL-$VERSION-$HOST.tar"
- local CACHE_COMP=${CACHE}${EXTENSION}
local C_LOG_COMP="$COMPILE_LOGS/$SPELL-$VERSION$EXTENSION"

+ local CACHE
+ construct_cache_name "$INSTALL_CACHE/$SPELL-$VERSION-$HOST" CACHE
+ local CACHE_COMP=$CACHE$EXTENSION
+
sound SUCCESS

# announce to everyone the spell succeeded
diff --git a/var/lib/sorcery/modules/libresurrect
b/var/lib/sorcery/modules/libresurrect
index f451004..715f7d8 100755
--- a/var/lib/sorcery/modules/libresurrect
+++ b/var/lib/sorcery/modules/libresurrect
@@ -12,19 +12,15 @@

#---------------------------------------------------------------------
## @param spellname
-## determines if a particular version of a spell can be cast
-## test -f $INSTALL_CACHE/$SPELL-$VERSION-$HOST.tar.bz2
+## determines if a particular version of a spell can be resurrected
#---------------------------------------------------------------------
function can_resurrect() {
debug "libresurrect" "can_resurrect - $*"
local SPELL=$1
local VERSION=$2

- # FIXME accept files of other extensions
- local file=$INSTALL_CACHE/$SPELL-$VERSION-$HOST.tar$EXTENSION &&
- test -f $file &&
- echo $file &&
- debug "libresurrect" "I am able to resurrect." &&
+ find_cache "$INSTALL_CACHE/$SPELL-$VERSION-$HOST" || return 1
+ debug "libresurrect" "I am able to resurrect."
return 0
}

@@ -119,13 +115,7 @@ function resurrect() { (
# note: tarballs are cached relative to $INSTALL_ROOT and $STATE_ROOT
# eg, with no special prefix, however install logs are relative to
# track_root and state root (isnt this fun?)
-
- # FIXME get a generic routine to unpack this stuff
- if [ -n "$EXTENSION" ]; then
- $COMPRESSBIN -cd $CACHE_COMP | tar -x 1>/dev/null 2>&1
- else
- tar -xf $CACHE_COMP 1>/dev/null 2>&1
- fi || {
+ uncompress_unpack_cache $CACHE_COMP || {
message "Failed to unpack $CACHE_COMP"
resurrect_fail
return 1
diff --git a/var/lib/sorcery/modules/libsorcery
b/var/lib/sorcery/modules/libsorcery
index b46d2ba..d1d8329 100755
--- a/var/lib/sorcery/modules/libsorcery
+++ b/var/lib/sorcery/modules/libsorcery
@@ -373,7 +373,6 @@ function release_saved_libraries() {
#---------------------------------------------------------------------
##
## Recovers from a CTRL-C while casting a spell
-## FIXME: this should be a resurrect
##
#---------------------------------------------------------------------
function spell_recover() {
@@ -381,36 +380,16 @@ function spell_recover() {
debug "libsorcery" "Running spell_recover()"

message "${MESSAGE_COLOR}Aborting dispel of ${SPELL_COLOR}${SPELL}" \
- "${MESSAGE_COLOR} and recovering${DEFAULT_COLOR}"
+ "${MESSAGE_COLOR}and recovering...${DEFAULT_COLOR}"

- CURRENT_VERSION=$(installed_version $SPELL)
- CACHE_COMP="$INSTALL_CACHE/$SPELL-$CURRENT_VERSION-$HOST.tar$EXTENSION"
- CONTINUE=false
-
- if [ ! -f $CACHE_COMP ]; then
- false
- elif [ -n "$EXTENSION" ]; then
- CONTINUE=true
- elif $COMPRESSBIN -tf $CACHE_COMP
- then
- CONTINUE=true
- fi
-
- if $CONTINUE
- then
-
- if [ -n "$EXTENSION" ]; then
- $COMPRESSBIN -cd $CACHE_COMP | tar -Pkx 2>/dev/null
- else
- tar -Pkxf $CACHE_COMP 2>/dev/null
- fi
- add_spell $SPELL installed $CURRENT_VERSION
- else
- false
- fi
+ unlock_resources "libgrimoire" "install"
+ unlock_resources "cast" "$SPELL"
+ unlock_resources "solo" "cast"
+ local current_version=$(installed_version $SPELL)
+ SUCCESS_LIST=/dev/null
+ resurrect $SPELL $current_version

exit 130
-
}


@@ -1575,12 +1554,18 @@ function set_compression_type() {

B) modify_local_config "COMPRESSBIN" "bzip2" &&
COMPRESSBIN="bzip2" &&
- modify_local_config "EXTENSION" ".bz2" ;;
+ modify_local_config "EXTENSION" ".bz2" &&
+ ARCHIVEBIN="tar" &&
+ modify_local_config "ARCHIVEBIN" "tar" ;;
G) modify_local_config "COMPRESSBIN" "gzip" &&
COMPRESSBIN="gzip" &&
- modify_local_config "EXTENSION" ".gz" ;;
- T) modify_local_config "COMPRESSBIN" "tar" &&
- COMPRESSBIN="tar" &&
+ modify_local_config "EXTENSION" ".gz" &&
+ ARCHIVEBIN="tar" &&
+ modify_local_config "ARCHIVEBIN" "tar" ;;
+ T) modify_local_config "ARCHIVEBIN" "tar" &&
+ ARCHIVEBIN="tar" &&
+ modify_local_config "COMPRESSBIN" "" &&
+ COMPRESSBIN="" &&
modify_local_config "EXTENSION" "" ;;

esac
diff --git a/var/lib/sorcery/modules/libtrack
b/var/lib/sorcery/modules/libtrack
index 5481ba2..c20fcd6 100755
--- a/var/lib/sorcery/modules/libtrack
+++ b/var/lib/sorcery/modules/libtrack
@@ -333,13 +333,61 @@ function check_if_modified() {
fi
}

+#---------------------------------------------------------------------
+## Constructs the to-be cache name depending on the ARCHIVEBIN
+## @param archive name
+## @param upvar
+#---------------------------------------------------------------------
+function construct_cache_name() {
+ local name=$1
+ if [[ -n $ARCHIVEBIN ]]; then
+ # just use the bin, currently there is no need for another extension
+ name="$name.$ARCHIVEBIN"
+ fi
+ upvar $2 "$name"
+}
+
+#---------------------------------------------------------------------
+## Given a filename, will return the actual filename if a similar
+## filename with a different extension exists. A more thorough version
+## of guess_filename used for finding caches
+## @param archive name (can be right trimmed, globbing will be done)
+## @param upvar (optional)
+#---------------------------------------------------------------------
+function find_cache() {
+ debug "libtrack" "$FUNCNAME $@"
+ local filename=$1
+ local real_name
+
+ if [[ -f $filename ]]; then
+ real_name=$filename
+ else
+ # use the first if more were found
+ local basename
+ smgl_basename "$filename" basename
+ read real_name < <(find $INSTALL_CACHE -type f -name "$basename*")
+ fi
+ [[ -z $real_name ]] && return 1
+ debug "libtrack" "$FUNCNAME found $real_name"
+
+ if [[ -z $2 ]]; then
+ echo $real_name
+ else
+ upvar $2 "$real_name"
+ fi
+ return 0
+}

#---------------------------------------------------------------------
##
## Creates a bzip/gzip'ed tar file containing an archived backup of
-## file specified on standard input into $CACHE_COMP
-## @stdin files, one per line, to put into the archive
-## @param directory input files are relative to install root for regular
files state root for state files
+## file specified on standard input into the target dir.
+##
+## Input files are relative to install root for regular files and
+## state root for state files
+## @param files, one per line, to put into the archive
+## @param archive name
+## @param compressed archive name
##
#---------------------------------------------------------------------
function create_cache_archive() {
@@ -361,20 +409,27 @@ function create_cache_archive() {
local TMP_MDATA=$TMP_DIR/foo.mdata
seperate_state_files $input $TMP_DATA $TMP_MDATA

- pushd $STATE_ROOT/ &>/dev/null
- install_log_filter $STATE_ROOT "." < $TMP_MDATA |
- tar --no-recursion -cPf "$CACHE" -T -
- popd &>/dev/null
-
- pushd $INSTALL_ROOT/ &>/dev/null
- install_log_filter $INSTALL_ROOT "." < $TMP_DATA |
- tar --no-recursion -rPf "$CACHE" -T -
+ case "$ARCHIVEBIN" in
+ tar)
+ pushd $STATE_ROOT/ &>/dev/null
+ install_log_filter $STATE_ROOT "." < $TMP_MDATA |
+ tar --no-recursion -cPf "$CACHE" -T -
+ popd &>/dev/null
+
+ pushd $INSTALL_ROOT/ &>/dev/null
+ install_log_filter $INSTALL_ROOT "." < $TMP_DATA |
+ tar --no-recursion -rPf "$CACHE" -T -
+ popd &>/dev/null
+ ;;
+ esac
rm $TMP_DATA $TMP_MDATA
- popd &>/dev/null
- if [ "$COMPRESSBIN" != "tar" ]; then
- $COMPRESSBIN -c $CACHE > $CACHE_COMP
- rm $CACHE
- fi
+
+ case "$COMPRESSBIN" in
+ gzip|bzip2)
+ $COMPRESSBIN -c $CACHE > $CACHE_COMP
+ rm $CACHE
+ ;;
+ esac
}

#---------------------------------------------------------------------
diff --git a/var/lib/sorcery/modules/libunpack
b/var/lib/sorcery/modules/libunpack
index d70e291..d945049 100755
--- a/var/lib/sorcery/modules/libunpack
+++ b/var/lib/sorcery/modules/libunpack
@@ -595,31 +595,50 @@ function unpack_missing() {

}

+#---------------------------------------------------------------------
+## @param file to unpack
+##
+## Given a cache file, runs the decompression and the unarchival
+## program on it. A wrapper around uncompress_unpack
+##
+#---------------------------------------------------------------------
+function uncompress_unpack_cache() {
+ uncompress_unpack "$1" root "cache" silent
+}

#---------------------------------------------------------------------
## @param file to unpack
+## @param (optional) dirname of the file (default: $SOURCE_CACHE)
+## 'root' if you already have an absolute path
+## @param (optional) type (default: source)
+## @param (optional) if 'silent' doesn't print the messages (default off)
##
## Given a file, runs the decompression program for that file, as well as
## untar'ing the file.
##
#---------------------------------------------------------------------
function uncompress_unpack() {
- debug "libgrimoire" "Running uncompress_unpack() on $1"
-
- FILENAME="$( guess_filename "$SOURCE_CACHE/$1" )" &&
- COMPRESSOR="$( guess_compressor "$FILENAME" )"
-
- message "${MESSAGE_COLOR}Unpacking source file ${SPELL_COLOR}${1}" \
- "${DEFAULT_COLOR}${MESSAGE_COLOR}for spell${SPELL_COLOR}" \
- "${SPELL}${DEFAULT_COLOR}${MESSAGE_COLOR}.${DEFAULT_COLOR}"
+ debug "libgrimoire" "Running uncompress_unpack() on $@"
+
+ local basedir
+ [[ $2 == root ]] || basedir=$SOURCE_CACHE
+ local filename=$(guess_filename "$basedir/$1") &&
+ local compressor=$(guess_compressor "$filename")
+ local type=${3:-source}
+
+ if [[ $4 != silent ]]; then
+ message "${MESSAGE_COLOR}Unpacking $type file ${SPELL_COLOR}${1}" \
+ "${DEFAULT_COLOR}${MESSAGE_COLOR}for spell${SPELL_COLOR}" \
+ "${SPELL}${DEFAULT_COLOR}${MESSAGE_COLOR}.${DEFAULT_COLOR}"
+ fi

- if [[ ! $FILENAME ]] || ! test -f "$FILENAME" ; then
- message "${PROBLEM_COLOR}Source file not found.${DEFAULT_COLOR}"
+ if [[ ! -f $filename ]]; then
+ error_message "$PROBLEM_COLOR$type file not found!$DEFAULT_COLOR"
return 1
fi

- uncompress_core "$FILENAME" "$COMPRESSOR" |
- unpack_core "$FILENAME" "$COMPRESSOR"
+ uncompress_core "$filename" "$compressor" |
+ unpack_core "$filename" "$compressor"
}

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



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

Archive powered by MHonArc 2.6.24.

Top of Page