From 824042d6082934964feebed61b42027304cc6b83 Mon Sep 17 00:00:00 2001 From: Michael Johnson Date: Fri, 6 Sep 2019 15:55:30 -0700 Subject: [PATCH] Add output for mis-configured element scripts I commonly get asked for help when people are attempting to create local image elements and they cannot get them to work. diskimage-builder silently ignores element scripts that it doesn't find to it's liking, such as non-executable or files with extensions (.sh is a common mistake). This patch extends the '-x' tracing flag down to dib-run-parts and will cause it to print out helpful messages when these files would otherwise be silently ignored. Examples: Ignoring non-executable files: 10-do-not-run-me Ignoring non-conforming filenames: 10-I-can-run.sh I am not enabling these by default as they can create extra noise and require additional filesystem IO to produce. Change-Id: Ic804efca3015c199440b4b10da951d71a815c64f --- diskimage_builder/lib/dib-run-parts | 11 +++++++++++ 1 file changed, 11 insertions(+) diff --git a/diskimage_builder/lib/dib-run-parts b/diskimage_builder/lib/dib-run-parts index dc5748647..4b893a85b 100755 --- a/diskimage_builder/lib/dib-run-parts +++ b/diskimage_builder/lib/dib-run-parts @@ -105,6 +105,17 @@ if [ "$show_list" == "1" ] ; then exit 0 fi +if [ ${DIB_DEBUG_TRACE} -gt 0 ]; then + non_exec=$(find $target_dir -maxdepth 1 -xtype f \! -executable -printf '%f\n') + if [ ! -z "$non_exec" ]; then + output "Ignoring non-executable files: $non_exec" + fi + bad_filename=$(find $target_dir -maxdepth 1 -xtype f -executable -printf '%f\n' | grep -v -E "$allowed_regex" || echo "") + if [ ! -z "$bad_filename" ]; then + output "Ignoring non-conforming filenames: $bad_filename" + fi +fi + PROFILE_DIR=$(mktemp -d --tmpdir profiledir.XXXXXX) # note, run this in a sub-shell so we don't pollute our