aboutsummaryrefslogtreecommitdiffstats
path: root/tools
diff options
context:
space:
mode:
authorJo¶rgen Karlsson <jorgen.w.karlsson@ericsson.com>2015-11-10 14:55:00 +0100
committerJo¶rgen Karlsson <jorgen.w.karlsson@ericsson.com>2015-11-10 14:55:00 +0100
commiteb8320b2e924e22c20af49a0d37bee12417ede95 (patch)
treea08f819c7bcc4671f6ccf41629b9697b6f4ddb17 /tools
parent71413bb440af953d20a0dfc52ef710ea1618cd90 (diff)
Add cleanup trap to yardstick-img-modify
Fixes a problem with loopback devices not beeing detached when the image build fails. Change-Id: I3e422be4fb0157289a032c14700e184f58d544d9 Signed-off-by: Jo¶rgen Karlsson <jorgen.w.karlsson@ericsson.com>
Diffstat (limited to 'tools')
-rwxr-xr-xtools/yardstick-img-modify24
1 files changed, 23 insertions, 1 deletions
diff --git a/tools/yardstick-img-modify b/tools/yardstick-img-modify
index ee9a45780..33065627f 100755
--- a/tools/yardstick-img-modify
+++ b/tools/yardstick-img-modify
@@ -25,6 +25,7 @@
#
set -e
+set -x
die() {
echo "error: $1" >&2
@@ -117,13 +118,34 @@ cleanup() {
rm -rf $mountdir
}
-set -x
+exitcode=""
+error_trap()
+{
+ local rc=$?
+
+ set +e
+
+ if [ -z "$exitcode" ]; then
+ exitcode=$rc
+ fi
+
+ cleanup
+
+ echo "Image build failed with $exitcode"
+
+ exit $exitcode
+}
main() {
cleanup
+
+ trap "error_trap" EXIT SIGTERM
+
download
setup
modify
+
+ trap - EXIT SIGTERM
cleanup
echo "the modified image is found here: $imgfile"