Skip to Content.
Sympa Menu

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

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 (31bb04aacc82d575580ff364f88c2b0ac8c4f646)
  • Date: Fri, 10 Apr 2015 10:03:21 -0500

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

var/lib/sorcery/modules/libdepends | 96
+++++++++++--------------------------
1 file changed, 30 insertions(+), 66 deletions(-)

New commits:
commit 31bb04aacc82d575580ff364f88c2b0ac8c4f646
Author: Ismael Luceno <ismael AT sourcemage.org>
Commit: Ismael Luceno <ismael AT sourcemage.org>

libdepends: Unify parsing of installed dependencies in __comp_depends_aux

diff --git a/var/lib/sorcery/modules/libdepends
b/var/lib/sorcery/modules/libdepends
index 02d6b86..53737a5 100755
--- a/var/lib/sorcery/modules/libdepends
+++ b/var/lib/sorcery/modules/libdepends
@@ -281,37 +281,27 @@ function process_sub_depends() {

######################END CALLS TO OUTSIDE WORLD########################

-#---------------------------------------------------------------------
-## Create a map of spells to their dependent spells.
-## Then for all installed or held spells, output a libhash command to
-## join the spell name and dependency info.
-## Then evaluate the output, thus filling a libhash with dependency info.
-## @param Name of hash table to put dependencies
-#---------------------------------------------------------------------
-function compute_installed_depends() {
- #$1==hash table to fill
- local hash=$1
- touch $DEPENDS_STATUS $SPELL_STATUS &>/dev/null
-
- local pattern status
- if [[ $2 ]] ; then
- pattern="required|optional|runtime|suggest"
- else
- pattern="required|optional"
+function __comp_depends_aux() {
+ #$2==hash table to fill
+ local pattern="required|optional"
+ if [ "$3" ]; then
+ pattern="$pattern|runtime|suggest"
fi
- status=${3:-on}
-
- # From here forward $1 and $2 are only used to refer to awk variables
-
+ touch "$DEPENDS_STATUS" "$SPELL_STATUS" >/dev/null 2>&1
lock_file "$DEPENDS_STATUS"
lock_file "$SPELL_STATUS"
- # sub(/(.*)/, "", $2) removes a provider name
- awk -v pattern="$pattern" -v status="$status" -F : '
+ while read a b; do
+ hash_put "$2" "$a" "$b"
+ done < <(
+ awk -F: -v reverse="$1" -v pattern="$pattern" -v status="${4:-on}" '
FNR == 1 { file++ }
file == 1 {
- if ($3 == status && ($4 ~ pattern)) {
- sub(/\(.*\)/, "", $2);
- depmap[$1] = depmap[$1] " " $2 " "
+ if ($3 == status && $4 ~ pattern) {
+ # Remove provider name
+ sub(/[(].*/, "", $2)
+ if (reverse)
+ depmap[$2] = depmap[$2] " " $1 " "
+ else depmap[$1] = depmap[$1] " " $2 " "
}
next
}
@@ -319,10 +309,8 @@ function compute_installed_depends() {
if ($3 == "installed" || $3 == "held")
print $1, depmap[$1]
}
- ' "$DEPENDS_STATUS" "$SPELL_STATUS" |
- while read a b; do
- hash_put "$hash" "$a" "$b"
- done
+ ' "$DEPENDS_STATUS" "$SPELL_STATUS"
+ )
unlock_file "$DEPENDS_STATUS"
unlock_file "$SPELL_STATUS"
}
@@ -332,45 +320,21 @@ function compute_installed_depends() {
## Then for all installed or held spells, output a libhash command to
## join the spell name and dependency info.
## Then evaluate the output, thus filling a libhash with dependency info.
+## @param Name of hash table to put dependencies
+#---------------------------------------------------------------------
+function compute_installed_depends() {
+ __comp_depends_aux 0 "$@"
+}
+
+#---------------------------------------------------------------------
+## Create a map of spells to their dependent spells.
+## Then for all installed or held spells, output a libhash command to
+## join the spell name and dependency info.
+## Then evaluate the output, thus filling a libhash with dependency info.
## @param Name of hash table to fill with dependencies
#---------------------------------------------------------------------
function compute_reverse_installed_depends() {
- #$1==hash table to fill
- local hash=$1
- touch $DEPENDS_STATUS $SPELL_STATUS &>/dev/null
-
- local pattern status
- if [[ $2 ]] ; then
- pattern="required|optional|runtime|suggest"
- else
- pattern="required|optional"
- fi
- status=${3:-on}
-
- # From here forward $1 and $2 are only used to refer to awk variables
-
- lock_file "$DEPENDS_STATUS"
- lock_file "$SPELL_STATUS"
- # sub(/(.*)/, "", $2) removes a provider name
- awk -v pattern="$pattern" -v status="$status" -F : '
- FNR == 1 { file++ }
- file == 1 {
- if ($3 == status && ($4 ~ pattern)) {
- sub(/\(.*\)/, "", $2);
- depmap[$2] = depmap[$2] " " $1 " "
- }
- next
- }
- {
- if ($3 == "installed" || $3 == "held")
- print $1, depmap[$1]
- }
- ' "$DEPENDS_STATUS" "$SPELL_STATUS" |
- while read a b; do
- hash_put "$hash" "$a" "$b"
- done
- unlock_file "$DEPENDS_STATUS"
- unlock_file "$SPELL_STATUS"
+ __comp_depends_aux 1 "$@"
}

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



  • [SM-Commit] GIT changes to master sorcery by Ismael Luceno (31bb04aacc82d575580ff364f88c2b0ac8c4f646), Ismael Luceno, 04/10/2015

Archive powered by MHonArc 2.6.24.

Top of Page