From 33cd0fb40fbb8979aad771f0497f0ddcb00e7a2f Mon Sep 17 00:00:00 2001 From: Antoine Musso Date: Tue, 1 Sep 2015 22:49:25 +0200 Subject: [PATCH] dib-run-parts: make cp to target root more robust The dib-run-parts/root.d/90-base-dib-run-parts script would mysteriously fail whenever the dib-run-parts is not in the path. The install commands complaining with: install: missing destination file operand after '/tmp/image.ILFTBYVy/mnt/usr/local/bin/dib-run-parts' The reason is chaining a command in exec bypasses set -e. For example: exec /bin/ls $(which doesnotexist) Will works and continue. Handle the which lookup in a variable to have the script abort immediately whenever dib-run-parts is not found. Left an inline comment to make sure the fix is kept around in the future. Signed-off-by: Dan Duvall Change-Id: Ibb5d7342b0d06483b84f9dd567e1cc0bf90f194e --- elements/dib-run-parts/root.d/90-base-dib-run-parts | 6 +++++- 1 file changed, 5 insertions(+), 1 deletion(-) diff --git a/elements/dib-run-parts/root.d/90-base-dib-run-parts b/elements/dib-run-parts/root.d/90-base-dib-run-parts index fb4c4594f..c85dc82af 100755 --- a/elements/dib-run-parts/root.d/90-base-dib-run-parts +++ b/elements/dib-run-parts/root.d/90-base-dib-run-parts @@ -6,6 +6,10 @@ fi set -eu set -o pipefail +# Abort early if dib-run-parts is not found to prevent a meaningless +# error message from the subsequent install command +DIB_RUN_PARTS=$(which dib-run-parts) + exec sudo install -m 0755 -o root -g root -D \ - $(which dib-run-parts) \ + $DIB_RUN_PARTS \ $TARGET_ROOT/usr/local/bin/dib-run-parts