another cleanup and almost running cdist-manifest-recursive-run

Signed-off-by: Nico Schottelius <nico@kr.ethz.ch>
This commit is contained in:
Nico Schottelius 2011-02-06 16:04:28 +01:00
parent f4c53e800c
commit 3dacee432e

View file

@ -38,54 +38,56 @@ set -eu
__cdist_output_dir="$1"; shift
__cdist_object_dir="$1"; shift
__cdist_object_ran_all=0
while [ "$__cdist_object_ran_all" = 0 ]; do
# change to directory containing objects
cd "$__cdist_object_dir"
# Loop until we do not create new objects anymore
# which is equal to all objects have been run
__cdist_object_created_new=1
while [ "$__cdist_object_created_new" = 1 ]; do
# assume we're done after this run
__cdist_object_created_new=0
# find all objects (every object has the source recorded)
find . -name "$__cdist_object_source" | \
sed -e "s;$__cdist_object_source\$;;" \
-e 's;^./;;' \
> "$__cdist_tmp_file"
cat "$__cdist_tmp_file"
while read object; do
if [ ! -f "${object}/$__cdist_object_finished" ]; then
echo "Running object ${object} ..."
manifest="${object}/${__cdist_name_init}"
if [ -x "${manifest}" ]; then
cdist-manifest-run "${manifest}" "${__cdist_tmp_dir}"
echo "Merging stuff back..."
# FIXME: continue here
# tar, cp, pax?
# - copy if not existing
# fail (abort whole recursive run) if existing
#
# iterate over all new objects and copy each back?
else
# Be nice, warn user if manifests exists, but is not executable
if [ -f "${manifest}" ]; then
echo "Warning ${manifest} is not executable"
fi
fi
touch "${object}/$__cdist_object_finished"
# At least one more run needed
__cdist_object_created_new=1
fi
done < "$__cdist_tmp_file"
# # FIXME past 1.0: allow multi level ids (/example/id instead of example_id only)
# # OUTER LOOP NEEDED IF GOING OVER ALL OBJECTS WITH FIND?
# for type in *; do
# cd "$__cdist_object_dir/$type"
#
# # find all objects (every object has the source recorded)
# find . -name "$__cdist_object_source" > "$__cdist_tmp_file"
#
# while read object; do
# echo "Running object ${type}/${object} ..."
# done < "$__cdist_tmp_file"
# done
#
# # FIXME: abort on real case only :-)
# __cdist_object_ran_all=1
done
exit 0
# Ensure binaries exist and are up-to-date
cdist-build-bin
# prepend our path, so all cdist tools come before other tools
PATH="${__cdist_cache_bin}:$PATH"
# Force -x, so the user is aware the file is executed
if [ ! -x "${__cdist_manifest_init}" ]; then
__cdist_exit_err "${__cdist_manifest_init} needs to be executable."
fi
mkdir -p "${__cdist_output_dir}"
"${__cdist_manifest}"