diff options
author | Peter Kjellerstedt <pkj@axis.com> | 2016-03-15 15:41:02 +0100 |
---|---|---|
committer | Richard Purdie <richard.purdie@linuxfoundation.org> | 2016-03-20 23:12:30 +0000 |
commit | 16fb9b80e3887b053cb980317d4f28228348f689 (patch) | |
tree | d882340534a7b83147008d2f2dd4688648a391c6 | |
parent | 3173979532aa57fe39479df819884430adb47b63 (diff) | |
download | poky-16fb9b80e3887b053cb980317d4f28228348f689.tar.gz |
oe-init-build-env*: Allow $OEROOT to be predefined
The current implementation of oe-init-build-env and
oe-init-build-env-memres requires that they are sourced from the
directory that will be known as $OEROOT. This makes it hard to write a
wrapper script with the same name as the original OE script which,
e.g., sources the original OE script from a sub-directory.
With this change, $OEROOT can be predefined when oe-init-build-env or
oe-init-build-env-memres is sourced, allowing the original OE scripts
to be anywhere.
(From OE-Core rev: 3327e2a9222004d8ac7974cb1d9fe77c81176cfc)
Signed-off-by: Peter Kjellerstedt <peter.kjellerstedt@axis.com>
Signed-off-by: Ross Burton <ross.burton@intel.com>
Signed-off-by: Richard Purdie <richard.purdie@linuxfoundation.org>
-rwxr-xr-x | oe-init-build-env | 16 | ||||
-rwxr-xr-x | oe-init-build-env-memres | 16 |
2 files changed, 18 insertions, 14 deletions
diff --git a/oe-init-build-env b/oe-init-build-env index b7e29188b0..7b922b302a 100755 --- a/oe-init-build-env +++ b/oe-init-build-env | |||
@@ -26,30 +26,32 @@ | |||
26 | # to sourcing this script. | 26 | # to sourcing this script. |
27 | # | 27 | # |
28 | if [ -n "$BASH_SOURCE" ]; then | 28 | if [ -n "$BASH_SOURCE" ]; then |
29 | OEROOT="`dirname $BASH_SOURCE`" | 29 | THIS_SCRIPT=$BASH_SOURCE |
30 | elif [ -n "$ZSH_NAME" ]; then | 30 | elif [ -n "$ZSH_NAME" ]; then |
31 | OEROOT="`dirname $0`" | 31 | THIS_SCRIPT=$0 |
32 | else | 32 | else |
33 | OEROOT="`pwd`" | 33 | THIS_SCRIPT="$(pwd)/oe-init-build-env" |
34 | fi | 34 | fi |
35 | if [ -n "$BBSERVER" ]; then | 35 | if [ -n "$BBSERVER" ]; then |
36 | unset BBSERVER | 36 | unset BBSERVER |
37 | fi | 37 | fi |
38 | THIS_SCRIPT=$OEROOT/oe-init-build-env | ||
39 | 38 | ||
40 | if [ -z "$ZSH_NAME" ] && [ "$0" = "$THIS_SCRIPT" ]; then | 39 | if [ -z "$ZSH_NAME" ] && [ "$0" = "$THIS_SCRIPT" ]; then |
41 | echo "Error: This script needs to be sourced. Please run as '. $THIS_SCRIPT'" | 40 | echo "Error: This script needs to be sourced. Please run as '. $THIS_SCRIPT'" |
42 | exit 1 | 41 | exit 1 |
43 | fi | 42 | fi |
44 | 43 | ||
45 | OEROOT=`readlink -f "$OEROOT"` | 44 | if [ -z "$OEROOT" ]; then |
45 | OEROOT=$(dirname "$THIS_SCRIPT") | ||
46 | OEROOT=$(readlink -f "$OEROOT") | ||
47 | fi | ||
48 | unset THIS_SCRIPT | ||
49 | |||
46 | export OEROOT | 50 | export OEROOT |
47 | . $OEROOT/scripts/oe-buildenv-internal && \ | 51 | . $OEROOT/scripts/oe-buildenv-internal && \ |
48 | TEMPLATECONF="$TEMPLATECONF" $OEROOT/scripts/oe-setup-builddir && \ | 52 | TEMPLATECONF="$TEMPLATECONF" $OEROOT/scripts/oe-setup-builddir && \ |
49 | [ -n "$BUILDDIR" ] && cd "$BUILDDIR" | 53 | [ -n "$BUILDDIR" ] && cd "$BUILDDIR" |
50 | unset OEROOT | 54 | unset OEROOT |
51 | unset BBPATH | ||
52 | unset THIS_SCRIPT | ||
53 | 55 | ||
54 | # Shutdown any bitbake server if the BBSERVER variable is not set | 56 | # Shutdown any bitbake server if the BBSERVER variable is not set |
55 | if [ -z "$BBSERVER" ] && [ -f bitbake.lock ] ; then | 57 | if [ -z "$BBSERVER" ] && [ -f bitbake.lock ] ; then |
diff --git a/oe-init-build-env-memres b/oe-init-build-env-memres index c1dc4fe3ef..092d4fe081 100755 --- a/oe-init-build-env-memres +++ b/oe-init-build-env-memres | |||
@@ -34,30 +34,32 @@ else | |||
34 | fi | 34 | fi |
35 | 35 | ||
36 | if [ -n "$BASH_SOURCE" ]; then | 36 | if [ -n "$BASH_SOURCE" ]; then |
37 | OEROOT="`dirname $BASH_SOURCE`" | 37 | THIS_SCRIPT=$BASH_SOURCE |
38 | elif [ -n "$ZSH_NAME" ]; then | 38 | elif [ -n "$ZSH_NAME" ]; then |
39 | OEROOT="`dirname $0`" | 39 | THIS_SCRIPT=$0 |
40 | else | 40 | else |
41 | OEROOT="`pwd`" | 41 | THIS_SCRIPT="$(pwd)/oe-init-build-env" |
42 | fi | 42 | fi |
43 | if [ -n "$BBSERVER" ]; then | 43 | if [ -n "$BBSERVER" ]; then |
44 | unset BBSERVER | 44 | unset BBSERVER |
45 | fi | 45 | fi |
46 | 46 | ||
47 | THIS_SCRIPT=$OEROOT/oe-init-build-env-memres | ||
48 | if [ -z "$ZSH_NAME" ] && [ "x$0" = "x$THIS_SCRIPT" ]; then | 47 | if [ -z "$ZSH_NAME" ] && [ "x$0" = "x$THIS_SCRIPT" ]; then |
49 | echo "Error: This script needs to be sourced. Please run as '. $THIS_SCRIPT'" | 48 | echo "Error: This script needs to be sourced. Please run as '. $THIS_SCRIPT'" |
50 | exit 1 | 49 | exit 1 |
51 | fi | 50 | fi |
52 | 51 | ||
53 | OEROOT=`readlink -f "$OEROOT"` | 52 | if [ -z "$OEROOT" ]; then |
53 | OEROOT=$(dirname "$THIS_SCRIPT") | ||
54 | OEROOT=$(readlink -f "$OEROOT") | ||
55 | fi | ||
56 | unset THIS_SCRIPT | ||
57 | |||
54 | export OEROOT | 58 | export OEROOT |
55 | . $OEROOT/scripts/oe-buildenv-internal && \ | 59 | . $OEROOT/scripts/oe-buildenv-internal && \ |
56 | $OEROOT/scripts/oe-setup-builddir && \ | 60 | $OEROOT/scripts/oe-setup-builddir && \ |
57 | [ -n "$BUILDDIR" ] && cd $BUILDDIR | 61 | [ -n "$BUILDDIR" ] && cd $BUILDDIR |
58 | unset OEROOT | 62 | unset OEROOT |
59 | unset BBPATH | ||
60 | unset THIS_SCRIPT | ||
61 | 63 | ||
62 | res=1 | 64 | res=1 |
63 | if [ -e bitbake.lock ] && grep : bitbake.lock > /dev/null ; then | 65 | if [ -e bitbake.lock ] && grep : bitbake.lock > /dev/null ; then |