Fix error by envsetup.sh when reuse a terminal
[AGL/meta-agl.git] / scripts / envsetup.sh
index 27d73a7..79d2a25 100644 (file)
@@ -2,10 +2,17 @@
 
 if [ -z $1 ]; then
         echo -e "Usage: source envsetup.sh <board/device> [build dir]"
-        return -1
+        return 1
 fi
 
-case "$1" in
+MACHINE="$1"
+
+# set template conf for each <board/device>
+if [ -z "$TEMPLATECONF" ]; then
+    TEMPLATECONF="$PWD/meta-agl-demo/templates/$MACHINE/conf"
+fi
+
+case "$MACHINE" in
         "porter")
                 # setup proprietary gfx drivers and multimedia packages
                 COPY_MM_SCRIPT=meta-renesas/meta-rcar-gen2/scripts/setup_mm_packages.sh
@@ -14,28 +21,34 @@ case "$1" in
                         copy_mm_packages $1
                         if [ $? -ne 0 ]; then
                                 echo "Copying gfx drivers and multimedia packages for '$1' failed."
-                                return -1
+                                return 1
                         fi
                 fi
 
-                # template conf for R-Car2 M2 Porter board
-                TEMPLATECONF=$PWD/meta-renesas/meta-rcar-gen2/conf
+                if [ ! -d "$TEMPLATECONF" ]; then
+                    # set template conf for R-Car2 M2 Porter board
+                    TEMPLATECONF="$PWD/meta-renesas/meta-rcar-gen2/conf"
+                fi
+                ;;
+        "intel-corei7-64")
+                ;;
+        "qemux86")
                 ;;
         "qemux86-64")
-                # template conf for QEMU x86-64
-                TEMPLATECONF=$PWD/meta-agl-demo/conf
                 ;;
         *)
                 # nothing to do here
-                echo "WARN: '$1' is not tested by AGL Distro"
-                if [ -z $TEMPLATECONF ]; then
-                        TEMPLATECONF=$PWD/meta-agl-demo/conf
-                fi
+                echo "WARN: '$MACHINE' is not tested by AGL Distro"
                 ;;
 esac
 
 echo "envsetup: Set '$1 as MACHINE."
-export MACHINE="$1"
+export MACHINE
+
+if [ ! -d "$TEMPLATECONF" ]; then
+   # Allow to use templates at meta-agl-demo/conf
+   TEMPLATECONF="$PWD/meta-agl-demo/conf"
+fi
 
 echo "envsetup: Using templates for local.conf & bblayers.conf from :"
 echo "          '$TEMPLATECONF'"
@@ -62,3 +75,4 @@ fi
 
 export BB_ENV_EXTRAWHITE
 
+unset TEMPLATECONF