From 42af407d3ef7c814d8019c7cd518ac3e1e234271 Mon Sep 17 00:00:00 2001 From: Nico Schottelius Date: Fri, 18 Mar 2011 01:31:30 +0100 Subject: [PATCH] refactor cdist-remote-code-run-all Signed-off-by: Nico Schottelius --- bin/cdist-config | 6 ++++++ bin/cdist-remote-code-run-all | 21 +++++++-------------- 2 files changed, 13 insertions(+), 14 deletions(-) diff --git a/bin/cdist-config b/bin/cdist-config index 38f997fa..62337024 100755 --- a/bin/cdist-config +++ b/bin/cdist-config @@ -42,6 +42,7 @@ __cdist_abs_myname="$__cdist_abs_mydir/$__cdist_myname" : ${__cdist_name_bin:=bin} : ${__cdist_name_code:=code} +: ${__cdist_name_code_finished:=.codedone} : ${__cdist_name_conf_dir:=conf} : ${__cdist_name_explorer:=explorer} : ${__cdist_name_gencode:=gencode} @@ -239,6 +240,11 @@ __cdist_object_code() echo "$(__cdist_object_dir "$1")/${__cdist_name_code}" } +__cdist_object_code_finished() +{ + echo "$(__cdist_object_dir "$1")/${__cdist_name_code_finished}" +} + __cdist_object_parameter_dir() { echo "$(__cdist_object_dir "$1")/${__cdist_name_parameter}" diff --git a/bin/cdist-remote-code-run-all b/bin/cdist-remote-code-run-all index 7135037f..6c60337a 100755 --- a/bin/cdist-remote-code-run-all +++ b/bin/cdist-remote-code-run-all @@ -30,21 +30,14 @@ __cdist_out_object_dir="$1"; shift __cdist_object_list "$__cdist_out_object_dir" > "$__cdist_tmp_file" -# FIXME post 1.0: add dependencies while read object; do code="$(__cdist_object_code "$object")" - echo "Running code for $object ..." - if [ -e "$code" ]; then - if [ -f "$code" ]; then - if [ -x "$code" ]; then - "$code" - else - __cdist_exit_err "$code exists, but is not executable." - fi - else - __cdist_exit_err "$code exists, but is not a file." - fi - else - __cdist_exit_err "Missing code for ${object}." + require="$(__cdist_object_require "$object")" + + # Object code depends on others, execute them before us + if [ -f "$require" ]; then + while read requirement; do + cdist-remote-code-run "$code" + done < "$require" fi done < "$__cdist_tmp_file"