|
|
@ -1370,13 +1370,16 @@ get_service_deps() { |
|
|
|
} |
|
|
|
export -f get_service_deps |
|
|
|
|
|
|
|
|
|
|
|
## XXXvlab: cache was disabled because improper. Indeed, this needs to cache |
|
|
|
## 'depths' full state. Second, it should be |
|
|
|
_rec_get_depth() { |
|
|
|
local elt=$1 dep deps max cache_file="$state_tmpdir/$FUNCNAME.cache.$1" |
|
|
|
local elt=$1 dep deps max cache_file="$state_tmpdir/$FUNCNAME.cache.$1.$(declare -pA depths | md5_compat)" |
|
|
|
[ "${depths[$elt]}" ] && return 0 |
|
|
|
if [ -e "$cache_file" ]; then |
|
|
|
# debug "$FUNCNAME: cache hit ($*)" |
|
|
|
depths[$elt]=$(cat "$cache_file") |
|
|
|
while read-0 k v; do |
|
|
|
depths["$k"]="$v" |
|
|
|
done < "$cache_file" |
|
|
|
return 0 |
|
|
|
fi |
|
|
|
|
|
|
@ -1402,20 +1405,21 @@ _rec_get_depth() { |
|
|
|
done |
|
|
|
# debug "Setting depth[$elt] to $((max + 1))" |
|
|
|
depths[$elt]=$((max + 1)) |
|
|
|
echo "${depths[$elt]}" > $cache_file |
|
|
|
array_kv_to_stdin depths > $cache_file |
|
|
|
} |
|
|
|
export -f _rec_get_depth |
|
|
|
|
|
|
|
|
|
|
|
get_ordered_service_dependencies() { |
|
|
|
local services=("$@") cache_file="$state_tmpdir/$FUNCNAME.cache.$(echo "$*" | md5_compat)" |
|
|
|
local services=("$@") cache_file="$state_tmpdir/$FUNCNAME.cache.$(H "$@")" \ |
|
|
|
i value key heads depths visited |
|
|
|
if [ -e "$cache_file" ]; then |
|
|
|
# debug "$FUNCNAME: cache hit ($*)" |
|
|
|
cat "$cache_file" |
|
|
|
return 0 |
|
|
|
fi |
|
|
|
|
|
|
|
#debug "Figuring ordered deps of $DARKYELLOW$services$NORMAL" |
|
|
|
#debug "Figuring ordered deps of $DARKYELLOW${services[@]}$NORMAL" |
|
|
|
if [ -z "${services[*]}" ]; then |
|
|
|
return 0 |
|
|
|
# print_syntax_error "$FUNCNAME: no arguments" |
|
|
@ -1439,7 +1443,7 @@ get_ordered_service_dependencies() { |
|
|
|
unset depths[$key] |
|
|
|
fi |
|
|
|
done |
|
|
|
i=$((i + 1)) |
|
|
|
((i++)) |
|
|
|
done | tee "$cache_file" |
|
|
|
} |
|
|
|
export -f get_ordered_service_dependencies |
|
|
|