From 7550d25db068b841134895d69aef1c004aeb1419 Mon Sep 17 00:00:00 2001 From: Ian Wienand Date: Fri, 27 May 2016 09:25:22 +1000 Subject: [PATCH] Export die() function I realised I'd been using die() in a few places assuming it was available, but it wasn't exported. I guess it didn't matter because whatever was wrong, we were failing anyway :) This exports the function to make it available to sub-processes, which should remove the need to source it as done in several places. Change-Id: I7b9a5a6db406e160099b6ed9fde80455ae227327 --- elements/base/extra-data.d/50-store-build-settings | 1 - elements/local-config/extra-data.d/62-ssh-key | 1 - .../block-device.d/10-partitioning-sfdisk | 1 - elements/vm/block-device.d/10-partition | 1 - lib/die | 9 +++++---- 5 files changed, 5 insertions(+), 8 deletions(-) diff --git a/elements/base/extra-data.d/50-store-build-settings b/elements/base/extra-data.d/50-store-build-settings index 4ddd8d68..0ba87371 100755 --- a/elements/base/extra-data.d/50-store-build-settings +++ b/elements/base/extra-data.d/50-store-build-settings @@ -7,7 +7,6 @@ fi set -eu set -o pipefail -source $_LIB/die [ -n "$TMP_HOOKS_PATH" ] || die "Temp hook path not set" echo "$DIB_ENV" > $TMP_HOOKS_PATH/dib_environment diff --git a/elements/local-config/extra-data.d/62-ssh-key b/elements/local-config/extra-data.d/62-ssh-key index 1254513a..3a2c8e52 100755 --- a/elements/local-config/extra-data.d/62-ssh-key +++ b/elements/local-config/extra-data.d/62-ssh-key @@ -8,7 +8,6 @@ fi set -eu set -o pipefail -source $_LIB/die [ -n "$TMP_HOOKS_PATH" ] || die "Temp hook path not set" if [ -e ~/.ssh/authorized_keys ]; then diff --git a/elements/partitioning-sfdisk/block-device.d/10-partitioning-sfdisk b/elements/partitioning-sfdisk/block-device.d/10-partitioning-sfdisk index 447f23a0..06b60cf8 100755 --- a/elements/partitioning-sfdisk/block-device.d/10-partitioning-sfdisk +++ b/elements/partitioning-sfdisk/block-device.d/10-partitioning-sfdisk @@ -7,7 +7,6 @@ set -eu set -o pipefail # sanity checks -source $_LIB/die [ -n "$IMAGE_BLOCK_DEVICE" ] || die "Image block device not set" # execute sfdisk with the given partitioning schema diff --git a/elements/vm/block-device.d/10-partition b/elements/vm/block-device.d/10-partition index df0732ed..f800eb8f 100755 --- a/elements/vm/block-device.d/10-partition +++ b/elements/vm/block-device.d/10-partition @@ -6,7 +6,6 @@ fi set -eu set -o pipefail -source $_LIB/die [ -n "$IMAGE_BLOCK_DEVICE" ] || die "Image block device not set" # Create 2 partitions for PPC, one for PReP boot and other for root diff --git a/lib/die b/lib/die index 68a61185..e2dde986 100644 --- a/lib/die +++ b/lib/die @@ -1,13 +1,13 @@ #!/bin/bash # Copyright 2012 Hewlett-Packard Development Company, L.P. # All Rights Reserved. -# +# # Licensed under the Apache License, Version 2.0 (the "License"); you may # not use this file except in compliance with the License. You may obtain # a copy of the License at -# +# # http://www.apache.org/licenses/LICENSE-2.0 -# +# # Unless required by applicable law or agreed to in writing, software # distributed under the License is distributed on an "AS IS" BASIS, WITHOUT # WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. See the @@ -16,10 +16,11 @@ # Prints "message" and exits # Usage: die "message" -function die() { +function die { local exitcode=$? set +o xtrace echo $@ exit $exitcode } +export -f die