From 92860706b2d643d5b142db5e82134e9e1066ed7d Mon Sep 17 00:00:00 2001 From: Nico Schottelius Date: Wed, 23 Mar 2011 12:20:09 +0100 Subject: [PATCH] import merge code from cdist-manifest-run-all into cdist-type-emulator Signed-off-by: Nico Schottelius --- bin/cdist-type-emulator | 53 +++++++++++++++++++++++++++++++++++++++++ doc/dev/todo/niconext | 3 +++ 2 files changed, 56 insertions(+) diff --git a/bin/cdist-type-emulator b/bin/cdist-type-emulator index 0b709a13..8451ec9d 100755 --- a/bin/cdist-type-emulator +++ b/bin/cdist-type-emulator @@ -164,3 +164,56 @@ if [ -e "${__cdist_new_object_dir}" ]; then fi + + +# -------------------------------------------------------------------------------- + + # Verify no conflicting objects have been created + while read __cdist_new_object; do + __cdist_object_found=$(grep "^$__cdist_new_object\$" "$__cdist_objects_list" || true) + + if [ "$__cdist_object_found" ]; then + __cdist_object_source="$(cat "$(__cdist_object_dir "$__cdist_new_object")/${__cdist_name_object_source}")" + __cdist_exit_err "${__cdist_manifest}: ${__cdist_new_object} already exists (source: $__cdist_object_source)" + fi + done < "$__cdist_new_objects_list" + + # Safe harbour: We can merge all objects into main tree + # Merge = mkdir + mv parameters and source information + while read __cdist_new_object; do + [ "$__cdist_new_objects_created" = "n" ] && __cdist_new_objects_created="y" + + # where to save the newly created object + __cdist_object_dir="$__cdist_out_object_dir/$__cdist_new_object" + mkdir -p "$__cdist_object_dir" + + # Move parts of the object (CANNOT MOVE COMPLETLEY, HIERACHY!) + __cdist_new_object_dir="$__cdist_new_objects_dir/$__cdist_new_object" + + # Source + mv "${__cdist_new_object_dir}/${__cdist_name_object_source}" \ + "$__cdist_object_dir" + + # Explorer, Parameter, Require + for __cdist_object_file in \ + ${__cdist_name_explorer} \ + ${__cdist_name_parameter} \ + ${__cdist_name_require} \ + ; do + + if [ -e "${__cdist_new_object_dir}/${__cdist_object_file}" ]; then + mv "${__cdist_new_object_dir}/${__cdist_object_file}" \ + "$__cdist_object_dir" + fi + done + done < "$__cdist_new_objects_list" + + # Remove listing and objects, otherwise the next type will reuse it... + rm -rf "$__cdist_new_objects_dir" "$__cdist_new_objects_list" + else + # Be nice, warn user if manifests exists, but is not executable + if [ -f "${__cdist_manifest}" ]; then + echo "Warning ${__cdist_manifest} exists, but is not executable." >&2 + fi + fi + fi diff --git a/doc/dev/todo/niconext b/doc/dev/todo/niconext index 6179c017..75790fb8 100644 --- a/doc/dev/todo/niconext +++ b/doc/dev/todo/niconext @@ -1,2 +1,5 @@ - think about using .cdist for meta information? - otherwise: parameter, gencode-local, etc. are not valid object id stuff + +- check cdist-manifest-run-all whether -x -f to manifest shouldn't be better + in cdist-manifest-run