forked from ungleich-public/cdist
in theory finish new algorithm to allow same objects
Signed-off-by: Nico Schottelius <nico@kr.ethz.ch>
This commit is contained in:
parent
8d32e00114
commit
1756608720
2 changed files with 34 additions and 6 deletions
|
@ -192,7 +192,12 @@ __cdist_object_code_finished()
|
||||||
|
|
||||||
__cdist_object_dir()
|
__cdist_object_dir()
|
||||||
{
|
{
|
||||||
echo "${__cdist_out_object_dir}/$1/${__cdist_name_dot_cdist}"
|
echo "$(__cdist_object_dir_base "$1")/${__cdist_name_dot_cdist}"
|
||||||
|
}
|
||||||
|
|
||||||
|
__cdist_object_dir_base()
|
||||||
|
{
|
||||||
|
echo "${__cdist_out_object_dir}/$1"
|
||||||
}
|
}
|
||||||
|
|
||||||
|
|
||||||
|
|
|
@ -77,7 +77,6 @@ __cdist_object_dir="$(__cdist_object_dir "$__cdist_object_self")"
|
||||||
mkdir -p "${__cdist_object_dir}"
|
mkdir -p "${__cdist_object_dir}"
|
||||||
__cdist_object_source_add "${__cdist_object_dir}"
|
__cdist_object_source_add "${__cdist_object_dir}"
|
||||||
|
|
||||||
|
|
||||||
# Record parameter
|
# Record parameter
|
||||||
__cdist_parameter_dir="$(__cdist_object_parameter_dir "$__cdist_object_self")"
|
__cdist_parameter_dir="$(__cdist_object_parameter_dir "$__cdist_object_self")"
|
||||||
mkdir -p "${__cdist_parameter_dir}"
|
mkdir -p "${__cdist_parameter_dir}"
|
||||||
|
@ -152,19 +151,43 @@ exit 1
|
||||||
# Save original destination
|
# Save original destination
|
||||||
__cdist_out_object_dir="$__cdist_out_object_dir_orig"
|
__cdist_out_object_dir="$__cdist_out_object_dir_orig"
|
||||||
|
|
||||||
__cdist_object_destination_dir="$(__cdist_object_dir "$__cdist_object_self")"
|
__cdist_new_object_dir="$(__cdist_object_dir "$__cdist_object_self")"
|
||||||
|
|
||||||
#
|
#
|
||||||
# If the object already exists and is exactly the same, merge it. Otherwise fail.
|
# If the object already exists and is exactly the same, merge it. Otherwise fail.
|
||||||
#
|
#
|
||||||
if [ -e "${__cdist_new_object_dir}" ]; then
|
if [ -e "${__cdist_new_object_dir}" ]; then
|
||||||
source="$(__cdist_object_source "${__cdist_new_object_dir}")"
|
# Allow diff to fail
|
||||||
__cdist_exit_err "${__cdist_object} already exists (source: $source)"
|
set +e
|
||||||
|
diff -ru "${__cdist_object_dir}" "${__cdist_new_object_dir}" \
|
||||||
|
> "$__cdist_tmp_file"; ret=$?
|
||||||
|
set -e
|
||||||
|
|
||||||
|
if [ "$ret" != 0 ]; then
|
||||||
|
# Go to standard error
|
||||||
|
exec >&2
|
||||||
|
echo "${__cdist_object_self} already exists differently."
|
||||||
|
echo "Recorded source(s):"
|
||||||
|
__cdist_object_source "${__cdist_new_object_dir}"
|
||||||
|
echo "Differences:"
|
||||||
|
cat "$__cdist_tmp_file"
|
||||||
|
__cdist_exit_err "Aborting due to object conflict."
|
||||||
|
fi
|
||||||
|
|
||||||
|
# Add ourselves, if we're compatible
|
||||||
|
__cdist_object_source_add "${__cdist_new_object_dir}"
|
||||||
|
else
|
||||||
|
#
|
||||||
|
# Move object into tree:
|
||||||
|
# Create full path minus .cdist and move .cdist
|
||||||
|
#
|
||||||
|
__cdist_new_object_base_dir="$(__cdist_object_base_dir "$__cdist_object_self")"
|
||||||
|
mkdir -p "$__cdist_new_object_base_dir"
|
||||||
|
mv "$__cdist_object_dir" "$__cdist_new_object_base_dir"
|
||||||
fi
|
fi
|
||||||
|
|
||||||
|
|
||||||
|
exit 0
|
||||||
|
|
||||||
# --------------------------------------------------------------------------------
|
# --------------------------------------------------------------------------------
|
||||||
|
|
||||||
|
|
Loading…
Reference in a new issue