From 9a86b392dca714e31497f9f39db9b54789dc49a3 Mon Sep 17 00:00:00 2001 From: Nico Schottelius Date: Tue, 14 Jun 2011 01:27:53 +0200 Subject: [PATCH] ../core/__cdist_code_run and ../core/__cdist_type_build_emulation Signed-off-by: Nico Schottelius --- bin/cdist-code-run => core/__cdist_code_run | 40 ++++++++++--------- core/__cdist_manifest_run | 3 +- core/__cdist_object_code_run | 2 +- .../__cdist_type_build_emulation | 34 ++++++++-------- 4 files changed, 41 insertions(+), 38 deletions(-) rename bin/cdist-code-run => core/__cdist_code_run (50%) rename bin/cdist-type-build-emulation => core/__cdist_type_build_emulation (57%) diff --git a/bin/cdist-code-run b/core/__cdist_code_run similarity index 50% rename from bin/cdist-code-run rename to core/__cdist_code_run index 3d7499bf..6a1b916b 100755 --- a/bin/cdist-code-run +++ b/core/__cdist_code_run @@ -21,30 +21,32 @@ # This binary is executed on the remote side to execute code # -. cdist-config -[ $# -eq 2 ] || __cdist_usage " " -set -ue +__cdist_code_run() +{ -__cdist_object_self="$1"; shift -__cdist_code_type="$1"; shift + [ $# -eq 2 ] || __cdist_usage " " -if [ ! -d "$(__cdist_object_dir "$__cdist_object_self")" ]; then - __cdist_exit_err "Object undefined" -fi + __cdist_object_self="$1"; shift + __cdist_code_type="$1"; shift -__cdist_code="$(__cdist_object_code "$__cdist_object_self" "${__cdist_code_type}")" + if [ ! -d "$(__cdist_object_dir "$__cdist_object_self")" ]; then + __cdist_exit_err "Object undefined" + fi -__cdist_echo info "Checking code-${__cdist_code_type}" + __cdist_code="$(__cdist_object_code "$__cdist_object_self" "${__cdist_code_type}")" -if [ -e "$__cdist_code" ]; then - if [ -f "$__cdist_code" ]; then - if [ -x "$__cdist_code" ]; then - __cdist_echo info "Executing code-${__cdist_code_type}" - __cdist_exec_fail_on_error "$__cdist_code" + __cdist_echo info "Checking code-${__cdist_code_type}" + + if [ -e "$__cdist_code" ]; then + if [ -f "$__cdist_code" ]; then + if [ -x "$__cdist_code" ]; then + __cdist_echo info "Executing code-${__cdist_code_type}" + __cdist_exec_fail_on_error "$__cdist_code" + else + __cdist_exit_err "$__cdist_code exists, but is not executable." + fi else - __cdist_exit_err "$__cdist_code exists, but is not executable." + __cdist_exit_err "$__cdist_code exists, but is not a file." fi - else - __cdist_exit_err "$__cdist_code exists, but is not a file." fi -fi +} diff --git a/core/__cdist_manifest_run b/core/__cdist_manifest_run index 0ba5f515..76d0a934 100755 --- a/core/__cdist_manifest_run +++ b/core/__cdist_manifest_run @@ -46,7 +46,8 @@ __cdist_manifest_run() # # Ensure binaries exist and are up-to-date - cdist-type-build-emulation "${__cdist_out_type_bin_dir}" \ + # FIXME: do only once! no need to check for every manifest! + __cdist_type_build_emulation "${__cdist_out_type_bin_dir}" \ || __cdist_exit_err "Failed to build type emulation binaries" # prepend our path, so all cdist tools come before other tools diff --git a/core/__cdist_object_code_run b/core/__cdist_object_code_run index cecb6659..d25d1dca 100755 --- a/core/__cdist_object_code_run +++ b/core/__cdist_object_code_run @@ -29,7 +29,7 @@ __cdist_object_code_run() # Code local export __cdist_out_object_dir="$__cdist_out_object_dir" - cdist-code-run "$__cdist_object_code_run_object" "${__cdist_name_gencode_local}" + __cdist_code_run "$__cdist_object_code_run_object" "${__cdist_name_gencode_local}" # Code remote cdist-run-remote "$__cdist_target_host" \ diff --git a/bin/cdist-type-build-emulation b/core/__cdist_type_build_emulation similarity index 57% rename from bin/cdist-type-build-emulation rename to core/__cdist_type_build_emulation index 51c2f5b4..a6cfcaa6 100755 --- a/bin/cdist-type-build-emulation +++ b/core/__cdist_type_build_emulation @@ -20,24 +20,24 @@ # Build pseudo binaries for type emulation # -. cdist-config -[ $# -eq 1 ] || __cdist_usage "" -set -eu +__cdist_type_build_emulation() +{ + [ $# -eq 1 ] || __cdist_usage "" -__cdist_output_dir="$1"; shift + __cdist_output_dir="$1"; shift + __cdist_type_emulator="$__cdist_abs_mydir/cdist-type-emulator" -__cdist_type_emulator="$__cdist_abs_mydir/cdist-type-emulator" + if [ ! -d "${__cdist_type_dir}" ]; then + __cdist_exit_err "$__cdist_type_dir must exist and contain available types" + fi -if [ ! -d "${__cdist_type_dir}" ]; then - __cdist_exit_err "$__cdist_type_dir must exist and contain available types" -fi + # Get Types + cd "${__cdist_type_dir}" + ls -1 > "${__cdist_tmp_file}" -# Get Types -cd "${__cdist_type_dir}" -ls -1 > "${__cdist_tmp_file}" - -# Create binaries -mkdir -p "${__cdist_output_dir}" -while read type; do - ln -sf "${__cdist_type_emulator}" "${__cdist_output_dir}/${type}" -done < "${__cdist_tmp_file}" + # Create binaries + mkdir -p "${__cdist_output_dir}" + while read type; do + ln -sf "${__cdist_type_emulator}" "${__cdist_output_dir}/${type}" + done < "${__cdist_tmp_file}" +}