[oe-commits] Dexuan Cui : oe-init-build-env, scripts/oe-buildenv-internal: add error detecting for $BDIR

git version control git at git.openembedded.org
Tue Aug 2 13:33:00 UTC 2011


Module: openembedded-core.git
Branch: master
Commit: 651ccb3b031d9ccb8331505a51171372002230d9
URL:    http://git.openembedded.org/?p=openembedded-core.git&a=commit;h=651ccb3b031d9ccb8331505a51171372002230d9

Author: Dexuan Cui <dexuan.cui at intel.com>
Date:   Tue Aug  2 14:08:32 2011 +0800

oe-init-build-env, scripts/oe-buildenv-internal: add error detecting for $BDIR

[YOCTO #671]

"readlink -f" in Ubuntu 10.04 is buggy: it doesn't ignore a trailing / (e.g.,
"readlink -f /tmp/non-existent-dir/" returns nothing, but according to
http://www.gnu.org/s/coreutils/manual/coreutils.pdf it should do that --
hence we get bug 671. It seems Ubuntu 10.10 or even later Ubuntu 11.04,
and other Linux distributions(e.g., Open Suse 11.4) haven't such an issue.

So I think we should detect this and ask Ubuntu 10.04 users to avoid supply
a path with trailing slash here.

Moreever, I also add the detection of non-existent path, e.g.,
source oe-init-build-env /non-existent-dir/build
can be detected and we'll print an error msg.
And, if we get errors in oe-buildenv-internal, we should stop the script
and shouldn't further run.

Signed-off-by: Dexuan Cui <dexuan.cui at intel.com>
Signed-off-by: Richard Purdie <richard.purdie at linuxfoundation.org>

---

 oe-init-build-env            |    6 +++---
 scripts/oe-buildenv-internal |   13 +++++++++++--
 2 files changed, 14 insertions(+), 5 deletions(-)

diff --git a/oe-init-build-env b/oe-init-build-env
index 77332a7..cc30a3b 100755
--- a/oe-init-build-env
+++ b/oe-init-build-env
@@ -35,10 +35,10 @@ else
    fi
    OEROOT=`readlink -f "$OEROOT"`
    export OEROOT
-   . $OEROOT/scripts/oe-buildenv-internal
-   $OEROOT/scripts/oe-setup-builddir
+   . $OEROOT/scripts/oe-buildenv-internal && \
+        $OEROOT/scripts/oe-setup-builddir && \
+        [ -n "$BUILDDIR" ] && cd $BUILDDIR
    unset OEROOT
    unset BBPATH
-   [ -n "$BUILDDIR" ] && cd $BUILDDIR
 fi
 
diff --git a/scripts/oe-buildenv-internal b/scripts/oe-buildenv-internal
index c13fc40..117b0c5 100755
--- a/scripts/oe-buildenv-internal
+++ b/scripts/oe-buildenv-internal
@@ -21,7 +21,7 @@
 # It is assumed OEROOT is already defined when this is called
 if [ -z "$OEROOT" ]; then
     echo >&2 "Error: OEROOT is not defined!"
-    return
+    return 1
 fi
 
 if [ "x$BDIR" = "x" ]; then
@@ -29,6 +29,15 @@ if [ "x$BDIR" = "x" ]; then
         BDIR="build"
     else
         BDIR=`readlink -f "$1"`
+        if [ -z "$BDIR"  ]; then
+            if expr "$1" : '.*/$' >/dev/null; then
+                echo >&2 "Error: please remove any trailing / in the argument."
+            else
+                PARENTDIR=`dirname "$1"`
+                echo >&2 "Error: the directory $PARENTDIR doesn't exist?"
+            fi
+            return 1
+        fi
     fi
 fi
 if expr "$BDIR" : '/.*' > /dev/null ; then
@@ -45,7 +54,7 @@ BUILDDIR=`readlink -f "$BUILDDIR"`
 
 if ! (test -d "$BITBAKEDIR"); then
     echo >&2 "Error: The bitbake directory ($BITBAKEDIR) does not exist!  Please ensure a copy of bitbake exists at this location"
-    return
+    return 1
 fi
 
 PATH="${OEROOT}/scripts:$BITBAKEDIR/bin/:$PATH"





More information about the Openembedded-commits mailing list