From 813b4bc2422b0968bd8cf6786bce80fac5157797 Mon Sep 17 00:00:00 2001
From: James Slagle <jslagle@redhat.com>
Date: Fri, 30 May 2014 15:38:17 -0400
Subject: [PATCH] Check return code of element-info

Ensure the return code of element-info is actually checked by moving the
export IMAGE_ELEMENT to the subsequent line.

A recent change (Ic0a061995e2ae708c95a535cba6237bff58f7d93) exported the
IMAGE_ELEMENT variable. This caused the return code of element-info to not
actually be checked, since the export command is now checked instead and
almost always will return 0.

This caused a misleading error message when using diskimage-builder with an
unknown element since the script didn't exit when it should have:
$ bin/disk-image-create -a amd64 foobar vm
Building elements: base  foobar vm
ERROR: Element 'foobar' not found in 'bin/../elements'
Expanded element dependencies to:
Building in /var/tmp/image.DuIDY1lW
Please include at least one distribution root element.

Change-Id: I3d9c02bf0b1a4f320280185dd3fab0697d2c92f2
---
 lib/common-functions | 3 ++-
 1 file changed, 2 insertions(+), 1 deletion(-)

diff --git a/lib/common-functions b/lib/common-functions
index f3f73c74f..6bbceab6b 100644
--- a/lib/common-functions
+++ b/lib/common-functions
@@ -241,7 +241,8 @@ function arg_to_elements() {
   fi
   echo "Building elements: $IMAGE_ELEMENT"
 
-  export IMAGE_ELEMENT=$($SCRIPT_HOME/element-info --expand-dependencies $IMAGE_ELEMENT)
+  IMAGE_ELEMENT=$($SCRIPT_HOME/element-info --expand-dependencies $IMAGE_ELEMENT)
+  export IMAGE_ELEMENT
 
   echo "Expanded element dependencies to: $IMAGE_ELEMENT"
 }