All of lore.kernel.org
 help / color / mirror / Atom feed
* [PATCHv2 0/7] Improve oe-init-build-env/-memres
@ 2016-03-17 11:14 Peter Kjellerstedt
  2016-03-17 11:14 ` [PATCHv2 1/7] oe-init-build-env*: Allow $OEROOT to be predefined Peter Kjellerstedt
                   ` (7 more replies)
  0 siblings, 8 replies; 10+ messages in thread
From: Peter Kjellerstedt @ 2016-03-17 11:14 UTC (permalink / raw)
  To: openembedded-core

I started looking at the oe-init-build-env (and
oe-init-build-env-memres) scripts since I wanted to add support for
specifying $OEROOT from the outside. This is because we want to wrap
those scripts with our own while keeping the official names (so anyone
reading the official Poky documentation will not be too confused).

While fixing the above, I had noticed a number of inconsistencies in
the scripts, so I continued to fix those. I also improved the code
that adds paths to $PATH, and the code that adds variable names to
$BB_ENV_EXTRAWHITE.

New in version 2:

* Make sure oe-init-build-env and oe-init-build-env-memres actually
  return failures from other scripts they source and call.

//Peter

The following changes since commit 8debfea81e69d038bd2d56314b272cb74f5582ed:

  local.conf.sample: Disable prelink by default (2016-03-13 22:09:05 +0000)

are available in the git repository at:

  git://git.yoctoproject.org/poky-contrib pkj/oe-init-build-env
  http://git.yoctoproject.org/cgit.cgi/poky-contrib/log/?h=pkj/oe-init-build-env

Peter Kjellerstedt (7):
  oe-init-build-env*: Allow $OEROOT to be predefined
  oe-init-build-env*: Update/correct comment about specifying arguments
  oe-init-build-env*: Remove unnecessary differences between the scripts
  oe-init-build-env*: Make them actually return failures
  oe-buildenv-internal: Add paths to $PATH individually
  oe-buildenv-internal: Add variables individually to BB_ENV_EXTRAWHITE
  oe-buildenv-internal: Some clean up

 oe-init-build-env            | 51 +++++++++++++++------------
 oe-init-build-env-memres     | 60 ++++++++++++++++++--------------
 scripts/oe-buildenv-internal | 83 ++++++++++++++++++++++++++++----------------
 3 files changed, 114 insertions(+), 80 deletions(-)

-- 
2.1.0



^ permalink raw reply	[flat|nested] 10+ messages in thread

* [PATCHv2 1/7] oe-init-build-env*: Allow $OEROOT to be predefined
  2016-03-17 11:14 [PATCHv2 0/7] Improve oe-init-build-env/-memres Peter Kjellerstedt
@ 2016-03-17 11:14 ` Peter Kjellerstedt
  2016-03-17 11:14 ` [PATCHv2 2/7] oe-init-build-env*: Update/correct comment about specifying arguments Peter Kjellerstedt
                   ` (6 subsequent siblings)
  7 siblings, 0 replies; 10+ messages in thread
From: Peter Kjellerstedt @ 2016-03-17 11:14 UTC (permalink / raw)
  To: openembedded-core

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.

Signed-off-by: Peter Kjellerstedt <peter.kjellerstedt@axis.com>
---
 oe-init-build-env        | 16 +++++++++-------
 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 b7e2918..7b922b3 100755
--- a/oe-init-build-env
+++ b/oe-init-build-env
@@ -26,30 +26,32 @@
 # to sourcing this script.
 #
 if [ -n "$BASH_SOURCE" ]; then
-   OEROOT="`dirname $BASH_SOURCE`"
+    THIS_SCRIPT=$BASH_SOURCE
 elif [ -n "$ZSH_NAME" ]; then
-   OEROOT="`dirname $0`"
+    THIS_SCRIPT=$0
 else
-   OEROOT="`pwd`"
+    THIS_SCRIPT="$(pwd)/oe-init-build-env"
 fi
 if [ -n "$BBSERVER" ]; then
    unset BBSERVER
 fi
-THIS_SCRIPT=$OEROOT/oe-init-build-env
 
 if [ -z "$ZSH_NAME" ] && [ "$0" = "$THIS_SCRIPT" ]; then
    echo "Error: This script needs to be sourced. Please run as '. $THIS_SCRIPT'"
    exit 1
 fi
 
-OEROOT=`readlink -f "$OEROOT"`
+if [ -z "$OEROOT" ]; then
+    OEROOT=$(dirname "$THIS_SCRIPT")
+    OEROOT=$(readlink -f "$OEROOT")
+fi
+unset THIS_SCRIPT
+
 export OEROOT
 . $OEROOT/scripts/oe-buildenv-internal && \
      TEMPLATECONF="$TEMPLATECONF" $OEROOT/scripts/oe-setup-builddir && \
      [ -n "$BUILDDIR" ] && cd "$BUILDDIR"
 unset OEROOT
-unset BBPATH
-unset THIS_SCRIPT
 
 # Shutdown any bitbake server if the BBSERVER variable is not set
 if [ -z "$BBSERVER" ] && [ -f bitbake.lock ] ; then
diff --git a/oe-init-build-env-memres b/oe-init-build-env-memres
index c1dc4fe..092d4fe 100755
--- a/oe-init-build-env-memres
+++ b/oe-init-build-env-memres
@@ -34,30 +34,32 @@ else
 fi
 
 if [ -n "$BASH_SOURCE" ]; then
-  OEROOT="`dirname $BASH_SOURCE`"
+    THIS_SCRIPT=$BASH_SOURCE
 elif [ -n "$ZSH_NAME" ]; then
-  OEROOT="`dirname $0`"
+    THIS_SCRIPT=$0
 else
-  OEROOT="`pwd`"
+    THIS_SCRIPT="$(pwd)/oe-init-build-env"
 fi
 if [ -n "$BBSERVER" ]; then
   unset BBSERVER
 fi
 
-THIS_SCRIPT=$OEROOT/oe-init-build-env-memres
 if [ -z "$ZSH_NAME" ] && [ "x$0" = "x$THIS_SCRIPT" ]; then
    echo "Error: This script needs to be sourced. Please run as '. $THIS_SCRIPT'"
    exit 1
 fi
 
-OEROOT=`readlink -f "$OEROOT"`
+if [ -z "$OEROOT" ]; then
+    OEROOT=$(dirname "$THIS_SCRIPT")
+    OEROOT=$(readlink -f "$OEROOT")
+fi
+unset THIS_SCRIPT
+
 export OEROOT
 . $OEROOT/scripts/oe-buildenv-internal && \
     $OEROOT/scripts/oe-setup-builddir && \
     [ -n "$BUILDDIR" ] && cd $BUILDDIR
 unset OEROOT
-unset BBPATH
-unset THIS_SCRIPT
 
 res=1
 if [ -e bitbake.lock ] && grep : bitbake.lock > /dev/null ; then
-- 
2.1.0



^ permalink raw reply related	[flat|nested] 10+ messages in thread

* [PATCHv2 2/7] oe-init-build-env*: Update/correct comment about specifying arguments
  2016-03-17 11:14 [PATCHv2 0/7] Improve oe-init-build-env/-memres Peter Kjellerstedt
  2016-03-17 11:14 ` [PATCHv2 1/7] oe-init-build-env*: Allow $OEROOT to be predefined Peter Kjellerstedt
@ 2016-03-17 11:14 ` Peter Kjellerstedt
  2016-03-17 11:14 ` [PATCHv2 3/7] oe-init-build-env*: Remove unnecessary differences between the scripts Peter Kjellerstedt
                   ` (5 subsequent siblings)
  7 siblings, 0 replies; 10+ messages in thread
From: Peter Kjellerstedt @ 2016-03-17 11:14 UTC (permalink / raw)
  To: openembedded-core

Signed-off-by: Peter Kjellerstedt <peter.kjellerstedt@axis.com>
---
 oe-init-build-env        | 8 ++++----
 oe-init-build-env-memres | 8 ++++----
 2 files changed, 8 insertions(+), 8 deletions(-)

diff --git a/oe-init-build-env b/oe-init-build-env
index 7b922b3..fa9eacd 100755
--- a/oe-init-build-env
+++ b/oe-init-build-env
@@ -19,11 +19,11 @@
 # Foundation, Inc., 59 Temple Place, Suite 330, Boston, MA  02111-1307  USA
 
 #
-# Normally this is called as '. ./oe-init-build-env builddir'
+# Normally this is called as '. ./oe-init-build-env <builddir>'
 #
-# This works in most shells (not dash), but not all of them pass arg1 when
-# being sourced.   To workaround the shell limitation use "set arg1" prior 
-# to sourcing this script.
+# This works in most shells (not dash), but not all of them pass the arguments
+# when being sourced.  To workaround the shell limitation use "set <builddir>"
+# prior to sourcing this script.
 #
 if [ -n "$BASH_SOURCE" ]; then
     THIS_SCRIPT=$BASH_SOURCE
diff --git a/oe-init-build-env-memres b/oe-init-build-env-memres
index 092d4fe..41c09d8 100755
--- a/oe-init-build-env-memres
+++ b/oe-init-build-env-memres
@@ -19,11 +19,11 @@
 # Foundation, Inc., 59 Temple Place, Suite 330, Boston, MA  02111-1307  USA
 
 #
-# Normally this is called as '. ./oe-init-build-env builddir <portnumber> <builddir>'
+# Normally this is called as '. ./oe-init-build-env-memres <portnumber> <builddir>'
 #
-# This works in most shells (not dash), but not all of them pass arg1 when
-# being sourced.   To workaround the shell limitation use "set arg1" prior 
-# to sourcing this script.
+# This works in most shells (not dash), but not all of them pass the arguments
+# when being sourced.  To workaround the shell limitation use "set <portnumber>
+# <builddir>" prior to sourcing this script.
 #
 if [ -z "$1" ]; then
     echo "No port specified, using dynamically selected port"
-- 
2.1.0



^ permalink raw reply related	[flat|nested] 10+ messages in thread

* [PATCHv2 3/7] oe-init-build-env*: Remove unnecessary differences between the scripts
  2016-03-17 11:14 [PATCHv2 0/7] Improve oe-init-build-env/-memres Peter Kjellerstedt
  2016-03-17 11:14 ` [PATCHv2 1/7] oe-init-build-env*: Allow $OEROOT to be predefined Peter Kjellerstedt
  2016-03-17 11:14 ` [PATCHv2 2/7] oe-init-build-env*: Update/correct comment about specifying arguments Peter Kjellerstedt
@ 2016-03-17 11:14 ` Peter Kjellerstedt
  2016-03-17 11:14 ` [PATCHv2 4/7] oe-init-build-env*: Make them actually return failures Peter Kjellerstedt
                   ` (4 subsequent siblings)
  7 siblings, 0 replies; 10+ messages in thread
From: Peter Kjellerstedt @ 2016-03-17 11:14 UTC (permalink / raw)
  To: openembedded-core

While at it, also fix:
* consistent indentation (four spaces)
* unset temporary variables
* use $(...) instead of `...`

Signed-off-by: Peter Kjellerstedt <peter.kjellerstedt@axis.com>
---
 oe-init-build-env        | 21 ++++++++++-----------
 oe-init-build-env-memres | 30 +++++++++++++++---------------
 2 files changed, 25 insertions(+), 26 deletions(-)

diff --git a/oe-init-build-env b/oe-init-build-env
index fa9eacd..0b4df1b 100755
--- a/oe-init-build-env
+++ b/oe-init-build-env
@@ -33,12 +33,12 @@ else
     THIS_SCRIPT="$(pwd)/oe-init-build-env"
 fi
 if [ -n "$BBSERVER" ]; then
-   unset BBSERVER
+    unset BBSERVER
 fi
 
 if [ -z "$ZSH_NAME" ] && [ "$0" = "$THIS_SCRIPT" ]; then
-   echo "Error: This script needs to be sourced. Please run as '. $THIS_SCRIPT'"
-   exit 1
+    echo "Error: This script needs to be sourced. Please run as '. $THIS_SCRIPT'"
+    exit 1
 fi
 
 if [ -z "$OEROOT" ]; then
@@ -49,16 +49,15 @@ unset THIS_SCRIPT
 
 export OEROOT
 . $OEROOT/scripts/oe-buildenv-internal && \
-     TEMPLATECONF="$TEMPLATECONF" $OEROOT/scripts/oe-setup-builddir && \
-     [ -n "$BUILDDIR" ] && cd "$BUILDDIR"
+    TEMPLATECONF="$TEMPLATECONF" $OEROOT/scripts/oe-setup-builddir && \
+    [ -n "$BUILDDIR" ] && cd "$BUILDDIR"
 unset OEROOT
 
 # Shutdown any bitbake server if the BBSERVER variable is not set
-if [ -z "$BBSERVER" ] && [ -f bitbake.lock ] ; then
-    grep ":" bitbake.lock > /dev/null && BBSERVER=`cat bitbake.lock` bitbake --status-only
-    if [ $? = 0 ] ; then
-	echo "Shutting down bitbake memory resident server with bitbake -m"
-	BBSERVER=`cat bitbake.lock` bitbake -m
+if [ -z "$BBSERVER" ] && [ -f bitbake.lock ]; then
+    grep ":" bitbake.lock > /dev/null && BBSERVER=$(cat bitbake.lock) bitbake --status-only
+    if [ $? = 0 ]; then
+        echo "Shutting down bitbake memory resident server with bitbake -m"
+        BBSERVER=$(cat bitbake.lock) bitbake -m
     fi
 fi
-
diff --git a/oe-init-build-env-memres b/oe-init-build-env-memres
index 41c09d8..9d393f5 100755
--- a/oe-init-build-env-memres
+++ b/oe-init-build-env-memres
@@ -41,12 +41,12 @@ else
     THIS_SCRIPT="$(pwd)/oe-init-build-env"
 fi
 if [ -n "$BBSERVER" ]; then
-  unset BBSERVER
+    unset BBSERVER
 fi
 
-if [ -z "$ZSH_NAME" ] && [ "x$0" = "x$THIS_SCRIPT" ]; then
-   echo "Error: This script needs to be sourced. Please run as '. $THIS_SCRIPT'"
-   exit 1
+if [ -z "$ZSH_NAME" ] && [ "$0" = "$THIS_SCRIPT" ]; then
+    echo "Error: This script needs to be sourced. Please run as '. $THIS_SCRIPT'"
+    exit 1
 fi
 
 if [ -z "$OEROOT" ]; then
@@ -57,30 +57,30 @@ unset THIS_SCRIPT
 
 export OEROOT
 . $OEROOT/scripts/oe-buildenv-internal && \
-    $OEROOT/scripts/oe-setup-builddir && \
-    [ -n "$BUILDDIR" ] && cd $BUILDDIR
+    TEMPLATECONF="$TEMPLATECONF" $OEROOT/scripts/oe-setup-builddir && \
+    [ -n "$BUILDDIR" ] && cd "$BUILDDIR"
 unset OEROOT
 
 res=1
-if [ -e bitbake.lock ] && grep : bitbake.lock > /dev/null ; then
-    BBSERVER=`cat bitbake.lock` bitbake --status-only
+if [ -e bitbake.lock ] && grep : bitbake.lock > /dev/null; then
+    BBSERVER=$(cat bitbake.lock) bitbake --status-only
     res=$?
 fi
 
-if [ $res != 0 ] ; then
+if [ $res != 0 ]; then
     bitbake --server-only -t xmlrpc -B localhost:$port
 fi
 
-if [ $port = -1 ] ; then
+if [ $port = -1 ]; then
     export BBSERVER=localhost:-1
     echo "Bitbake server started on demand as needed, use bitbake -m to shut it down"
 else
-    export BBSERVER=`cat bitbake.lock`
+    export BBSERVER=$(cat bitbake.lock)
 
-    if [ $res = 0 ] ; then
-	echo "Using existing bitbake server at: $BBSERVER, use bitbake -m to shut it down"
+    if [ $res = 0 ]; then
+        echo "Using existing bitbake server at: $BBSERVER, use bitbake -m to shut it down"
     else
-	echo "Bitbake server started at: $BBSERVER, use bitbake -m to shut it down"
+        echo "Bitbake server started at: $BBSERVER, use bitbake -m to shut it down"
     fi
-    unset res
 fi
+unset port res
-- 
2.1.0



^ permalink raw reply related	[flat|nested] 10+ messages in thread

* [PATCHv2 4/7] oe-init-build-env*: Make them actually return failures
  2016-03-17 11:14 [PATCHv2 0/7] Improve oe-init-build-env/-memres Peter Kjellerstedt
                   ` (2 preceding siblings ...)
  2016-03-17 11:14 ` [PATCHv2 3/7] oe-init-build-env*: Remove unnecessary differences between the scripts Peter Kjellerstedt
@ 2016-03-17 11:14 ` Peter Kjellerstedt
  2016-03-17 11:14 ` [PATCHv2 5/7] oe-buildenv-internal: Add paths to $PATH individually Peter Kjellerstedt
                   ` (3 subsequent siblings)
  7 siblings, 0 replies; 10+ messages in thread
From: Peter Kjellerstedt @ 2016-03-17 11:14 UTC (permalink / raw)
  To: openembedded-core

If either of the internal scripts (oe-buildenv-internal and
oe-setup-builddir) failed, oe-init-build-env (and
oe-init-build-env-memres) would still return success.

Signed-off-by: Peter Kjellerstedt <peter.kjellerstedt@axis.com>
---
 oe-init-build-env        | 10 +++++++---
 oe-init-build-env-memres | 10 +++++++---
 2 files changed, 14 insertions(+), 6 deletions(-)

diff --git a/oe-init-build-env b/oe-init-build-env
index 0b4df1b..5fe68d1 100755
--- a/oe-init-build-env
+++ b/oe-init-build-env
@@ -48,11 +48,15 @@ fi
 unset THIS_SCRIPT
 
 export OEROOT
-. $OEROOT/scripts/oe-buildenv-internal && \
-    TEMPLATECONF="$TEMPLATECONF" $OEROOT/scripts/oe-setup-builddir && \
-    [ -n "$BUILDDIR" ] && cd "$BUILDDIR"
+. $OEROOT/scripts/oe-buildenv-internal &&
+    TEMPLATECONF="$TEMPLATECONF" $OEROOT/scripts/oe-setup-builddir || {
+    unset OEROOT
+    return 1
+}
 unset OEROOT
 
+[ -z "$BUILDDIR" ] || cd "$BUILDDIR"
+
 # Shutdown any bitbake server if the BBSERVER variable is not set
 if [ -z "$BBSERVER" ] && [ -f bitbake.lock ]; then
     grep ":" bitbake.lock > /dev/null && BBSERVER=$(cat bitbake.lock) bitbake --status-only
diff --git a/oe-init-build-env-memres b/oe-init-build-env-memres
index 9d393f5..9e1425e 100755
--- a/oe-init-build-env-memres
+++ b/oe-init-build-env-memres
@@ -56,11 +56,15 @@ fi
 unset THIS_SCRIPT
 
 export OEROOT
-. $OEROOT/scripts/oe-buildenv-internal && \
-    TEMPLATECONF="$TEMPLATECONF" $OEROOT/scripts/oe-setup-builddir && \
-    [ -n "$BUILDDIR" ] && cd "$BUILDDIR"
+. $OEROOT/scripts/oe-buildenv-internal &&
+    TEMPLATECONF="$TEMPLATECONF" $OEROOT/scripts/oe-setup-builddir || {
+    unset OEROOT
+    return 1
+}
 unset OEROOT
 
+[ -z "$BUILDDIR" ] || cd "$BUILDDIR"
+
 res=1
 if [ -e bitbake.lock ] && grep : bitbake.lock > /dev/null; then
     BBSERVER=$(cat bitbake.lock) bitbake --status-only
-- 
2.1.0



^ permalink raw reply related	[flat|nested] 10+ messages in thread

* [PATCHv2 5/7] oe-buildenv-internal: Add paths to $PATH individually
  2016-03-17 11:14 [PATCHv2 0/7] Improve oe-init-build-env/-memres Peter Kjellerstedt
                   ` (3 preceding siblings ...)
  2016-03-17 11:14 ` [PATCHv2 4/7] oe-init-build-env*: Make them actually return failures Peter Kjellerstedt
@ 2016-03-17 11:14 ` Peter Kjellerstedt
  2016-03-17 11:14 ` [PATCHv2 6/7] oe-buildenv-internal: Add variables individually to BB_ENV_EXTRAWHITE Peter Kjellerstedt
                   ` (2 subsequent siblings)
  7 siblings, 0 replies; 10+ messages in thread
From: Peter Kjellerstedt @ 2016-03-17 11:14 UTC (permalink / raw)
  To: openembedded-core

Instead of assuming that the path to the scripts directory always is
in $PATH directly before the bitbake directory, treat them as separate
paths and add them individually to $PATH.

Signed-off-by: Peter Kjellerstedt <peter.kjellerstedt@axis.com>
---
 scripts/oe-buildenv-internal | 11 ++++++++---
 1 file changed, 8 insertions(+), 3 deletions(-)

diff --git a/scripts/oe-buildenv-internal b/scripts/oe-buildenv-internal
index 457763b..85f82f1 100755
--- a/scripts/oe-buildenv-internal
+++ b/scripts/oe-buildenv-internal
@@ -95,9 +95,14 @@ if ! (test -d "$BITBAKEDIR"); then
 fi
 
 # Make sure our paths are at the beginning of $PATH
-NEWPATHS="${OEROOT}/scripts:$BITBAKEDIR/bin:"
-PATH=$NEWPATHS$(echo $PATH | sed -e "s|:$NEWPATHS|:|g" -e "s|^$NEWPATHS||")
-unset BITBAKEDIR NEWPATHS
+for newpath in "$BITBAKEDIR/bin" "$OEROOT/scripts"; do
+    # Remove any existences of $newpath from $PATH
+    PATH=$(echo $PATH | sed -re "s#(^|:)$newpath(:|$)#\1#g;s#^:##")
+
+    # Add $newpath to $PATH
+    PATH="$newpath:$PATH"
+done
+unset BITBAKEDIR newpath
 
 # Used by the runqemu script
 export BUILDDIR
-- 
2.1.0



^ permalink raw reply related	[flat|nested] 10+ messages in thread

* [PATCHv2 6/7] oe-buildenv-internal: Add variables individually to BB_ENV_EXTRAWHITE
  2016-03-17 11:14 [PATCHv2 0/7] Improve oe-init-build-env/-memres Peter Kjellerstedt
                   ` (4 preceding siblings ...)
  2016-03-17 11:14 ` [PATCHv2 5/7] oe-buildenv-internal: Add paths to $PATH individually Peter Kjellerstedt
@ 2016-03-17 11:14 ` Peter Kjellerstedt
  2016-03-17 11:14 ` [PATCHv2 7/7] oe-buildenv-internal: Some clean up Peter Kjellerstedt
  2016-03-21 10:09 ` [PATCHv2 0/7] Improve oe-init-build-env/-memres Robert Yang
  7 siblings, 0 replies; 10+ messages in thread
From: Peter Kjellerstedt @ 2016-03-17 11:14 UTC (permalink / raw)
  To: openembedded-core

Instead of adding all variables to BB_ENV_EXTRAWHITE as one, treat
them separately and add them one by one as needed.

Signed-off-by: Peter Kjellerstedt <peter.kjellerstedt@axis.com>
---
 scripts/oe-buildenv-internal | 26 +++++++++++++++++++++-----
 1 file changed, 21 insertions(+), 5 deletions(-)

diff --git a/scripts/oe-buildenv-internal b/scripts/oe-buildenv-internal
index 85f82f1..354501e 100755
--- a/scripts/oe-buildenv-internal
+++ b/scripts/oe-buildenv-internal
@@ -108,13 +108,29 @@ unset BITBAKEDIR newpath
 export BUILDDIR
 export PATH
 
-BB_ENV_EXTRAWHITE_OE="MACHINE DISTRO TCMODE TCLIBC HTTP_PROXY http_proxy \
+add_extrawhite() {
+    # If the current shell is zsh, then temporarily set it to emulate sh in this
+    # function so that the for and case statements below work as expected.
+    [ -z "$ZSH_NAME" ] || emulate -L sh
+
+    local extrawhite="MACHINE DISTRO TCMODE TCLIBC HTTP_PROXY http_proxy \
 HTTPS_PROXY https_proxy FTP_PROXY ftp_proxy FTPS_PROXY ftps_proxy ALL_PROXY \
 all_proxy NO_PROXY no_proxy SSH_AGENT_PID SSH_AUTH_SOCK BB_SRCREV_POLICY \
 SDKMACHINE BB_NUMBER_THREADS BB_NO_NETWORK PARALLEL_MAKE GIT_PROXY_COMMAND \
 SOCKS5_PASSWD SOCKS5_USER SCREENDIR STAMPS_DIR"
 
-echo "$BB_ENV_EXTRAWHITE" | grep -q "${BB_ENV_EXTRAWHITE_OE}"
-if [ $? != 0 ]; then
-     export BB_ENV_EXTRAWHITE="${BB_ENV_EXTRAWHITE_OE} $BB_ENV_EXTRAWHITE"
-fi
+    local var
+    for var in $extrawhite; do
+        case " $BB_ENV_EXTRAWHITE " in
+            *[[:blank:]]$var[[:blank:]]*)
+                ;;
+            *)
+                BB_ENV_EXTRAWHITE="${BB_ENV_EXTRAWHITE:+$BB_ENV_EXTRAWHITE }$var"
+                ;;
+        esac
+    done
+}
+
+add_extrawhite
+unset -f add_extrawhite
+export BB_ENV_EXTRAWHITE
-- 
2.1.0



^ permalink raw reply related	[flat|nested] 10+ messages in thread

* [PATCHv2 7/7] oe-buildenv-internal: Some clean up
  2016-03-17 11:14 [PATCHv2 0/7] Improve oe-init-build-env/-memres Peter Kjellerstedt
                   ` (5 preceding siblings ...)
  2016-03-17 11:14 ` [PATCHv2 6/7] oe-buildenv-internal: Add variables individually to BB_ENV_EXTRAWHITE Peter Kjellerstedt
@ 2016-03-17 11:14 ` Peter Kjellerstedt
  2016-03-21 10:09 ` [PATCHv2 0/7] Improve oe-init-build-env/-memres Robert Yang
  7 siblings, 0 replies; 10+ messages in thread
From: Peter Kjellerstedt @ 2016-03-17 11:14 UTC (permalink / raw)
  To: openembedded-core

* Consistent indentation (four spaces)
* Use [ -z ...] and [ -n ... ] where possible
* Unset temporary variables
* Use $(...) instead of `...`
* Avoid an unnecessary call to expr

Signed-off-by: Peter Kjellerstedt <peter.kjellerstedt@axis.com>
---
 scripts/oe-buildenv-internal | 46 +++++++++++++++++++++++---------------------
 1 file changed, 24 insertions(+), 22 deletions(-)

diff --git a/scripts/oe-buildenv-internal b/scripts/oe-buildenv-internal
index 354501e..bc6a4fe 100755
--- a/scripts/oe-buildenv-internal
+++ b/scripts/oe-buildenv-internal
@@ -24,7 +24,7 @@ if [ -z "$OEROOT" ]; then
     return 1
 fi
 
-if [ -z "$OE_SKIP_SDK_CHECK" -a ! -z "$OECORE_SDK_VERSION" ]; then
+if [ -z "$OE_SKIP_SDK_CHECK" ] && [ -n "$OECORE_SDK_VERSION" ]; then
     echo >&2 "Error: The OE SDK/ADT was detected as already being present in this shell environment. Please use a clean shell when sourcing this environment script."
     return 1
 fi
@@ -33,24 +33,26 @@ fi
 # sanity.bbclass because bitbake's source code doesn't even pass
 # parsing stage when used with python v3, so we catch it here so we
 # can offer a meaningful error message.
-py_v3_check=`/usr/bin/env python --version 2>&1 | grep "Python 3"`
-if [ "$py_v3_check" != "" ]; then
-	echo >&2 "Bitbake is not compatible with python v3"
-	echo >&2 "Please set up python v2 as your default python interpreter"
-	return 1
+py_v3_check=$(/usr/bin/env python --version 2>&1 | grep "Python 3")
+if [ -n "$py_v3_check" ]; then
+    echo >&2 "Bitbake is not compatible with python v3"
+    echo >&2 "Please set up python v2 as your default python interpreter"
+    return 1
 fi
+unset py_v3_check
 
 # Similarly, we now have code that doesn't parse correctly with older
 # versions of Python, and rather than fixing that and being eternally
 # vigilant for any other new feature use, just check the version here.
-py_v26_check=`python -c 'import sys; print sys.version_info >= (2,7,3)'`
+py_v26_check=$(python -c 'import sys; print sys.version_info >= (2,7,3)')
 if [ "$py_v26_check" != "True" ]; then
-	echo >&2 "BitBake requires Python 2.7.3 or later"
-	return 1
+    echo >&2 "BitBake requires Python 2.7.3 or later"
+    return 1
 fi
+unset py_v26_check
 
-if [ "x$BDIR" = "x" ]; then
-    if [ "x$1" = "x" ]; then
+if [ -z "$BDIR" ]; then
+    if [ -z "$1" ]; then
         BDIR="build"
     else
         BDIR="$1"
@@ -62,34 +64,34 @@ if [ "x$BDIR" = "x" ]; then
         # Remove any possible trailing slashes. This is used to work around
         # buggy readlink in Ubuntu 10.04 that doesn't ignore trailing slashes
         # and hence "readlink -f new_dir_to_be_created/" returns empty.
-        BDIR=`echo $BDIR | sed -re 's|/+$||'`
+        BDIR=$(echo $BDIR | sed -re 's|/+$||')
 
-        BDIR=`readlink -f "$BDIR"`
+        BDIR=$(readlink -f "$BDIR")
         if [ -z "$BDIR" ]; then
-            PARENTDIR=`dirname "$1"`
+            PARENTDIR=$(dirname "$1")
             echo >&2 "Error: the directory $PARENTDIR does not exist?"
             return 1
         fi
     fi
-    if [ "x$2" != "x" ]; then
+    if [ -n "$2" ]; then
         BITBAKEDIR="$2"
     fi
 fi
-if expr "$BDIR" : '/.*' > /dev/null ; then
+if [ "${BDIR#/}" != "$BDIR" ]; then
     BUILDDIR="$BDIR"
 else
-    BUILDDIR="`pwd`/$BDIR"
+    BUILDDIR="$(pwd)/$BDIR"
 fi
 unset BDIR
 
-if [ "x$BITBAKEDIR" = "x" ]; then
-    BITBAKEDIR="$OEROOT/bitbake$BBEXTRA/"
+if [ -z "$BITBAKEDIR" ]; then
+    BITBAKEDIR="$OEROOT/bitbake$BBEXTRA"
 fi
 
-BITBAKEDIR=`readlink -f "$BITBAKEDIR"`
-BUILDDIR=`readlink -f "$BUILDDIR"`
+BITBAKEDIR=$(readlink -f "$BITBAKEDIR")
+BUILDDIR=$(readlink -f "$BUILDDIR")
 
-if ! (test -d "$BITBAKEDIR"); then
+if [ ! -d "$BITBAKEDIR" ]; then
     echo >&2 "Error: The bitbake directory ($BITBAKEDIR) does not exist!  Please ensure a copy of bitbake exists at this location"
     return 1
 fi
-- 
2.1.0



^ permalink raw reply related	[flat|nested] 10+ messages in thread

* Re: [PATCHv2 0/7] Improve oe-init-build-env/-memres
  2016-03-17 11:14 [PATCHv2 0/7] Improve oe-init-build-env/-memres Peter Kjellerstedt
                   ` (6 preceding siblings ...)
  2016-03-17 11:14 ` [PATCHv2 7/7] oe-buildenv-internal: Some clean up Peter Kjellerstedt
@ 2016-03-21 10:09 ` Robert Yang
  2016-03-21 11:55   ` Peter Kjellerstedt
  7 siblings, 1 reply; 10+ messages in thread
From: Robert Yang @ 2016-03-21 10:09 UTC (permalink / raw)
  To: Peter Kjellerstedt, openembedded-core


I got strange errors, I think that it is caused by one of these patches:

$ . ../poky/oe-init-build-env .
$ bitbake core-image-minimal
ERROR:  OE-core's config sanity checker detected a potential misconfiguration.
     Either fix the cause of this error or at your own risk disable the checker 
(see sanity.conf).
     Following is the list of potential problems / advisories:

     PATH contains '.', './' or '' (empty element), which will break the build, 
please remove this.

$ echo $PATH
/buildarea/lyang1/poky/scripts:/buildarea/lyang1/poky/bitbake/bin:/folk/lyang1/bin:/folk/lyang1/gbin:/usr/local/sbin:/usr/local/bin:/usr/sbin:/usr/bin:/sbin:/bin:/usr/games:/opt/dell/srvadmin/bin:


Without running oe-init-build-env:
$ echo $PATH
/folk/lyang1/bin:/folk/lyang1/gbin:/usr/local/sbin:/usr/local/bin:/usr/sbin:/usr/bin:/sbin:/bin:/usr/games:/opt/dell/srvadmin/bin:/buildarea/lyang1/poky/bitbake/bin

// Robert

On 03/17/2016 07:14 PM, Peter Kjellerstedt wrote:
> I started looking at the oe-init-build-env (and
> oe-init-build-env-memres) scripts since I wanted to add support for
> specifying $OEROOT from the outside. This is because we want to wrap
> those scripts with our own while keeping the official names (so anyone
> reading the official Poky documentation will not be too confused).
>
> While fixing the above, I had noticed a number of inconsistencies in
> the scripts, so I continued to fix those. I also improved the code
> that adds paths to $PATH, and the code that adds variable names to
> $BB_ENV_EXTRAWHITE.
>
> New in version 2:
>
> * Make sure oe-init-build-env and oe-init-build-env-memres actually
>    return failures from other scripts they source and call.
>
> //Peter
>
> The following changes since commit 8debfea81e69d038bd2d56314b272cb74f5582ed:
>
>    local.conf.sample: Disable prelink by default (2016-03-13 22:09:05 +0000)
>
> are available in the git repository at:
>
>    git://git.yoctoproject.org/poky-contrib pkj/oe-init-build-env
>    http://git.yoctoproject.org/cgit.cgi/poky-contrib/log/?h=pkj/oe-init-build-env
>
> Peter Kjellerstedt (7):
>    oe-init-build-env*: Allow $OEROOT to be predefined
>    oe-init-build-env*: Update/correct comment about specifying arguments
>    oe-init-build-env*: Remove unnecessary differences between the scripts
>    oe-init-build-env*: Make them actually return failures
>    oe-buildenv-internal: Add paths to $PATH individually
>    oe-buildenv-internal: Add variables individually to BB_ENV_EXTRAWHITE
>    oe-buildenv-internal: Some clean up
>
>   oe-init-build-env            | 51 +++++++++++++++------------
>   oe-init-build-env-memres     | 60 ++++++++++++++++++--------------
>   scripts/oe-buildenv-internal | 83 ++++++++++++++++++++++++++++----------------
>   3 files changed, 114 insertions(+), 80 deletions(-)
>


^ permalink raw reply	[flat|nested] 10+ messages in thread

* Re: [PATCHv2 0/7] Improve oe-init-build-env/-memres
  2016-03-21 10:09 ` [PATCHv2 0/7] Improve oe-init-build-env/-memres Robert Yang
@ 2016-03-21 11:55   ` Peter Kjellerstedt
  0 siblings, 0 replies; 10+ messages in thread
From: Peter Kjellerstedt @ 2016-03-21 11:55 UTC (permalink / raw)
  To: Richard Purdie (richard.purdie@linuxfoundation.org),
	Robert Yang, openembedded-core

> -----Original Message-----
> From: openembedded-core-bounces@lists.openembedded.org
> [mailto:openembedded-core-bounces@lists.openembedded.org] On Behalf Of
> Robert Yang
> Sent: den 21 mars 2016 11:09
> To: Peter Kjellerstedt; openembedded-core@lists.openembedded.org
> Subject: Re: [OE-core] [PATCHv2 0/7] Improve oe-init-build-env/-memres
> 
> 
> I got strange errors, I think that it is caused by one of these
> patches:
> 
> $ . ../poky/oe-init-build-env .
> $ bitbake core-image-minimal
> ERROR:  OE-core's config sanity checker detected a potential
> misconfiguration.
>      Either fix the cause of this error or at your own risk disable the
> checker
> (see sanity.conf).
>      Following is the list of potential problems / advisories:
> 
>      PATH contains '.', './' or '' (empty element), which will break
> the build,
> please remove this.
> 
> $ echo $PATH
> /buildarea/lyang1/poky/scripts:/buildarea/lyang1/poky/bitbake/bin:/folk
> /lyang1/bin:/folk/lyang1/gbin:/usr/local/sbin:/usr/local/bin:/usr/sbin:
> /usr/bin:/sbin:/bin:/usr/games:/opt/dell/srvadmin/bin:
> 
> 
> Without running oe-init-build-env:
> $ echo $PATH
> /folk/lyang1/bin:/folk/lyang1/gbin:/usr/local/sbin:/usr/local/bin:/usr/
> sbin:/usr/bin:/sbin:/bin:/usr/games:/opt/dell/srvadmin/bin:/buildarea/l
> yang1/poky/bitbake/bin
> 
> // Robert

Bah, sorry about that. A colleague recommended a change to the code 
that adds paths to $PATH in oe-buildenv-internal, which I implemented 
just before sending my second patch set last week. Unfortunately I 
missed changing a \1 to a \2 in the sed-expression after introducing 
another capture group.

I have now sent a fix for this.

//Peter



^ permalink raw reply	[flat|nested] 10+ messages in thread

end of thread, other threads:[~2016-03-21 11:55 UTC | newest]

Thread overview: 10+ messages (download: mbox.gz / follow: Atom feed)
-- links below jump to the message on this page --
2016-03-17 11:14 [PATCHv2 0/7] Improve oe-init-build-env/-memres Peter Kjellerstedt
2016-03-17 11:14 ` [PATCHv2 1/7] oe-init-build-env*: Allow $OEROOT to be predefined Peter Kjellerstedt
2016-03-17 11:14 ` [PATCHv2 2/7] oe-init-build-env*: Update/correct comment about specifying arguments Peter Kjellerstedt
2016-03-17 11:14 ` [PATCHv2 3/7] oe-init-build-env*: Remove unnecessary differences between the scripts Peter Kjellerstedt
2016-03-17 11:14 ` [PATCHv2 4/7] oe-init-build-env*: Make them actually return failures Peter Kjellerstedt
2016-03-17 11:14 ` [PATCHv2 5/7] oe-buildenv-internal: Add paths to $PATH individually Peter Kjellerstedt
2016-03-17 11:14 ` [PATCHv2 6/7] oe-buildenv-internal: Add variables individually to BB_ENV_EXTRAWHITE Peter Kjellerstedt
2016-03-17 11:14 ` [PATCHv2 7/7] oe-buildenv-internal: Some clean up Peter Kjellerstedt
2016-03-21 10:09 ` [PATCHv2 0/7] Improve oe-init-build-env/-memres Robert Yang
2016-03-21 11:55   ` Peter Kjellerstedt

This is an external index of several public inboxes,
see mirroring instructions on how to clone and mirror
all data and code used by this external index.