../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,22 +21,23 @@
|
||||||
# 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_code_type="$1"; shift
|
||||||
|
|
||||||
|
if [ ! -d "$(__cdist_object_dir "$__cdist_object_self")" ]; then
|
||||||
__cdist_exit_err "Object undefined"
|
__cdist_exit_err "Object undefined"
|
||||||
fi
|
fi
|
||||||
|
|
||||||
__cdist_code="$(__cdist_object_code "$__cdist_object_self" "${__cdist_code_type}")"
|
__cdist_code="$(__cdist_object_code "$__cdist_object_self" "${__cdist_code_type}")"
|
||||||
|
|
||||||
__cdist_echo info "Checking code-${__cdist_code_type}"
|
__cdist_echo info "Checking code-${__cdist_code_type}"
|
||||||
|
|
||||||
if [ -e "$__cdist_code" ]; then
|
if [ -e "$__cdist_code" ]; then
|
||||||
if [ -f "$__cdist_code" ]; then
|
if [ -f "$__cdist_code" ]; then
|
||||||
if [ -x "$__cdist_code" ]; then
|
if [ -x "$__cdist_code" ]; then
|
||||||
__cdist_echo info "Executing code-${__cdist_code_type}"
|
__cdist_echo info "Executing code-${__cdist_code_type}"
|
||||||
|
@ -47,4 +48,5 @@ if [ -e "$__cdist_code" ]; then
|
||||||
else
|
else
|
||||||
__cdist_exit_err "$__cdist_code exists, but is not a file."
|
__cdist_exit_err "$__cdist_code exists, but is not a file."
|
||||||
fi
|
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
|
||||||
|
|
||||||
if [ ! -d "${__cdist_type_dir}" ]; then
|
|
||||||
__cdist_exit_err "$__cdist_type_dir must exist and contain available types"
|
__cdist_exit_err "$__cdist_type_dir must exist and contain available types"
|
||||||
fi
|
fi
|
||||||
|
|
||||||
# Get Types
|
# Get Types
|
||||||
cd "${__cdist_type_dir}"
|
cd "${__cdist_type_dir}"
|
||||||
ls -1 > "${__cdist_tmp_file}"
|
ls -1 > "${__cdist_tmp_file}"
|
||||||
|
|
||||||
# Create binaries
|
# Create binaries
|
||||||
mkdir -p "${__cdist_output_dir}"
|
mkdir -p "${__cdist_output_dir}"
|
||||||
while read type; do
|
while read type; do
|
||||||
ln -sf "${__cdist_type_emulator}" "${__cdist_output_dir}/${type}"
|
ln -sf "${__cdist_type_emulator}" "${__cdist_output_dir}/${type}"
|
||||||
done < "${__cdist_tmp_file}"
|
done < "${__cdist_tmp_file}"
|
||||||
|
}
|
Loading…
Reference in a new issue