diff --git a/bin/dib-lint b/bin/dib-lint index f75c1ccd..c58865e5 100755 --- a/bin/dib-lint +++ b/bin/dib-lint @@ -151,6 +151,12 @@ for i in $(find elements -type f \ fi fi + # check that environment files don't "set -x" + if [[ "$i" =~ (environment.d) ]]; then + if grep -q "set -x" $i; then + error "Environment file $i should not set tracing" + fi + fi # check that sudo calls in phases run outside the chroot look # "safe"; meaning that they seem to operate within the chroot diff --git a/doc/source/developer/developing_elements.rst b/doc/source/developer/developing_elements.rst index aa536440..fa6c24b6 100644 --- a/doc/source/developer/developing_elements.rst +++ b/doc/source/developer/developing_elements.rst @@ -172,11 +172,12 @@ the image as executable files. Environment Variables ^^^^^^^^^^^^^^^^^^^^^ -To set environment variables for other hooks, add a file to your element -``environment.d``. - -This directory contains bash script snippets that are sourced before running -scripts in each phase. +To set environment variables for other hooks, add a file to your +element ``environment.d``. This directory contains bash script +snippets that are sourced before running scripts in each phase. Note +that because environment includes are sourced together, they should +not set global flags like ``set -x`` because they will affect all +preceeding imports. DIB exposes an internal ``$IMAGE_ELEMENT`` variable which provides elements access to the full set of elements that are included in the image build. This diff --git a/elements/centos/environment.d/00-bootloader.bash b/elements/centos/environment.d/00-bootloader.bash index 6478bc96..d406155d 100755 --- a/elements/centos/environment.d/00-bootloader.bash +++ b/elements/centos/environment.d/00-bootloader.bash @@ -1,9 +1 @@ -#!/bin/bash - -if [ "${DIB_DEBUG_TRACE:-0}" -gt 0 ]; then - set -x -fi -set -eu -set -o pipefail - export DIB_EXTLINUX=1 diff --git a/elements/manifests/environment.d/14-manifests b/elements/manifests/environment.d/14-manifests index c2ae96dc..a125a6f2 100755 --- a/elements/manifests/environment.d/14-manifests +++ b/elements/manifests/environment.d/14-manifests @@ -1,5 +1,3 @@ -#!/bin/bash -# # Copyright 2014 Hewlett-Packard Development Company, L.P. # # Licensed under the Apache License, Version 2.0 (the "License"); you may @@ -15,11 +13,5 @@ # under the License. # -if [ ${DIB_DEBUG_TRACE:-0} -gt 0 ]; then - set -x -fi -set -eu -set -o pipefail - export DIB_MANIFEST_IMAGE_DIR=${DIB_MANIFEST_IMAGE_DIR:-/etc/dib-manifests} export DIB_MANIFEST_SAVE_DIR=${DIB_MANIFEST_SAVE_DIR:-${IMAGE_NAME}.d/}