diff --git a/bin/disk-image-create b/bin/disk-image-create index e70bc94f1..dc483fed9 100755 --- a/bin/disk-image-create +++ b/bin/disk-image-create @@ -106,7 +106,7 @@ function show_options () { echo " File types should be comma separated. VHD outputting requires the vhd-util" echo " executable be in your PATH. ACI outputting requires the ACI_MANIFEST " echo " environment variable be a path to a manifest file." - echo " -x -- turn on tracing (use -x -x for very detailed tracing)" + echo " -x -- turn on tracing (use -x -x for very detailed tracing)." echo " -u -- uncompressed; do not compress the image - larger but faster" echo " -c -- clear environment before starting work" echo " --checksum -- generate MD5 and SHA256 checksum files for the created image" @@ -165,6 +165,7 @@ function show_version() { fi } +DIB_DEBUG_TRACE=${DIB_DEBUG_TRACE:-0} INSTALL_PACKAGES="" IMAGE_TYPES=("qcow2") COMPRESS_IMAGE="true" @@ -186,7 +187,7 @@ while true ; do -t) IFS="," read -a IMAGE_TYPES <<< "$2"; export IMAGE_TYPES ; shift 2 ;; -h|--help) show_options; exit 0;; --version) show_version; exit 0;; - -x) shift; export DIB_DEBUG_TRACE=$(( $DIB_DEBUG_TRACE + 1 )); set -x;; + -x) shift; DIB_DEBUG_TRACE=$(( $DIB_DEBUG_TRACE + 1 ));; -u) shift; export COMPRESS_IMAGE="";; -c) shift ; export CLEAR_ENV=1;; -n) shift; export SKIP_BASE="1";; @@ -209,6 +210,8 @@ while true ; do esac done +export DIB_DEBUG_TRACE + export DIB_IMAGE_CACHE=${DIB_IMAGE_CACHE:-~/.cache/image-create} mkdir -p $DIB_IMAGE_CACHE @@ -228,7 +231,6 @@ function _ps4 { export -f _ps4 export PS4='+ $(_ps4): ' - source $_LIB/img-defaults source $_LIB/common-functions source $_LIB/img-functions @@ -245,6 +247,11 @@ if [ -z "$*" ]; then fi arg_to_elements "$@" +# start tracing after most boilerplate +if [ ${DIB_DEBUG_TRACE} -gt 0 ]; then + set -x +fi + if [ "${#IMAGE_TYPES[@]}" = "1" ]; then export IMAGE_NAME=${IMAGE_NAME%%\.${IMAGE_TYPES[0]}} fi @@ -346,8 +353,8 @@ fi unmount_image mv $TMP_BUILD_DIR/mnt $TMP_BUILD_DIR/built -# save xtrace state, as we want to turn it off to avoid spamming the -# logs with du output below. +# save xtrace state, as we always want to turn it off to avoid +# spamming the logs with du output below. xtrace=$(set +o | grep xtrace) # temp file for holding du output diff --git a/elements/pkg-map/extra-data.d/10-create-pkg-map-dir b/elements/pkg-map/extra-data.d/10-create-pkg-map-dir index b3b5d9315..74a526196 100755 --- a/elements/pkg-map/extra-data.d/10-create-pkg-map-dir +++ b/elements/pkg-map/extra-data.d/10-create-pkg-map-dir @@ -1,17 +1,21 @@ #!/bin/bash -if [ ${DIB_DEBUG_TRACE:-1} -gt 0 ]; then +if [ ${DIB_DEBUG_TRACE:-1} -gt 1 ]; then set -x fi set -eu set -o pipefail +echo "Copying pkg-map files to $TMP_MOUNT_PATH/usr/share/pkg-map" + sudo mkdir -p $TMP_MOUNT_PATH/usr/share/pkg-map/ for ELEMENT in $IMAGE_ELEMENT ; do for DIR in ${ELEMENTS_PATH//:/ }; do if [ -f "$DIR/$ELEMENT/pkg-map" ]; then - sudo cp "$DIR/$ELEMENT/pkg-map" "$TMP_MOUNT_PATH/usr/share/pkg-map/$ELEMENT" + echo "Deploying pkg-map $DIR/$ELEMENT/pkg-map" + sudo cp "$DIR/$ELEMENT/pkg-map" \ + "$TMP_MOUNT_PATH/usr/share/pkg-map/$ELEMENT" fi done done diff --git a/lib/common-functions b/lib/common-functions index 653aee4fd..b0094b5a2 100644 --- a/lib/common-functions +++ b/lib/common-functions @@ -77,6 +77,7 @@ function copy_hooks_not_overwrite () { test -d $TMP_HOOKS_PATH/$_DIR || mkdir $TMP_HOOKS_PATH/$_DIR for _HOOK in $(ls $1); do if [ ! -f $TMP_HOOKS_PATH/$_DIR/$_HOOK ]; then + echo "Copying hooks $1/$_HOOK" cp -t $TMP_HOOKS_PATH/$_DIR -a $1/$_HOOK else echo "There is a duplicated hook in your elements: $_ELEMENT/$_DIR/$_HOOK" @@ -86,7 +87,12 @@ function copy_hooks_not_overwrite () { } function generate_hooks () { + local xtrace + xtrace=$(set +o | grep xtrace) + if [ ${DIB_DEBUG_TRACE} -lt 2 ]; then set +o xtrace; fi + mkdir -p $TMP_HOOKS_PATH + echo "Deploying hooks to $TMP_HOOKS_PATH" for _ELEMENT in $IMAGE_ELEMENT ; do for dir in ${ELEMENTS_PATH//:/ } ; do [ -d $dir/$_ELEMENT ] || continue @@ -94,11 +100,14 @@ function generate_hooks () { copy_hooks_not_overwrite $_DIR done for _FILE in $(find $dir/$_ELEMENT -follow -maxdepth 1 -type f); do + echo "Copy hook $_FILE" cp -t $TMP_HOOKS_PATH -a $_FILE done break done done + + $xtrace } # Call the supplied break-in routine if the named point is listed in the break @@ -212,6 +221,7 @@ function run_d() { check_element check_break before-$1 ${break_cmd:-bash} if [ -d ${TMP_HOOKS_PATH}/$1.d ] ; then + echo "Running hooks from ${TMP_HOOKS_PATH}/$1.d" if [ -n "$2" ]; then dib-run-parts ${TMP_HOOKS_PATH}/$1.d | tee $2 if [[ ${PIPESTATUS[0]} != 0 ]]; then