cleanup bin/cdist_tree_wrapper and introduce __cdist_object_source
Signed-off-by: Nico Schottelius <nico@kr.ethz.ch>
This commit is contained in:
		
					parent
					
						
							
								b639ed3b0c
							
						
					
				
			
			
				commit
				
					
						c8242ef7da
					
				
			
		
					 2 changed files with 14 additions and 7 deletions
				
			
		| 
						 | 
				
			
			@ -145,6 +145,13 @@ __cdist_object_list()
 | 
			
		|||
      sed -e "s;$__cdist_name_object_source\$;;" -e 's;^./;;'
 | 
			
		||||
}
 | 
			
		||||
 | 
			
		||||
__cdist_object_source()
 | 
			
		||||
{
 | 
			
		||||
   local object_dir="$1"; shift
 | 
			
		||||
 | 
			
		||||
   cat "${object_dir}/$__cdist_name_object_source"
 | 
			
		||||
}
 | 
			
		||||
 | 
			
		||||
__cdist_tmp_removal()
 | 
			
		||||
{
 | 
			
		||||
   rm -rf "${__cdist_tmp_dir}"
 | 
			
		||||
| 
						 | 
				
			
			
 | 
			
		|||
| 
						 | 
				
			
			@ -30,26 +30,26 @@
 | 
			
		|||
 | 
			
		||||
set -eu
 | 
			
		||||
 | 
			
		||||
echo "I am $__cdist_myname and have been called with $@"
 | 
			
		||||
 | 
			
		||||
export __cdist_object_id="$1"; shift
 | 
			
		||||
export __cdist_type_current="$__cdist_myname"
 | 
			
		||||
export __cdist_type="$__cdist_myname"
 | 
			
		||||
 | 
			
		||||
echo "$__cdist_object_id" | grep -q "^${__cdist_sane_regexp}\$" || \
 | 
			
		||||
   __cdist_usage "Insane object id, ${__cdist_object_id}."
 | 
			
		||||
 | 
			
		||||
__cdist_tid="${__cdist_type_current}/${__cdist_object_id}"
 | 
			
		||||
__cdist_ddir="$__cdist_output_dir/${__cdist_tid}"
 | 
			
		||||
__cdist_object="${__cdist_type}/${__cdist_object_id}"
 | 
			
		||||
__cdist_ddir="$__cdist_output_dir/${__cdist_object}"
 | 
			
		||||
 | 
			
		||||
if [ -e "${__cdist_ddir}" ]; then
 | 
			
		||||
   source="$(__cdist_object_source "${__cdist_ddir}")"
 | 
			
		||||
   __cdist_exit_err "${__cdist_tid} already exists (source: $source)"
 | 
			
		||||
   __cdist_exit_err "${__cdist_object} already exists (source: $source)"
 | 
			
		||||
fi
 | 
			
		||||
 | 
			
		||||
mkdir -p "${__cdist_ddir}"
 | 
			
		||||
 | 
			
		||||
# echo "I am $__cdist_myname and have been called with $@"
 | 
			
		||||
 | 
			
		||||
# Record (correct ;-) source
 | 
			
		||||
echo "${__cdist_manifest}" > "${__cdist_ddir}/${__cdist_object_source}"
 | 
			
		||||
echo "${__cdist_manifest}" > "${__cdist_ddir}/${__cdist_name_object_source}"
 | 
			
		||||
 | 
			
		||||
while [ $# -gt 0 ]; do
 | 
			
		||||
   opt="$1"; shift
 | 
			
		||||
| 
						 | 
				
			
			
 | 
			
		|||
		Loading…
	
	Add table
		Add a link
		
	
		Reference in a new issue