introduce and use __cdist_exec_fail_on_error
Signed-off-by: Nico Schottelius <nico@kr.ethz.ch>
This commit is contained in:
		
					parent
					
						
							
								da8abcb770
							
						
					
				
			
			
				commit
				
					
						5dcb719844
					
				
			
		
					 3 changed files with 5 additions and 29 deletions
				
			
		| 
						 | 
					@ -181,7 +181,8 @@ __cdist_object_source()
 | 
				
			||||||
 | 
					
 | 
				
			||||||
__cdist_exec_fail_on_error()
 | 
					__cdist_exec_fail_on_error()
 | 
				
			||||||
{
 | 
					{
 | 
				
			||||||
   sh -e "$1"
 | 
					   sh -e "$@"
 | 
				
			||||||
 | 
					   [ "$?" -eq 0 ] || __cdist_exit_err "Error: $1 exited non-zero."
 | 
				
			||||||
}
 | 
					}
 | 
				
			||||||
 | 
					
 | 
				
			||||||
 | 
					
 | 
				
			||||||
| 
						 | 
					
 | 
				
			||||||
| 
						 | 
					@ -41,17 +41,6 @@ if [ ! -x "${__cdist_manifest}" ]; then
 | 
				
			||||||
   __cdist_exit_err "${__cdist_manifest} needs to be executable."
 | 
					   __cdist_exit_err "${__cdist_manifest} needs to be executable."
 | 
				
			||||||
fi
 | 
					fi
 | 
				
			||||||
 | 
					
 | 
				
			||||||
mkdir -p "${__cdist_output_dir}"
 | 
					mkdir -p "${__cdist_output_dir}" || __cdist_exit_err "Cannot create output dir ${__cdist_output_dir}"
 | 
				
			||||||
 | 
					
 | 
				
			||||||
# Catch errors ourselves now
 | 
					__cdist_exec_fail_on_error "${__cdist_manifest}"
 | 
				
			||||||
set +e
 | 
					 | 
				
			||||||
 | 
					 | 
				
			||||||
# Ensure manifest fails if any error exists - FIXME: redundant, cdist-object-codegen
 | 
					 | 
				
			||||||
(
 | 
					 | 
				
			||||||
   set -e
 | 
					 | 
				
			||||||
   . "${__cdist_manifest}"
 | 
					 | 
				
			||||||
); ret=$?
 | 
					 | 
				
			||||||
 | 
					 | 
				
			||||||
if [ "$ret" -ne 0 ]; then
 | 
					 | 
				
			||||||
   __cdist_exit_err "Error: ${__cdist_manifest} exited non-zero."
 | 
					 | 
				
			||||||
fi
 | 
					 | 
				
			||||||
| 
						 | 
					
 | 
				
			||||||
| 
						 | 
					@ -54,19 +54,5 @@ if [ -x "$gencode" ]; then
 | 
				
			||||||
 | 
					
 | 
				
			||||||
eof
 | 
					eof
 | 
				
			||||||
 | 
					
 | 
				
			||||||
   # Catch errors ourself now
 | 
					   __cdist_exec_fail_on_error "$gencode"
 | 
				
			||||||
   set +e
 | 
					 | 
				
			||||||
   (
 | 
					 | 
				
			||||||
      # Ensure manifest fails if something within manifest fails
 | 
					 | 
				
			||||||
      # And not all manifests need to include set -e themselves
 | 
					 | 
				
			||||||
      set -e
 | 
					 | 
				
			||||||
      . "$gencode"
 | 
					 | 
				
			||||||
   ); ret=$?
 | 
					 | 
				
			||||||
 | 
					 | 
				
			||||||
else
 | 
					 | 
				
			||||||
   ret=0
 | 
					 | 
				
			||||||
fi
 | 
					 | 
				
			||||||
 | 
					 | 
				
			||||||
if [ "$ret" -ne 0 ]; then
 | 
					 | 
				
			||||||
   __cdist_exit_err "Error: $gencode exited non-zero"
 | 
					 | 
				
			||||||
fi
 | 
					fi
 | 
				
			||||||
| 
						 | 
					
 | 
				
			||||||
		Loading…
	
	Add table
		Add a link
		
	
		Reference in a new issue