New commits:
commit ad1fca2d26c4dde52480f5521436ad8813f53813
Author: Jaka Kranjc <lynxlynxlynx AT sourcemage.org>
Commit: Jaka Kranjc <lynxlynxlynx AT sourcemage.org>
*: use lock_start_transaction by reference
commit be460da010d3426e454c99aad6f6bf559ff689e8
Author: Jaka Kranjc <lynxlynxlynx AT sourcemage.org>
Commit: Jaka Kranjc <lynxlynxlynx AT sourcemage.org>
readded a local variable to store the transaction file name
commit 7a5d50e47a791e2e072d4109b4490f4cdf4e6fab
Author: Jaka Kranjc <lynxlynxlynx AT sourcemage.org>
Commit: Jaka Kranjc <lynxlynxlynx AT sourcemage.org>
liblock: lock_start_transaction now supports returning by reference
diff --git a/ChangeLog b/ChangeLog
index f6d7759..63592f0 100644
--- a/ChangeLog
+++ b/ChangeLog
@@ -1,3 +1,8 @@
+2008-01-18 Jaka Kranjc <lynxlynxlynx AT sourcemage.org>
+ * liblock: lock_start_transaction now supports returning by reference
+ readded a local variable to store the transaction file name
+ * *: use lock_start_transaction by reference
+
2008-01-16 Jaka Kranjc <lynxlynxlynx AT sourcemage.org>
* libdepends: added more locking calls #7917
* libgrimoire: 100% speedup of private_installed_version;
unfortunately
diff --git a/usr/sbin/cast b/usr/sbin/cast
index 59853dc..0967270 100755
--- a/usr/sbin/cast
+++ b/usr/sbin/cast
@@ -778,7 +778,8 @@ function main() {
if [[ "$CAST_QUEUE" == yes ]] ; then
touch "$INSTALL_QUEUE"
- local tfile=$(lock_start_transaction "$INSTALL_QUEUE")
+ local tfile
+ lock_start_transaction "$INSTALL_QUEUE" tfile
grep -Ev '^$' $INSTALL_QUEUE > $tfile
lock_commit_transaction "$INSTALL_QUEUE"
if [ -s $INSTALL_QUEUE ]; then
diff --git a/usr/sbin/cleanse b/usr/sbin/cleanse
index 548e105..cf151fb 100755
--- a/usr/sbin/cleanse
+++ b/usr/sbin/cleanse
@@ -983,12 +983,12 @@ function cleanse_fix_md5sum_check() {
# the wrong place a future improvement would be
# to use iterate or some other method that is not naive to
# filenames with spaces in them
- tfile=`lock_start_transaction $INSTALL_LOG`
+ lock_start_transaction "$INSTALL_LOG" tfile
sed "s${A}^$LINE\$${A}${A}" $INSTALL_LOG|tr -s '\n' > $tfile
lock_commit_transaction $INSTALL_LOG
message -n '.'
diff --git a/var/lib/sorcery/modules/libdepends
b/var/lib/sorcery/modules/libdepends
index 9da13d4..da7ea0b 100755
--- a/var/lib/sorcery/modules/libdepends
+++ b/var/lib/sorcery/modules/libdepends
@@ -463,11 +463,12 @@ function private_run_depends()
get_uncommitted_depends_file $SPELL spell_depends
spell_sub_depends=$spell_depends.sub
if [ -n "$RECONFIGURE" ]; then
+ local t_spell_p t_abandonded_p
rm -f $DEPENDS_CONFIG/$SPELL
test -f $DEPENDS_CONFIG/$SPELL.p &&
mkdir -p $ABANDONED_PERSIST &&
- local t_spell_p=$(lock_start_transaction "$DEPENDS_CONFIG/$SPELL.p") &&
- local t_abandonded_p=$(lock_start_transaction
"$ABANDONED_PERSIST/$SPELL.p") &&
+ lock_start_transaction "$DEPENDS_CONFIG/$SPELL.p" t_spell_p &&
+ lock_start_transaction "$ABANDONED_PERSIST/$SPELL.p" t_abandonded_p &&
mv -f "$t_spell_p" "$t_abandonded_p" &&
lock_commit_transaction "$DEPENDS_CONFIG/$SPELL.p" &&
lock_commit_transaction "$ABANDONED_PERSIST/$SPELL.p"
diff --git a/var/lib/sorcery/modules/libdispel
b/var/lib/sorcery/modules/libdispel
index 0a9c1e5..d0f5395 100755
--- a/var/lib/sorcery/modules/libdispel
+++ b/var/lib/sorcery/modules/libdispel
@@ -81,7 +81,8 @@ function reap_depends() {
# save the old depends data as abandoned stuff so its seen later on
# recasts as the default
mkdir -p $ABANDONED_DEPENDS
- local t_file=$(lock_start_transaction "$ABANDONED_DEPENDS/$SPELL")
+ local t_file
+ lock_start_transaction "$ABANDONED_DEPENDS/$SPELL" t_file
search_depends_status $DEPENDS_STATUS $SPELL > $t_file
lock_commit_transaction "$ABANDONED_DEPENDS/$SPELL"
diff --git a/var/lib/sorcery/modules/liblock b/var/lib/sorcery/modules/liblock
index 3ed8767..cac21fb 100755
--- a/var/lib/sorcery/modules/liblock
+++ b/var/lib/sorcery/modules/liblock
@@ -232,6 +232,7 @@ function unlock_file()
#---------------------------------------------------------------------
## @param File to start transaction on
## @param <file> ... (optional)
+## @param variable to set (optional)
##
## A transaction locks a file and ensures that changes made to the
## file are all made at once. No changes are made to the file until
@@ -248,7 +249,7 @@ function unlock_file()
function lock_start_transaction()
{
debug "liblock" "$FUNCNAME - $*"
- local NUMTRANS file="$1"
+ local NUMTRANS transaction_file file="$1"
if lock_file "$file" ; then
@@ -259,16 +260,21 @@ function lock_start_transaction()
NUMTRANS=${NUMTRANS:-1} # TODO: check if this should fallback to 0
let NUMTRANS++
+ transaction_file="$LOCK_TRANSACTIONS.$NUMTRANS"
# cp file to temp file or if doesn't exist, create an empty file.
if [[ -e $file ]]; then
- cp "$file" "$LOCK_TRANSACTIONS.$NUMTRANS"
+ cp "$file" "$transaction_file"
else
- echo -n "" > $LOCK_TRANSACTIONS.$NUMTRANS
+ echo -n "" > "$transaction_file"
fi
echo "$NUMTRANS:$file:$$" >$LOCK_TRANSACTIONS
unlock_file $LOCK_TRANSACTIONS
- echo "$LOCK_TRANSACTIONS.$NUMTRANS"
+ if [[ $2 ]]; then
+ eval "$2=\"\$transaction_file\""
+ else
+ echo "$transaction_file"
+ fi
return 0
else
@@ -377,7 +383,8 @@ function counter_down() {
counterfile="${LOCK_DIR}/${counterfile//\//^}"
touch $counterfile
- local tc=$(lock_start_transaction $counterfile)
+ local tc
+ lock_start_transaction "$counterfile" tc
for each in $(counter_clean $tc); do
[[ $foo ]] && echo $each && continue
if [[ $each == $$ ]] ; then foo=found ; else echo $each; fi
@@ -417,7 +424,8 @@ function counter_check() {
# we replace / with ^
counterfile="${LOCK_DIR}/${counterfile//\//^}"
if test -f $counterfile ; then
- local tc=$(lock_start_transaction $counterfile)
+ local tc
+ lock_start_transaction "$counterfile" tc
# sort saves a temp file since it has to read all the input
counter_clean $tc |sort > $tc
lock_commit_transaction $counterfile
diff --git a/var/lib/sorcery/modules/libmisc b/var/lib/sorcery/modules/libmisc
index a7450b7..82d3390 100755
--- a/var/lib/sorcery/modules/libmisc
+++ b/var/lib/sorcery/modules/libmisc
@@ -731,7 +731,8 @@ function real_persistent_save () {
local VAR
local TMP
local file=$SPELL_CONFIG.p
- local tfile=$(lock_start_transaction $file)
+ local tfile
+ lock_start_transaction "$file" tfile
> "$tfile"
for VAR in $PERSISTENT_VARIABLES; do
config_get_option $VAR TMP
diff --git a/var/lib/sorcery/modules/libresurrect
b/var/lib/sorcery/modules/libresurrect
index b701923..72d6212 100755
--- a/var/lib/sorcery/modules/libresurrect
+++ b/var/lib/sorcery/modules/libresurrect
@@ -575,7 +575,8 @@ function resurrect_success() {
# none of the old values are valid, only the new, uncommitted values are
remove_depends_status $DEPENDS_STATUS $SPELL
local spell_depends=$OLD_TABLET_DIR/depends
- local t_DEPENDS_STATUS=$(lock_start_transaction "$DEPENDS_STATUS")
+ local t_DEPENDS_STATUS
+ lock_start_transaction "$DEPENDS_STATUS" t_DEPENDS_STATUS
if [ -e $spell_depends ] ; then
cat $spell_depends >> $t_DEPENDS_STATUS
fi
diff --git a/var/lib/sorcery/modules/libsorcery
b/var/lib/sorcery/modules/libsorcery
index c4423f1..73c886a 100755
--- a/var/lib/sorcery/modules/libsorcery
+++ b/var/lib/sorcery/modules/libsorcery
@@ -659,7 +659,7 @@ function pop_queue() { (
local ITEM=`esc_str $2`
local exit_code=0
- tQUEUE_FILE=$( lock_start_transaction $1 )
+ lock_start_transaction "$1" tQUEUE_FILE
if ! [ -f "$1" ]; then
exit_code=1
elif [ -n "$ITEM" ]; then
@@ -709,7 +709,8 @@ function pop_install_queue() {
function push_queue() {
pop_queue "$1" "$2"
- local t_file=$(lock_start_transaction "$1")
+ local t_file
+ lock_start_transaction "$1" t_file
echo "$2" >> "$t_file";
lock_commit_transaction "$1"
@@ -1028,7 +1029,8 @@ function install_queue_history() {
get_new_changes "Viewing history since last update ($datedash) for spell
-- ${spell} -- :" "$date" "$(codex_find_spell_by_name $spell)/HISTORY"
if query "Would you like to ${RED}remove ${QUERY_COLOR}spell
$SPELL_COLOR$spell$QUERY_COLOR from the install queue?" n; then
- local t_queue=$(lock_start_transaction "$INSTALL_QUEUE")
+ local t_queue
+ lock_start_transaction "$INSTALL_QUEUE" t_queue
sedit "s/^$spell$//" "$t_queue"
lock_commit_transaction "$INSTALL_QUEUE"
echo -e "${QUERY_COLOR} The spell ${SPELL_COLOR} $spell ${QUERY_COLOR}
removed from $INSTALL_QUEUE.${DEFAULT_COLOR}"
diff --git a/var/lib/sorcery/modules/libstate
b/var/lib/sorcery/modules/libstate
index 5e7d7ef..9b3160d 100755
--- a/var/lib/sorcery/modules/libstate
+++ b/var/lib/sorcery/modules/libstate
@@ -45,7 +45,8 @@ function add_depends()
return 1
fi
- local t_status=$(lock_start_transaction "$depends_status")
+ local t_status
+ lock_start_transaction "$depends_status" t_status
echo "$1:$2:$3:$4:$5:$6" >> "$t_status"
lock_commit_transaction "$depends_status"
@@ -783,7 +788,8 @@ function all_spell_status()
##
#---------------------------------------------------------------------
function set_held () {
- local t_status=$(lock_start_transaction $SPELL_STATUS)
+ local t_status
+ lock_start_transaction "$SPELL_STATUS" t_status
for to_hold in $@; do
sedit 's/\(^'$(esc_str $to_hold)':[^:]*:\)installed/\1held/'
$t_status
done
@@ -857,7 +863,8 @@ function set_unexiled () {
##
#---------------------------------------------------------------------
function set_unheld () {
- local t_status=$(lock_start_transaction $SPELL_STATUS)
+ local t_status
+ lock_start_transaction "$SPELL_STATUS" t_status
for to_hold in $@; do
sedit 's/\(^'$(esc_str $to_hold)':[^:]*:\)held/\1installed/'
$t_status
done
@@ -939,7 +946,7 @@ function modify_config() {
fi