diff options
author | Gary Thomas <gary@mlbassoc.com> | 2014-02-24 17:11:47 +0000 |
---|---|---|
committer | Richard Purdie <richard.purdie@linuxfoundation.org> | 2014-03-11 08:11:41 -0700 |
commit | 61e8fdba041c04be05805ed511f2e9dd66f4fdfb (patch) | |
tree | 3dfe72b225521382d0442be0b17d4284a22fc2a6 | |
parent | cdf447333243c0f683470b395eac1e1f9b3dbce0 (diff) | |
download | poky-61e8fdba041c04be05805ed511f2e9dd66f4fdfb.tar.gz |
oe-init-build-env: Improve script sourcing detection.
This script is only useful when sourced into a shell.
These changes improve the detection of this operation,
no matter how the script is referenced.
(From OE-Core rev: cac863e958a0c8fe0f8a84dc194273c699f0c40f)
Signed-off-by: Gary Thomas <gary@mlbassoc.com>
Signed-off-by: Saul Wold <sgw@linux.intel.com>
Signed-off-by: Richard Purdie <richard.purdie@linuxfoundation.org>
-rwxr-xr-x | oe-init-build-env | 42 |
1 files changed, 23 insertions, 19 deletions
diff --git a/oe-init-build-env b/oe-init-build-env index 8ef32f3d55..52495133fd 100755 --- a/oe-init-build-env +++ b/oe-init-build-env | |||
@@ -25,27 +25,31 @@ | |||
25 | # being sourced. To workaround the shell limitation use "set arg1" prior | 25 | # being sourced. To workaround the shell limitation use "set arg1" prior |
26 | # to sourcing this script. | 26 | # to sourcing this script. |
27 | # | 27 | # |
28 | if [ -z "$ZSH_NAME" ] && [ "x$0" = "x./oe-init-build-env" ]; then | 28 | if [ -n "$BASH_SOURCE" ]; then |
29 | echo "Error: This script needs to be sourced. Please run as '. ./oe-init-build-env'" | 29 | OEROOT="`dirname $BASH_SOURCE`" |
30 | elif [ -n "$ZSH_NAME" ]; then | ||
31 | OEROOT="`dirname $0`" | ||
30 | else | 32 | else |
31 | if [ -n "$BASH_SOURCE" ]; then | 33 | OEROOT="`pwd`" |
32 | OEROOT="`dirname $BASH_SOURCE`" | ||
33 | elif [ -n "$ZSH_NAME" ]; then | ||
34 | OEROOT="`dirname $0`" | ||
35 | else | ||
36 | OEROOT="`pwd`" | ||
37 | fi | ||
38 | if [ -n "$BBSERVER" ]; then | ||
39 | unset BBSERVER | ||
40 | fi | ||
41 | OEROOT=`readlink -f "$OEROOT"` | ||
42 | export OEROOT | ||
43 | . $OEROOT/scripts/oe-buildenv-internal && \ | ||
44 | $OEROOT/scripts/oe-setup-builddir && \ | ||
45 | [ -n "$BUILDDIR" ] && cd $BUILDDIR | ||
46 | unset OEROOT | ||
47 | unset BBPATH | ||
48 | fi | 34 | fi |
35 | if [ -n "$BBSERVER" ]; then | ||
36 | unset BBSERVER | ||
37 | fi | ||
38 | THIS_SCRIPT=$OEROOT/oe-init-build-env | ||
39 | |||
40 | if [ -z "$ZSH_NAME" ] && [ "$0" = "$THIS_SCRIPT" ]; then | ||
41 | echo "Error: This script needs to be sourced. Please run as '. $THIS_SCRIPT'" | ||
42 | exit 1 | ||
43 | fi | ||
44 | |||
45 | OEROOT=`readlink -f "$OEROOT"` | ||
46 | export OEROOT | ||
47 | . $OEROOT/scripts/oe-buildenv-internal && \ | ||
48 | $OEROOT/scripts/oe-setup-builddir && \ | ||
49 | [ -n "$BUILDDIR" ] && cd $BUILDDIR | ||
50 | unset OEROOT | ||
51 | unset BBPATH | ||
52 | unset THIS_SCRIPT | ||
49 | 53 | ||
50 | # Shutdown any bitbake server if the BBSERVER variable is not set | 54 | # Shutdown any bitbake server if the BBSERVER variable is not set |
51 | if [ -z "$BBSERVER" ] && [ -f bitbake.lock ] ; then | 55 | if [ -z "$BBSERVER" ] && [ -f bitbake.lock ] ; then |