[meta-freescale] [fsl-community-bsp-base][PATCH] setup-environment: fix EULA acceptance logic

Mario Domenech Goulart mario at ossystems.com.br
Wed Aug 19 10:11:47 PDT 2015


This commit fixes the handling of the EULA environment variable,
which was being ignored.  This regression was introduced by
41c2b0acbe.

Assumption by this commit: variables are considered set if they are
set according to shell's rules.

So,

  . setup-environment <build-dir>

(assuming EULA is not set in the current environment) or

  EULA= . setup-environment <build-dir>

won't make the FSL EULA be automatically accepted.  However,

  EULA=1 . setup-environment <build-dir>

will, as well as for any value of EULA.

The same rules apply to ACCEPT_FSL_EULA configuration in
local.conf.

Signed-off-by: Mario Domenech Goulart <mario at ossystems.com.br>
---
 setup-environment |   36 ++++++++++++++++++++++++------------
 1 file changed, 24 insertions(+), 12 deletions(-)

diff --git a/setup-environment b/setup-environment
index 9abb572..436a932 100755
--- a/setup-environment
+++ b/setup-environment
@@ -179,11 +179,26 @@ EOF
 fi
 
 # Handle EULA setting
-if [ -z "$EULA" ] && ! grep -q '^ACCEPT_FSL_EULA\s*=' conf/local.conf; then
-    EULA='ask'
+EULA_ACCEPTED=
+
+# EULA has been accepted already (ACCEPT_FSL_EULA is set in local.conf)
+if grep -q '^\s*ACCEPT_FSL_EULA\s*=\s*["'\'']..*["'\'']' conf/local.conf; then
+    EULA_ACCEPTED=1
 fi
 
-if [ "$EULA" = "ask" ]; then
+if [ -z "$EULA_ACCEPTED" ] && [ -n "$EULA" ]; then
+    # The FSL EULA is not set as accepted in local.conf, but the EULA
+    # variable is set in the environment, so we just configure
+    # ACCEPT_FSL_EULA in local.conf according to $EULA.
+    echo "ACCEPT_FSL_EULA = \"$EULA\"" >> conf/local.conf
+elif [ -n "$EULA_ACCEPTED" ]; then
+    # The FSL EULA has been accepted once, so ACCEPT_FSL_EULA is set
+    # in local.conf.  No need to do anything.
+    :
+else
+    # THE FSL EULA is not set as accepted in local.conf, and EULA is
+    # not set in the environment, so we need to ask user if he/she
+    # accepts the FSL EULA:
     cat <<EOF
 
 Some BSPs depend on libraries and packages which are covered by Freescale's
@@ -196,26 +211,23 @@ EOF
 
     more -d $CWD/sources/meta-fsl-arm/EULA
     echo
-    while [ "$EULA" = "ask" ]; do
+    REPLY=
+    while [ -z "$REPLY" ]; do
         echo -n "Do you accept the EULA you just read? (y/n) "
         read REPLY
         case "$REPLY" in
             y|Y)
             echo "EULA has been accepted."
-            EULA="1"
+            echo "ACCEPT_FSL_EULA = \"1\"" >> conf/local.conf
             ;;
             n|N)
             echo "EULA has not been accepted."
-            EULA="0"
+            ;;
+            *)
+            REPLY=
             ;;
         esac
     done
-
-    if grep -q '^ACCEPT_FSL_EULA\s*=' conf/local.conf; then
-        sed -i "s/^#*ACCEPT_FSL_EULA\s*=.*/ACCEPT_FSL_EULA = \"$EULA\"/g" conf/local.conf
-    else
-        echo "ACCEPT_FSL_EULA = \"$EULA\"" >> conf/local.conf
-    fi
 fi
 
 cat <<EOF
-- 
1.7.10.4



More information about the meta-freescale mailing list