Skip to Content.
Sympa Menu

sm-discuss - [SM-Discuss] [RFC v2] libdepends: Automagic sub-dependens implementation

sm-discuss AT lists.ibiblio.org

Subject: Public SourceMage Discussion List

List archive

Chronological Thread  
  • From: ismael.luceno AT gmail.com
  • To: sm-discuss AT lists.ibiblio.org
  • Subject: [SM-Discuss] [RFC v2] libdepends: Automagic sub-dependens implementation
  • Date: Fri, 5 Aug 2016 19:30:10 -0300

From: Ismael Luceno <ismael AT sourcemage.org>

Signed-off-by: Ismael Luceno <ismael AT sourcemage.org>
---
var/lib/sorcery/modules/libdepends | 12 ++++++++++++
var/lib/sorcery/modules/libstate | 13 +++++++++++++
2 files changed, 25 insertions(+)

diff --git a/var/lib/sorcery/modules/libdepends
b/var/lib/sorcery/modules/libdepends
index 53737a5baaa1..e6fd8c447fe0 100755
--- a/var/lib/sorcery/modules/libdepends
+++ b/var/lib/sorcery/modules/libdepends
@@ -262,6 +262,9 @@ function process_sub_depends() {
local THIS_SUB_DEPENDS=$sub_depends
local PROCESSED_SUB_DEPENDS
hash_get_ref processed_sub_depends $sub_dependee PROCESSED_SUB_DEPENDS
+ [[ ${sub_depends:0:1} == @ ]] &&
+ message "${MESSAGE_COLOR}Automagic sub-dependency" \
+ "@$SPELL_COLOR${sub_depends:1}$MESSAGE_COLOR
requested.$DEFAULT_COLOR"
run_spell_file SUB_DEPENDS sub_depends || return 1
hash_append processed_sub_depends $sub_dependee $sub_depends
else
@@ -1463,6 +1466,15 @@ function real_sub_depends() {
if ! tablet_set_spell $sub_dependee ; then
codex_set_current_spell_by_name $sub_dependee || return 1
fi
+ # Automagic sub-depends
+ if [[ ${sub_depends:0:1} == @ ]] &&
+ is_dependency "$sub_dependee" "${sub_depends:1}"
+ then
+ message "${MESSAGE_COLOR}Automagic sub-dependency" \
+ "@$SPELL_COLOR${sub_depends:1}$MESSAGE_COLOR
found.$DEFAULT_COLOR"
+ is_depends_enabled "$sub_dependee" "${sub_depends:1}"
+ return
+ fi
run_spell_file PRE_SUB_DEPENDS pre_sub_depends
rc=$?
return $rc
diff --git a/var/lib/sorcery/modules/libstate
b/var/lib/sorcery/modules/libstate
index 2f3f94aa3fe5..a5f320613127 100755
--- a/var/lib/sorcery/modules/libstate
+++ b/var/lib/sorcery/modules/libstate
@@ -833,6 +833,19 @@ function real_is_depends_enabled() {
[[ -n $(search_depends_status_simple $dep_status "$1" "$2" 'on' ) ]]
}

+#---------------------------------------------------------------------
+## @param Spell name
+## @param Target spell name
+##
+## @return 0 if a dependency from $1 on $2 exists, 1 otherwise.
+#---------------------------------------------------------------------
+function is_dependency() {
+ local dep_status
+ hash_get_ref uncommitted_hash $1 dep_status
+ [[ $dep_status ]] || dep_status=$DEPENDS_STATUS
+ [[ $(search_depends_status_simple $dep_status "$1" "$2") ]]
+}
+

#---------------------------------------------------------------------
## @param spell name
--
2.9.2





Archive powered by MHonArc 2.6.24.

Top of Page