[Fuego] [PATCH 05/29] functions: add is_on_sdk

Daniel Sangorrin daniel.sangorrin at toshiba.co.jp
Fri Jul 21 08:01:56 UTC 2017


Similar to is_on_target a test may want to know wheter certain
libraries are available on the SDK/Toolchain or not.

The function is vulnerable to race conditions because it uses
a fixed temporary file path. The same happens with is_on_target

Signed-off-by: Daniel Sangorrin <daniel.sangorrin at toshiba.co.jp>
---
 engine/scripts/functions.sh | 22 ++++++++++++++++++++++
 1 file changed, 22 insertions(+)

diff --git a/engine/scripts/functions.sh b/engine/scripts/functions.sh
index a225273..19936c2 100755
--- a/engine/scripts/functions.sh
+++ b/engine/scripts/functions.sh
@@ -716,3 +716,25 @@ function is_on_target {
  cmd "rm $tmpfile"
  rm -f $tmpfile # -f for tests running on the host
 }
+
+# check for a library on the SDK, and set a variable if it's present
+# $1 - the file (library) we want to search for in the SDK
+# $2 - variable to set the location (if the file is found)
+# $3 - (optional) set of paths joined by colons to look for on the SDK
+function is_on_sdk {
+    # FIXTHIS: race condition
+    tmpfile=$(mktemp /tmp/found_loc.XXXXXX)
+    touch $tmpfile
+    if [ -z "$3" ] ; then
+        find / -name "$1" | head -n 1 >$tmpfile
+    else
+        # split search path on colon
+        for d in $(echo "$3" | tr ":" "\n") ; do
+            echo "search $d"
+            find "$SDKROOT$d" -name "$1" | head -n 1 >$tmpfile
+        done
+    fi
+    LOCATION=$(head -n 1 $tmpfile)
+    export $2=$LOCATION
+    rm -f $tmpfile
+}
-- 
2.7.4




More information about the Fuego mailing list