../core/__cdist_code_run and ../core/__cdist_type_build_emulation

Signed-off-by: Nico Schottelius <nico@kr.ethz.ch>
This commit is contained in:
Nico Schottelius 2011-06-14 01:27:53 +02:00
parent 47c32d1b53
commit 9a86b392dc
4 changed files with 41 additions and 38 deletions

View file

@ -21,30 +21,32 @@
# This binary is executed on the remote side to execute code
#
. cdist-config
[ $# -eq 2 ] || __cdist_usage "<object> <type>"
set -ue
__cdist_code_run()
{
__cdist_object_self="$1"; shift
__cdist_code_type="$1"; shift
[ $# -eq 2 ] || __cdist_usage "<object> <type>"
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}")"
__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 a file."
if [ ! -d "$(__cdist_object_dir "$__cdist_object_self")" ]; then
__cdist_exit_err "Object undefined"
fi
fi
__cdist_code="$(__cdist_object_code "$__cdist_object_self" "${__cdist_code_type}")"
__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 a file."
fi
fi
}

View file

@ -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

View file

@ -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" \

View file

@ -20,24 +20,24 @@
# Build pseudo binaries for type emulation
#
. cdist-config
[ $# -eq 1 ] || __cdist_usage "<out dir>"
set -eu
__cdist_type_build_emulation()
{
[ $# -eq 1 ] || __cdist_usage "<out dir>"
__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}"
}