../core/__cdist_code_run and ../core/__cdist_type_build_emulation
Signed-off-by: Nico Schottelius <nico@kr.ethz.ch>
This commit is contained in:
parent
47c32d1b53
commit
9a86b392dc
4 changed files with 41 additions and 38 deletions
|
@ -21,30 +21,32 @@
|
||||||
# This binary is executed on the remote side to execute code
|
# This binary is executed on the remote side to execute code
|
||||||
#
|
#
|
||||||
|
|
||||||
. cdist-config
|
__cdist_code_run()
|
||||||
[ $# -eq 2 ] || __cdist_usage "<object> <type>"
|
{
|
||||||
set -ue
|
|
||||||
|
|
||||||
__cdist_object_self="$1"; shift
|
[ $# -eq 2 ] || __cdist_usage "<object> <type>"
|
||||||
__cdist_code_type="$1"; shift
|
|
||||||
|
|
||||||
if [ ! -d "$(__cdist_object_dir "$__cdist_object_self")" ]; then
|
__cdist_object_self="$1"; shift
|
||||||
__cdist_exit_err "Object undefined"
|
__cdist_code_type="$1"; shift
|
||||||
fi
|
|
||||||
|
|
||||||
__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
|
__cdist_echo info "Checking code-${__cdist_code_type}"
|
||||||
if [ -f "$__cdist_code" ]; then
|
|
||||||
if [ -x "$__cdist_code" ]; then
|
if [ -e "$__cdist_code" ]; then
|
||||||
__cdist_echo info "Executing code-${__cdist_code_type}"
|
if [ -f "$__cdist_code" ]; then
|
||||||
__cdist_exec_fail_on_error "$__cdist_code"
|
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
|
else
|
||||||
__cdist_exit_err "$__cdist_code exists, but is not executable."
|
__cdist_exit_err "$__cdist_code exists, but is not a file."
|
||||||
fi
|
fi
|
||||||
else
|
|
||||||
__cdist_exit_err "$__cdist_code exists, but is not a file."
|
|
||||||
fi
|
fi
|
||||||
fi
|
}
|
|
@ -46,7 +46,8 @@ __cdist_manifest_run()
|
||||||
#
|
#
|
||||||
|
|
||||||
# Ensure binaries exist and are up-to-date
|
# 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"
|
|| __cdist_exit_err "Failed to build type emulation binaries"
|
||||||
|
|
||||||
# prepend our path, so all cdist tools come before other tools
|
# prepend our path, so all cdist tools come before other tools
|
||||||
|
|
|
@ -29,7 +29,7 @@ __cdist_object_code_run()
|
||||||
|
|
||||||
# Code local
|
# Code local
|
||||||
export __cdist_out_object_dir="$__cdist_out_object_dir"
|
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
|
# Code remote
|
||||||
cdist-run-remote "$__cdist_target_host" \
|
cdist-run-remote "$__cdist_target_host" \
|
||||||
|
|
|
@ -20,24 +20,24 @@
|
||||||
# Build pseudo binaries for type emulation
|
# Build pseudo binaries for type emulation
|
||||||
#
|
#
|
||||||
|
|
||||||
. cdist-config
|
__cdist_type_build_emulation()
|
||||||
[ $# -eq 1 ] || __cdist_usage "<out dir>"
|
{
|
||||||
set -eu
|
[ $# -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
|
# Get Types
|
||||||
__cdist_exit_err "$__cdist_type_dir must exist and contain available types"
|
cd "${__cdist_type_dir}"
|
||||||
fi
|
ls -1 > "${__cdist_tmp_file}"
|
||||||
|
|
||||||
# Get Types
|
# Create binaries
|
||||||
cd "${__cdist_type_dir}"
|
mkdir -p "${__cdist_output_dir}"
|
||||||
ls -1 > "${__cdist_tmp_file}"
|
while read type; do
|
||||||
|
ln -sf "${__cdist_type_emulator}" "${__cdist_output_dir}/${type}"
|
||||||
# Create binaries
|
done < "${__cdist_tmp_file}"
|
||||||
mkdir -p "${__cdist_output_dir}"
|
}
|
||||||
while read type; do
|
|
||||||
ln -sf "${__cdist_type_emulator}" "${__cdist_output_dir}/${type}"
|
|
||||||
done < "${__cdist_tmp_file}"
|
|
Loading…
Reference in a new issue