forked from ungleich-public/cdist
		
	begin to sort cdist-config by alphabet
Signed-off-by: Nico Schottelius <nico@kr.ethz.ch>
This commit is contained in:
		
					parent
					
						
							
								25bf9e4185
							
						
					
				
			
			
				commit
				
					
						359e252ef7
					
				
			
		
					 1 changed files with 114 additions and 102 deletions
				
			
		
							
								
								
									
										216
									
								
								bin/cdist-config
									
										
									
									
									
								
							
							
						
						
									
										216
									
								
								bin/cdist-config
									
										
									
									
									
								
							| 
						 | 
					@ -134,7 +134,7 @@ __cdist_tmp_file=$(mktemp "$__cdist_tmp_dir/cdist.XXXXXXXXXXXX")
 | 
				
			||||||
: ${__cdist_remote_out_object_base_dir:=$__cdist_remote_out_dir/$__cdist_name_object}
 | 
					: ${__cdist_remote_out_object_base_dir:=$__cdist_remote_out_dir/$__cdist_name_object}
 | 
				
			||||||
 | 
					
 | 
				
			||||||
################################################################################
 | 
					################################################################################
 | 
				
			||||||
# Function list
 | 
					# Internal functions
 | 
				
			||||||
#
 | 
					#
 | 
				
			||||||
__cdist_debug_echo()
 | 
					__cdist_debug_echo()
 | 
				
			||||||
{
 | 
					{
 | 
				
			||||||
| 
						 | 
					@ -143,6 +143,12 @@ __cdist_debug_echo()
 | 
				
			||||||
   fi
 | 
					   fi
 | 
				
			||||||
}
 | 
					}
 | 
				
			||||||
 | 
					
 | 
				
			||||||
 | 
					__cdist_exec_fail_on_error()
 | 
				
			||||||
 | 
					{
 | 
				
			||||||
 | 
					   sh -e "$@"
 | 
				
			||||||
 | 
					   [ "$?" -eq 0 ] || __cdist_exit_err "Error: $1 exited non-zero."
 | 
				
			||||||
 | 
					}
 | 
				
			||||||
 | 
					
 | 
				
			||||||
__cdist_exit_err()
 | 
					__cdist_exit_err()
 | 
				
			||||||
{
 | 
					{
 | 
				
			||||||
   echo "$@" >&2
 | 
					   echo "$@" >&2
 | 
				
			||||||
| 
						 | 
					@ -170,76 +176,9 @@ __cdist_init_deploy()
 | 
				
			||||||
   ln -sf "$__cdist_conf_dir" "$__cdist_local_base_dir/$__cdist_name_conf_dir"
 | 
					   ln -sf "$__cdist_conf_dir" "$__cdist_local_base_dir/$__cdist_name_conf_dir"
 | 
				
			||||||
}
 | 
					}
 | 
				
			||||||
 | 
					
 | 
				
			||||||
__cdist_type_has_explorer()
 | 
					################################################################################
 | 
				
			||||||
{
 | 
					# Object
 | 
				
			||||||
   # We only create output, if there's at least one explorer
 | 
					#
 | 
				
			||||||
   # and can thus be used as a boolean ;-)
 | 
					 | 
				
			||||||
   if [ -d "$(__cdist_type_explorer_dir "$1")" ]; then
 | 
					 | 
				
			||||||
      ls -1 "$(__cdist_type_explorer_dir "$1")"
 | 
					 | 
				
			||||||
   fi
 | 
					 | 
				
			||||||
}
 | 
					 | 
				
			||||||
 | 
					 | 
				
			||||||
__cdist_type_dir()
 | 
					 | 
				
			||||||
{
 | 
					 | 
				
			||||||
   echo "${__cdist_type_dir}/$1"
 | 
					 | 
				
			||||||
}
 | 
					 | 
				
			||||||
 | 
					 | 
				
			||||||
__cdist_type_explorer_dir()
 | 
					 | 
				
			||||||
{
 | 
					 | 
				
			||||||
   echo "${__cdist_type_dir}/$1/${__cdist_name_explorer}"
 | 
					 | 
				
			||||||
}
 | 
					 | 
				
			||||||
 | 
					 | 
				
			||||||
__cdist_remote_type_explorer_dir()
 | 
					 | 
				
			||||||
{
 | 
					 | 
				
			||||||
   echo "${__cdist_remote_type_dir}/$1/${__cdist_name_explorer}"
 | 
					 | 
				
			||||||
}
 | 
					 | 
				
			||||||
 | 
					 | 
				
			||||||
__cdist_type_gencode()
 | 
					 | 
				
			||||||
{
 | 
					 | 
				
			||||||
   echo "${__cdist_type_dir}/$1/${__cdist_name_gencode}"
 | 
					 | 
				
			||||||
}
 | 
					 | 
				
			||||||
 | 
					 | 
				
			||||||
__cdist_type_singleton()
 | 
					 | 
				
			||||||
{
 | 
					 | 
				
			||||||
   echo "${__cdist_type_dir}/$1/${__cdist_name_singleton}"
 | 
					 | 
				
			||||||
}
 | 
					 | 
				
			||||||
 | 
					 | 
				
			||||||
__cdist_type_parameter_dir()
 | 
					 | 
				
			||||||
{
 | 
					 | 
				
			||||||
   echo "$(__cdist_type_dir "$1")/${__cdist_name_parameter}"
 | 
					 | 
				
			||||||
}
 | 
					 | 
				
			||||||
 | 
					 | 
				
			||||||
# Shorthand for required and optional
 | 
					 | 
				
			||||||
__cdist_type_parameter_required()
 | 
					 | 
				
			||||||
{
 | 
					 | 
				
			||||||
   echo "$(__cdist_type_parameter_dir "$1")/$__cdist_name_parameter_required"
 | 
					 | 
				
			||||||
}
 | 
					 | 
				
			||||||
 | 
					 | 
				
			||||||
__cdist_type_parameter_optional()
 | 
					 | 
				
			||||||
{
 | 
					 | 
				
			||||||
   echo "$(__cdist_type_parameter_dir "$1")/$__cdist_name_parameter_optional"
 | 
					 | 
				
			||||||
}
 | 
					 | 
				
			||||||
 | 
					 | 
				
			||||||
__cdist_type_from_object()
 | 
					 | 
				
			||||||
{
 | 
					 | 
				
			||||||
   echo "${1%%/*}"
 | 
					 | 
				
			||||||
}
 | 
					 | 
				
			||||||
 | 
					 | 
				
			||||||
__cdist_object_id_from_object()
 | 
					 | 
				
			||||||
{
 | 
					 | 
				
			||||||
   echo "${1#*/}"
 | 
					 | 
				
			||||||
}
 | 
					 | 
				
			||||||
 | 
					 | 
				
			||||||
__cdist_object_dir()
 | 
					 | 
				
			||||||
{
 | 
					 | 
				
			||||||
   __cdist_object_dir="${__cdist_out_object_dir}/$1/${__cdist_name_dot_cdist}"
 | 
					 | 
				
			||||||
   echo "$__cdist_object_dir"
 | 
					 | 
				
			||||||
}
 | 
					 | 
				
			||||||
 | 
					 | 
				
			||||||
__cdist_remote_object_dir()
 | 
					 | 
				
			||||||
{
 | 
					 | 
				
			||||||
   echo "${__cdist_remote_out_object_base_dir}/$1"
 | 
					 | 
				
			||||||
}
 | 
					 | 
				
			||||||
 | 
					
 | 
				
			||||||
__cdist_object_code()
 | 
					__cdist_object_code()
 | 
				
			||||||
{
 | 
					{
 | 
				
			||||||
| 
						 | 
					@ -251,31 +190,6 @@ __cdist_object_code_finished()
 | 
				
			||||||
   echo "$(__cdist_object_dir "$1")/${__cdist_name_code_finished}"
 | 
					   echo "$(__cdist_object_dir "$1")/${__cdist_name_code_finished}"
 | 
				
			||||||
}
 | 
					}
 | 
				
			||||||
 | 
					
 | 
				
			||||||
__cdist_object_parameter_dir()
 | 
					 | 
				
			||||||
{
 | 
					 | 
				
			||||||
   echo "$(__cdist_object_dir "$1")/${__cdist_name_parameter}"
 | 
					 | 
				
			||||||
}
 | 
					 | 
				
			||||||
 | 
					 | 
				
			||||||
__cdist_remote_object_parameter_dir()
 | 
					 | 
				
			||||||
{
 | 
					 | 
				
			||||||
   echo "$(__cdist_remote_object_dir "$1")/${__cdist_name_parameter}"
 | 
					 | 
				
			||||||
}
 | 
					 | 
				
			||||||
 | 
					 | 
				
			||||||
__cdist_object_require()
 | 
					 | 
				
			||||||
{
 | 
					 | 
				
			||||||
   echo "$(__cdist_object_dir "$1")/${__cdist_name_require}"
 | 
					 | 
				
			||||||
}
 | 
					 | 
				
			||||||
 | 
					 | 
				
			||||||
__cdist_object_type_explorer_dir()
 | 
					 | 
				
			||||||
{
 | 
					 | 
				
			||||||
   echo "$(__cdist_object_dir "$1")/${__cdist_name_explorer}"
 | 
					 | 
				
			||||||
}
 | 
					 | 
				
			||||||
 | 
					 | 
				
			||||||
__cdist_remote_object_type_explorer_dir()
 | 
					 | 
				
			||||||
{
 | 
					 | 
				
			||||||
   echo "$(__cdist_remote_object_dir "$1")/${__cdist_name_explorer}"
 | 
					 | 
				
			||||||
}
 | 
					 | 
				
			||||||
 | 
					 | 
				
			||||||
# Find objects, remove ./ and /MARKER
 | 
					# Find objects, remove ./ and /MARKER
 | 
				
			||||||
__cdist_object_list()
 | 
					__cdist_object_list()
 | 
				
			||||||
{
 | 
					{
 | 
				
			||||||
| 
						 | 
					@ -298,19 +212,117 @@ __cdist_object_source()
 | 
				
			||||||
   cat "${object_dir}/${__cdist_name_object_source}"
 | 
					   cat "${object_dir}/${__cdist_name_object_source}"
 | 
				
			||||||
}
 | 
					}
 | 
				
			||||||
 | 
					
 | 
				
			||||||
__cdist_exec_fail_on_error()
 | 
					__cdist_object_parameter_dir()
 | 
				
			||||||
{
 | 
					{
 | 
				
			||||||
   sh -e "$@"
 | 
					   echo "$(__cdist_object_dir "$1")/${__cdist_name_parameter}"
 | 
				
			||||||
   [ "$?" -eq 0 ] || __cdist_exit_err "Error: $1 exited non-zero."
 | 
					}
 | 
				
			||||||
 | 
					
 | 
				
			||||||
 | 
					__cdist_remote_object_parameter_dir()
 | 
				
			||||||
 | 
					{
 | 
				
			||||||
 | 
					   echo "$(__cdist_remote_object_dir "$1")/${__cdist_name_parameter}"
 | 
				
			||||||
 | 
					}
 | 
				
			||||||
 | 
					
 | 
				
			||||||
 | 
					__cdist_object_require()
 | 
				
			||||||
 | 
					{
 | 
				
			||||||
 | 
					   echo "$(__cdist_object_dir "$1")/${__cdist_name_require}"
 | 
				
			||||||
 | 
					}
 | 
				
			||||||
 | 
					
 | 
				
			||||||
 | 
					__cdist_object_type_explorer_dir()
 | 
				
			||||||
 | 
					{
 | 
				
			||||||
 | 
					   echo "$(__cdist_object_dir "$1")/${__cdist_name_explorer}"
 | 
				
			||||||
 | 
					}
 | 
				
			||||||
 | 
					
 | 
				
			||||||
 | 
					__cdist_object_id_from_object()
 | 
				
			||||||
 | 
					{
 | 
				
			||||||
 | 
					   echo "${1#*/}"
 | 
				
			||||||
 | 
					}
 | 
				
			||||||
 | 
					
 | 
				
			||||||
 | 
					__cdist_object_dir()
 | 
				
			||||||
 | 
					{
 | 
				
			||||||
 | 
					   __cdist_object_dir="${__cdist_out_object_dir}/$1/${__cdist_name_dot_cdist}"
 | 
				
			||||||
 | 
					   echo "$__cdist_object_dir"
 | 
				
			||||||
 | 
					}
 | 
				
			||||||
 | 
					
 | 
				
			||||||
 | 
					################################################################################
 | 
				
			||||||
 | 
					# Remote
 | 
				
			||||||
 | 
					#
 | 
				
			||||||
 | 
					
 | 
				
			||||||
 | 
					__cdist_remote_object_dir()
 | 
				
			||||||
 | 
					{
 | 
				
			||||||
 | 
					   echo "${__cdist_remote_out_object_base_dir}/$1"
 | 
				
			||||||
 | 
					}
 | 
				
			||||||
 | 
					
 | 
				
			||||||
 | 
					__cdist_remote_object_type_explorer_dir()
 | 
				
			||||||
 | 
					{
 | 
				
			||||||
 | 
					   echo "$(__cdist_remote_object_dir "$1")/${__cdist_name_explorer}"
 | 
				
			||||||
}
 | 
					}
 | 
				
			||||||
 | 
					
 | 
				
			||||||
 | 
					
 | 
				
			||||||
 | 
					__cdist_remote_type_explorer_dir()
 | 
				
			||||||
 | 
					{
 | 
				
			||||||
 | 
					   echo "${__cdist_remote_type_dir}/$1/${__cdist_name_explorer}"
 | 
				
			||||||
 | 
					}
 | 
				
			||||||
 | 
					
 | 
				
			||||||
 | 
					
 | 
				
			||||||
 | 
					################################################################################
 | 
				
			||||||
 | 
					# Temp clenup
 | 
				
			||||||
 | 
					#
 | 
				
			||||||
__cdist_tmp_removal()
 | 
					__cdist_tmp_removal()
 | 
				
			||||||
{
 | 
					{
 | 
				
			||||||
   rm -rf "${__cdist_tmp_dir}"
 | 
					   rm -rf "${__cdist_tmp_dir}"
 | 
				
			||||||
}
 | 
					}
 | 
				
			||||||
 | 
					
 | 
				
			||||||
################################################################################
 | 
					 | 
				
			||||||
# Trap for tmp removal
 | 
					 | 
				
			||||||
#
 | 
					 | 
				
			||||||
trap __cdist_tmp_removal EXIT
 | 
					trap __cdist_tmp_removal EXIT
 | 
				
			||||||
 | 
					
 | 
				
			||||||
 | 
					
 | 
				
			||||||
 | 
					################################################################################
 | 
				
			||||||
 | 
					# Type
 | 
				
			||||||
 | 
					#
 | 
				
			||||||
 | 
					__cdist_type_dir()
 | 
				
			||||||
 | 
					{
 | 
				
			||||||
 | 
					   echo "${__cdist_type_dir}/$1"
 | 
				
			||||||
 | 
					}
 | 
				
			||||||
 | 
					
 | 
				
			||||||
 | 
					__cdist_type_explorer_dir()
 | 
				
			||||||
 | 
					{
 | 
				
			||||||
 | 
					   echo "${__cdist_type_dir}/$1/${__cdist_name_explorer}"
 | 
				
			||||||
 | 
					}
 | 
				
			||||||
 | 
					
 | 
				
			||||||
 | 
					__cdist_type_from_object()
 | 
				
			||||||
 | 
					{
 | 
				
			||||||
 | 
					   echo "${1%%/*}"
 | 
				
			||||||
 | 
					}
 | 
				
			||||||
 | 
					
 | 
				
			||||||
 | 
					__cdist_type_has_explorer()
 | 
				
			||||||
 | 
					{
 | 
				
			||||||
 | 
					   # We only create output, if there's at least one explorer
 | 
				
			||||||
 | 
					   # and can thus be used as a boolean ;-)
 | 
				
			||||||
 | 
					   if [ -d "$(__cdist_type_explorer_dir "$1")" ]; then
 | 
				
			||||||
 | 
					      ls -1 "$(__cdist_type_explorer_dir "$1")"
 | 
				
			||||||
 | 
					   fi
 | 
				
			||||||
 | 
					}
 | 
				
			||||||
 | 
					
 | 
				
			||||||
 | 
					__cdist_type_gencode()
 | 
				
			||||||
 | 
					{
 | 
				
			||||||
 | 
					   echo "${__cdist_type_dir}/$1/${__cdist_name_gencode}"
 | 
				
			||||||
 | 
					}
 | 
				
			||||||
 | 
					
 | 
				
			||||||
 | 
					__cdist_type_parameter_dir()
 | 
				
			||||||
 | 
					{
 | 
				
			||||||
 | 
					   echo "$(__cdist_type_dir "$1")/${__cdist_name_parameter}"
 | 
				
			||||||
 | 
					}
 | 
				
			||||||
 | 
					
 | 
				
			||||||
 | 
					__cdist_type_parameter_optional()
 | 
				
			||||||
 | 
					{
 | 
				
			||||||
 | 
					   echo "$(__cdist_type_parameter_dir "$1")/$__cdist_name_parameter_optional"
 | 
				
			||||||
 | 
					}
 | 
				
			||||||
 | 
					
 | 
				
			||||||
 | 
					__cdist_type_parameter_required()
 | 
				
			||||||
 | 
					{
 | 
				
			||||||
 | 
					   echo "$(__cdist_type_parameter_dir "$1")/$__cdist_name_parameter_required"
 | 
				
			||||||
 | 
					}
 | 
				
			||||||
 | 
					
 | 
				
			||||||
 | 
					__cdist_type_singleton()
 | 
				
			||||||
 | 
					{
 | 
				
			||||||
 | 
					   echo "${__cdist_type_dir}/$1/${__cdist_name_singleton}"
 | 
				
			||||||
 | 
					}
 | 
				
			||||||
| 
						 | 
					
 | 
				
			||||||
		Loading…
	
	Add table
		Add a link
		
	
		Reference in a new issue