Skip to Content.
Sympa Menu

sm-commit - [SM-Commit] GIT changes to master sorcery by Ismael Luceno (48a558e751395415d89a800d729491788e781678)

sm-commit AT lists.ibiblio.org

Subject: Source Mage code commit list

List archive

Chronological Thread  
  • From: Ismael Luceno <scm AT sourcemage.org>
  • To: sm-commit AT lists.ibiblio.org
  • Subject: [SM-Commit] GIT changes to master sorcery by Ismael Luceno (48a558e751395415d89a800d729491788e781678)
  • Date: Fri, 8 Feb 2019 22:04:57 +0000

GIT changes to master sorcery by Ismael Luceno <ismael AT sourcemage.org>:

usr/sbin/gaze | 9 ---
var/lib/sorcery/modules/libcodex | 4 -
var/lib/sorcery/modules/libdownload | 4 -
var/lib/sorcery/modules/libgpg | 5 --
var/lib/sorcery/modules/libgrimoire | 4 -
var/lib/sorcery/modules/liblock | 4 -
var/lib/sorcery/modules/libmisc | 20 +++-----
var/lib/sorcery/modules/libqueue | 12 ++--
var/lib/sorcery/modules/libscreen | 5 --
var/lib/sorcery/modules/libsecurity | 8 +--
var/lib/sorcery/modules/libspell | 88
+++++++++++++-----------------------
var/lib/sorcery/modules/libsummon | 2
var/lib/sorcery/modules/libtablet | 4 -
var/lib/sorcery/modules/libtime | 4 -
var/lib/sorcery/modules/libtrack | 5 --
15 files changed, 71 insertions(+), 107 deletions(-)

New commits:
commit 48a558e751395415d89a800d729491788e781678
Author: Ismael Luceno <ismael AT sourcemage.org>
Commit: Ismael Luceno <ismael AT sourcemage.org>

Remove redundant "$" in arithmetic expressions

commit b2680f032a798e51262ab66573c5222acda6c457
Author: Ismael Luceno <ismael AT sourcemage.org>
Commit: Ismael Luceno <ismael AT sourcemage.org>

Reduce usage of smgl_which

commit d5eeb6dd77d927cc06582f400449ec718bd3cf2e
Author: Ismael Luceno <ismael AT sourcemage.org>
Commit: Ismael Luceno <ismael AT sourcemage.org>

libspell: Simplify load_spell_file_functions

commit 9f5758910d53ba3343b0e359a3d53cd67be49e50
Author: Ismael Luceno <ismael AT sourcemage.org>
Commit: Ismael Luceno <ismael AT sourcemage.org>

libmisc: Fix backtick subtitution

Bug introduced by 62934684669a30412d1a5d705bca614f0febeb01

diff --git a/usr/sbin/gaze b/usr/sbin/gaze
index 43446ba..e980b5c 100755
--- a/usr/sbin/gaze
+++ b/usr/sbin/gaze
@@ -551,7 +551,7 @@ gaze_catalog_html() {
iii="${ii}_URL"
echo "<br />"
echo "<a href=\"${!iii}\">$(echo ${!ii} | cut -c-25)</a>"
- i=$(($i+1))
+ ((i++))
ii=SOURCE${i}
done
echo "</td>"
@@ -1695,11 +1695,6 @@ gaze_show_dependencies() {


[[ $MAX_DEPTH ]] && [[ $DEPTH -ge $MAX_DEPTH ]] && return 1
- grep() {
- local foo
- smgl_which grep foo &&
- $foo "$@"
- }
[[ $FOUND ]] &&
grep -q '^'$name'$' $FOUND &&
found_before=" (see above for tree)"
@@ -2259,7 +2254,7 @@ gaze_time() {
continue
fi
if [[ ${diff% *} == $diff ]]; then
- (( sum += $diff ))
+ (( sum += diff ))
else
(( sum += ${diff% *}, n++ )) # we'll count the error separately
err_sum[n]=${diff#* }
diff --git a/var/lib/sorcery/modules/libcodex
b/var/lib/sorcery/modules/libcodex
index c0d8840..5bf07fd 100755
--- a/var/lib/sorcery/modules/libcodex
+++ b/var/lib/sorcery/modules/libcodex
@@ -241,7 +241,7 @@ codex_add_grimoire() {
touch $GRIMOIRE_LIST
lock_start_transaction "$GRIMOIRE_LIST" tGRIMOIRE_LIST
rm $tGRIMOIRE_LIST
- for ((i=0; i<$GRIMOIRE_COUNT;i++)); do
+ for ((i = 0; i < GRIMOIRE_COUNT; i++)); do
echo GRIMOIRE_DIR[$i]=${GRIMOIRE_DIR[$i]} >> $tGRIMOIRE_LIST
done
lock_commit_transaction $GRIMOIRE_LIST
@@ -345,7 +345,7 @@ codex_set_grimoires() {
done
unset GRIMOIRE_DIR
let GRIMOIRE_COUNT--
- for ((; $GRIMOIRE_COUNT>=0;GRIMOIRE_COUNT--)) ; do
+ for ((; GRIMOIRE_COUNT>=0;GRIMOIRE_COUNT--)) ; do
GRIMOIRE_DIR[$GRIMOIRE_COUNT]=${NEW_GRIMOIRE_DIR[$GRIMOIRE_COUNT]}
done
}
diff --git a/var/lib/sorcery/modules/libdownload
b/var/lib/sorcery/modules/libdownload
index b4b4f07..333d28f 100755
--- a/var/lib/sorcery/modules/libdownload
+++ b/var/lib/sorcery/modules/libdownload
@@ -93,9 +93,7 @@ dl_get_bucket() {
}

dl_command_check() {
- local cmd
- smgl_which $1 cmd
- if ! [[ $cmd ]] || ! test -x $cmd ; then
+ if type "$1" >/dev/null 2>&1; then
message "${PROBLEM_COLOR}${cmd:-$1} is not installed, please cast it..."
\
"${DEFAULT_COLOR}"
return 1
diff --git a/var/lib/sorcery/modules/libgpg b/var/lib/sorcery/modules/libgpg
index aecf3b6..db20c68 100755
--- a/var/lib/sorcery/modules/libgpg
+++ b/var/lib/sorcery/modules/libgpg
@@ -41,10 +41,7 @@ gpg_verify_signature() { # $1 sig $2 file $3 pubring $4
algo var
# always trust and supply our own keyring.
# We provide our own trust for the pubkey validity.

- local GPGPROG
- smgl_which gpg GPGPROG 2> /dev/null
-
- if test -z "$GPGPROG" ; then
+ if type gpg >/dev/null 2>&1; then
message "It appears you do not have gpg (gnupg) in your PATH."
message "${QUERY_COLOR}For full source verification, it is highly" \
"suggested that you cast gnupg\nas soon as possible. This" \
diff --git a/var/lib/sorcery/modules/libgrimoire
b/var/lib/sorcery/modules/libgrimoire
index 01b51f0..bc69995 100755
--- a/var/lib/sorcery/modules/libgrimoire
+++ b/var/lib/sorcery/modules/libgrimoire
@@ -132,9 +132,9 @@ make() {


if [[ "$USE_DISTCC" == on ]] ; then
- let JOBS=$(($make_njobs+$jobs_per_host*$num_hosts))
+ JOBS=$((make_njobs+jobs_per_host*num_hosts))
else
- let JOBS=$make_njobs
+ JOBS=$make_njobs
fi

if [[ $JOBS == 0 ]]; then
diff --git a/var/lib/sorcery/modules/liblock b/var/lib/sorcery/modules/liblock
index 4259fed..22dc02c 100755
--- a/var/lib/sorcery/modules/liblock
+++ b/var/lib/sorcery/modules/liblock
@@ -50,7 +50,7 @@ lock_resources()

while ! trylock_resources "$@";
do
- local SLEEP=$(( ${RANDOM} % ${MAX_SLEEP} ))
+ local SLEEP=$(( RANDOM % MAX_SLEEP ))
debug "lock_resources" "process $$ is sleeping ${SLEEP} seconds"
sleep "${SLEEP}"
done
@@ -112,7 +112,7 @@ excllock_resources()
do
#^^^ look if a lock exists of the given type (ugly code)
global_clean_resources
- local SLEEP=$(( ${RANDOM} % ${MAX_SLEEP} ))
+ local SLEEP=$(( RANDOM % MAX_SLEEP ))
sleep "$SLEEP"
done
#theoretically, someone could create a lock now... tiny race
diff --git a/var/lib/sorcery/modules/libmisc b/var/lib/sorcery/modules/libmisc
index 572a2d8..bdd1fa7 100755
--- a/var/lib/sorcery/modules/libmisc
+++ b/var/lib/sorcery/modules/libmisc
@@ -296,8 +296,8 @@ debug "libmisc" "progress_bar - $*"
LAST_PERCENT=$percent


- dash_len=$(($len-8))
- num_dash=$(( $dash_len*$1/$2 ))
+ dash_len=$((len - 8))
+ num_dash=$((dash_len * $1 / $2 ))

#Format: [---> ] 100%

@@ -305,7 +305,7 @@ debug "libmisc" "progress_bar - $*"
BAR_STRING="["

#The '=' signs
- for (( i=0 ; i<$num_dash ; i++ )) ; do
+ for (( i = 0 ; i < num_dash ; i++ )) ; do
BAR_STRING="${BAR_STRING}="
done

@@ -313,7 +313,7 @@ debug "libmisc" "progress_bar - $*"
[ $num_dash -lt $((dash_len-1)) ] && BAR_STRING="${BAR_STRING}>"

#Fill the rest of the bar up with blanks
- for (( i++ ; i<$dash_len-1 ; i++ )) ; do
+ for (( i++ ; i < dash_len - 1 ; i++ )) ; do
BAR_STRING="${BAR_STRING} "
done

@@ -321,7 +321,7 @@ debug "libmisc" "progress_bar - $*"
BAR_STRING="${BAR_STRING}] ${percent}%"

#Clear the rest of the space
- for (( i+=3+${#percent} ; i<$len ; i++ )) ; do
+ for (( i += 3 + ${#percent} ; i < len ; i++ )) ; do
BAR_STRING="${BAR_STRING} "
done

@@ -736,7 +736,7 @@ real_list_remove() {
-e \"s/[\t\v\f\r ]\\+/ /g\" \
-e \"s/ $i / /g\" \
-e \"s/^ *//\" \
- -e \"s/ *$//\"\)"
+ -e \"s/ *$//\")"
done
}

@@ -762,7 +762,7 @@ real_list_add() {
}
iterate list_add_sub " " "$(eval "echo \$$var")"
if [ $found -eq 0 ]; then
- eval "$var=\$(echo \"\$$var $i\"\)"
+ eval "$var=\$(echo \"\$$var $i\")"
eval "$var=\"\${$var/# /}\""
fi
done
@@ -1346,12 +1346,10 @@ smgl_which() {
#---------------------------------------------------------------------
find_make() {
local ___REAL_MAKE
- smgl_which make ___REAL_MAKE
- rc=$?
- if [[ $rc != 0 ]] ; then
+ if smgl_which make ___REAL_MAKE; then
message "Cannot find make command!!"
message "Bailing out"
- return $rc
+ return 1
fi
eval "$1=$___REAL_MAKE"
}
diff --git a/var/lib/sorcery/modules/libqueue
b/var/lib/sorcery/modules/libqueue
index 3395c5c..612b7ea 100755
--- a/var/lib/sorcery/modules/libqueue
+++ b/var/lib/sorcery/modules/libqueue
@@ -75,11 +75,11 @@ update_security_install_queue() {
if codex_set_current_spell_by_name $spell &&
tablet_find_spell_dir $spell page_dir; then
tablet_get_security_patch $page_dir curr_sec_patch &&
- diff=$(( ${SECURITY_PATCH:-0} - $curr_sec_patch ))
- if (( $diff > 0 )); then
+ diff=$(( SECURITY_PATCH - curr_sec_patch ))
+ if (( diff > 0 )); then
echo $spell >> $tmp_queue
clear_line
- if (( $diff > 1 )); then
+ if (( diff > 1 )); then
message "$SPELL_COLOR$spell$DEFAULT_COLOR: Security update
($diff times!)."
else
message "$SPELL_COLOR$spell$DEFAULT_COLOR: Security update."
@@ -262,9 +262,9 @@ does_spell_need_update_slow() {
tablet_get_security_patch $page_dir curr_sec_patch
fi

- local diff=$(( ${SECURITY_PATCH:-0} - $curr_sec_patch ))
- if (( $diff > 0 )); then
- if (( $diff > 1 )); then
+ local diff=$(( SECURITY_PATCH - curr_sec_patch ))
+ if (( diff > 0 )); then
+ if (( diff > 1 )); then
message="$message Security update ($diff times!)."
else
message="$message Security update."
diff --git a/var/lib/sorcery/modules/libscreen
b/var/lib/sorcery/modules/libscreen
index bc5a8ec..7dbb47b 100755
--- a/var/lib/sorcery/modules/libscreen
+++ b/var/lib/sorcery/modules/libscreen
@@ -21,14 +21,13 @@ screen_quick_intro() {
screen_start() {
$STD_DEBUG
local name="$1"
- local screen
shift
- if ! smgl_which screen screen > /dev/null ; then
+ if ! type screen >/dev/null 2>&1; then
message "Cannot find screen."
message "Consider fixing the PATH, or disabling screen mode and casting
screen."
exit 1
fi
- exec $screen -S "$name" $SCREEN_KEY -c $SCREENRC "$@"
+ exec screen -S "$name" "$SCREEN_KEY" -c "$SCREENRC" "$@"
}

#-----
diff --git a/var/lib/sorcery/modules/libsecurity
b/var/lib/sorcery/modules/libsecurity
index e267114..628172c 100755
--- a/var/lib/sorcery/modules/libsecurity
+++ b/var/lib/sorcery/modules/libsecurity
@@ -30,7 +30,7 @@ gaze_checkmd5() {
SOURCE=${!SOURCEvar}
if [ -n "$SOURCEnum" ]
then
- MD5num="$(($SOURCEnum-1))"
+ MD5num="$((SOURCEnum - 1))"
else
MD5num="0"
fi
@@ -252,9 +252,9 @@ gaze_checkmd5s() {

fi
unset $jj
- unset MD5[$(($j-1))] 2> /dev/null
- unset LICENSE[$(($j-1))] 2> /dev/null
- j=$(($j+1))
+ unset MD5[$((j - 1))] 2> /dev/null
+ unset LICENSE[$((j - 1))] 2> /dev/null
+ ((j++))
jj=SOURCE$j
done
unset VERSION
diff --git a/var/lib/sorcery/modules/libspell
b/var/lib/sorcery/modules/libspell
index 4de495b..de8feab 100755
--- a/var/lib/sorcery/modules/libspell
+++ b/var/lib/sorcery/modules/libspell
@@ -20,57 +20,33 @@
## the proper context. This is merely a safety valve.
#---------------------------------------------------------------------
load_spell_file_functions() {
- for each in $(
- cat << EOF
-PREPARE:prepare
-CONFIGURE:configure
-DEPENDS:depends
-
-PRE_SUB_DEPENDS:pre_sub_depends
-SUB_DEPENDS:sub_depends
-
-CONFLICTS:conflicts
-
-PRE_BUILD:pre_build
-BUILD:build
-PRE_INSTALL:pre_install
-INSTALL:install
-POST_BUILD:post_build
-INSTALL_EXTRAS:install_extras
-POST_INSTALL:post_install
-TRANSFER:transfer
-FINAL:final
-
-UP_TRIGGERS:up_triggers
-TRIGGERS:triggers
-TRIGGER_CHECK:trigger_check
-
-DOWNLOAD:download
-
-PRE_REMOVE:pre_remove
-POST_REMOVE:post_remove
-
-PRE_RESURRECT:pre_resurrect
-POST_RESURRECT:post_resurrect
-EOF
-); do
- local NAME=${each%:*}
- local name=${each#*:}
+ for name in \
+ prepare configure depends \
+ pre_sub_depends sub_depends \
+ conflicts \
+ pre_build build pre_install install post_build install_extras \
+ post_install transfer final \
+ up_triggers triggers trigger_check \
+ download \
+ pre_remove post_remove \
+ pre_resurrect post_resurrect
+ do

# Create the four libapi entry points for each file
- eval "function default_${name}() {
- real_default_${name}
- }"
- eval "function default_section_${name}() {
- real_default_section_${name}
- }"
- eval "function default_grimoire_${name}() {
- real_default_grimoire_${name}
- }"
- eval "function default_sorcery_${name}() {
- real_default_sorcery_${name}
- }"
-
+ eval "
+ function default_${name}() {
+ real_default_${name}
+ }
+ function default_section_${name}() {
+ real_default_section_${name}
+ }
+ function default_grimoire_${name}() {
+ real_default_grimoire_${name}
+ }
+ function default_sorcery_${name}() {
+ real_default_sorcery_${name}
+ }
+ "

# real_default_<file> always refers to the level above in the hierarchy.
# (section, grimoire or sorcery).
@@ -82,12 +58,14 @@ EOF
# These two functions run the section/grimoire function and update
# the real_default_<file> function. Ignore this generic declaration,
# it is changed at runtime to private_default_<section|grimoire>_generic.
- eval "function real_default_section_${name}() {
- false
- }"
- eval "function real_default_grimoire_${name}() {
- false
- }"
+ eval "
+ function real_default_section_${name}() {
+ false
+ }
+ function real_default_grimoire_${name}() {
+ false
+ }
+ "

# If there isnt a sorcery default function, declare one as "true".
# Note that, the right thing happens regardless of what order lib files
diff --git a/var/lib/sorcery/modules/libsummon
b/var/lib/sorcery/modules/libsummon
index 3244c3e..69a940d 100755
--- a/var/lib/sorcery/modules/libsummon
+++ b/var/lib/sorcery/modules/libsummon
@@ -367,7 +367,7 @@ download_from_fallback() {
local i idx
local FALL_BACKS
local offset=$[${RANDOM} % $FURLNUM]
- for (( i=0; $i < $FURLNUM; i++ )); do
+ for (( i = 0; i < FURLNUM; i++ )); do
idx=$[($i + $offset) % $FURLNUM]
FALL_BACKS="$FALL_BACKS ${FALLBACK_URL_MIRROR[$idx]}/$target"
done
diff --git a/var/lib/sorcery/modules/libtablet
b/var/lib/sorcery/modules/libtablet
index e54d538..b531646 100755
--- a/var/lib/sorcery/modules/libtablet
+++ b/var/lib/sorcery/modules/libtablet
@@ -388,7 +388,7 @@ tablet_get_path() {
local made

mkdir -p $TABLET_PATH/$SPELL &&
- for (( i=0 ; $i < 20 ; i++ )) ; do
+ for (( i=0 ; i < 20 ; i++ )) ; do
if mkdir $tb_dir > /dev/null; then
made=1
break
@@ -897,7 +897,7 @@ tablet_fix_duplicates() {
return
fi

- for ((i=0;$i<${#tablets[*]}; i++ )) ; do
+ for ((i = 0; i < ${#tablets[*]}; i++ )) ; do
message "Inspecting ${tablets[$i]}"
tablet_is_spell_version_installed $spell ${tablets[$i]} &&
tablet_does_tablet_point_to_itself ${tablets[$i]} ||
diff --git a/var/lib/sorcery/modules/libtime b/var/lib/sorcery/modules/libtime
index 2ffe40e..50755b4 100755
--- a/var/lib/sorcery/modules/libtime
+++ b/var/lib/sorcery/modules/libtime
@@ -171,7 +171,7 @@ compute_weighted_mean() {
if [[ $type == last-cast ]]; then
local weight=10 #make this relative someday?
local i command
- for ((i=1; i < $weight; i++)); do
+ for ((i = 1; i < weight; i++)); do
command="p; $command"
done
{
@@ -284,7 +284,7 @@ pretty_print_time_sub() {
pretty_print_time_error() {
local error=$1

- if (( $error < 60 )); then
+ if (( error < 60 )); then
error=0
else
error=$(pretty_print_time_sub $error)
diff --git a/var/lib/sorcery/modules/libtrack
b/var/lib/sorcery/modules/libtrack
index 6ddf2e2..3460f42 100755
--- a/var/lib/sorcery/modules/libtrack
+++ b/var/lib/sorcery/modules/libtrack
@@ -178,13 +178,12 @@ real_devoke_installwatch() {

is_castfs_installed()
{
- local loc
- if smgl_which castfs loc >/dev/null 2>&1 &&
+ if type castfs >/dev/null 2>&1 &&
(
modprobe fuse > /dev/null 2>&1 ||
grep -q '^nodev[\t\v\f\r ]*fuse$' /proc/filesystems
) &&
- [[ -c /dev/fuse ]]
+ [ -c /dev/fuse ]
then
message "${MESSAGE_COLOR}Staging enabled${DEFAULT_COLOR}"
return 0



  • [SM-Commit] GIT changes to master sorcery by Ismael Luceno (48a558e751395415d89a800d729491788e781678), Ismael Luceno, 02/08/2019

Archive powered by MHonArc 2.6.24.

Top of Page