All of lore.kernel.org
 help / color / mirror / Atom feed
* [PATCH][fsl-community-bsp-base] setup-environment: provide a MACHINE menu
@ 2014-03-26 19:33 Trevor Woerner
  2014-03-27 13:28 ` Daiane.Angolini
  2014-03-27 17:53 ` Otavio Salvador
  0 siblings, 2 replies; 17+ messages in thread
From: Trevor Woerner @ 2014-03-26 19:33 UTC (permalink / raw)
  To: meta-freescale; +Cc: Otavio Salvador, patches

If the user hasn't specified a MACHINE in the environment, and the specified
build directory doesn't contain conf/local.conf and conf/bblayers.conf, then
provide the user with a list of machines and have them choose one by number.

Signed-off-by: Trevor Woerner <trevor.woerner@linaro.org>
---
 setup-environment | 45 ++++++++++++++++++++++++++++++++++++++++-----
 1 file changed, 40 insertions(+), 5 deletions(-)

I would very much have liked to have been able to use "select", but (alas) it
is a bash-ism.

diff --git a/setup-environment b/setup-environment
index 861d854..fc42cc4 100644
--- a/setup-environment
+++ b/setup-environment
@@ -29,13 +29,16 @@ usage()
     echo -e "\nUsage: source $PROGNAME <build-dir>
     <build-dir>: required option; specifies build directory location
 
-By default the script will setup MACHINE to be imx6qsabresd.
+Either specify the MACHINE in the environment, or choose
+one from the list provided when the script is run.
 
 Supported machines: `ls sources/*/conf/machine/*.conf \
 | sed s/\.conf//g | sed -r 's/^.+\///' | xargs echo`
 
 To build for a machine listed above, run this script as:
-MACHINE=<machine> source $PROGNAME <build-dir>
+    MACHINE=<machine> source $PROGNAME <build-dir>
+or don't specify the MACHINE and the script will prompt
+you for one with a list.
 
 The script sets PARALLEL_MAKE & BB_NUMBER_THREADS to $NCPU
 "
@@ -43,7 +46,8 @@ The script sets PARALLEL_MAKE & BB_NUMBER_THREADS to $NCPU
 
 clean_up()
 {
-   unset EULA LIST_MACHINES VALID_MACHINE
+   unset EULA LIST_MACHINES VALID_MACHINE MACHINELIST MACHINECNT EXISTINGCONFIG
+   unset _i _opt
    unset NCPU CWD TEMPLATES SHORTOPTS LONGOPTS ARGS PROGNAME
 }
 
@@ -79,10 +83,41 @@ if [ "$(whoami)" = "root" ]; then
     echo "ERROR: do not use the BSP as root. Exiting..."
 fi
 
-if [ -z "$MACHINE" ]; then
-    MACHINE='imx6qsabresd'
+EXISTINGCONFIG=
+if [ -f $1/conf/local.conf ] && [ -f $1/conf/bblayers.conf ]; then
+    EXISTINGCONFIG="yes"
 fi
 
+MACHINELIST=`ls -1 */*/conf/machine/*conf 2> /dev/null | cut -d'/' -f5 | cut -d'.' -f1 | sort -n | uniq`
+MACHINECNT=`echo $MACHINELIST | wc -w`
+machine_menu()
+{
+    _i=1
+    while [ $_i -le $MACHINECNT ]; do
+        echo -n "$_i) "
+        echo $MACHINELIST | cut -d' ' -f$_i
+        _i=`expr $_i + 1`
+    done
+}
+_opt=
+if [ -z "$MACHINE" ] && [ -z "$EXISTINGCONFIG" ]; then
+    while [ -z "$_opt" ]; do
+        machine_menu
+        echo -n "Please choose a MACHINE: "
+        read _opt
+        if echo $_opt | grep -qE "^[0-9]+$"; then
+            if [ $_opt -gt 0 ] && [ $_opt -le $MACHINECNT ]; then
+                MACHINE=`echo $MACHINELIST | cut -d' ' -f$_opt`
+                break
+            fi
+        fi
+        echo "invalid input: \"$_opt\""
+        echo ""
+        _opt=
+    done
+fi
+unset _opt _i EXISTINGCONFIG MACHINELIST MACHINECNT
+
 # Check the machine type specified
 LIST_MACHINES=`ls -1 $CWD/sources/*/conf/machine`
 VALID_MACHINE=`echo -e "$LIST_MACHINES" | grep ${MACHINE}.conf$ | wc -l`
-- 
1.9.0



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

end of thread, other threads:[~2014-03-28 16:28 UTC | newest]

Thread overview: 17+ messages (download: mbox.gz follow: Atom feed
-- links below jump to the message on this page --
2014-03-26 19:33 [PATCH][fsl-community-bsp-base] setup-environment: provide a MACHINE menu Trevor Woerner
2014-03-27 13:28 ` Daiane.Angolini
2014-03-27 14:02   ` John Weber
2014-03-27 16:21   ` Trevor Woerner
2014-03-27 17:45     ` Otavio Salvador
2014-03-27 18:08     ` Daiane.Angolini
2014-03-27 18:17       ` Otavio Salvador
2014-03-27 18:55         ` Daiane.Angolini
2014-03-27 19:01       ` Trevor Woerner
2014-03-27 19:12         ` Otavio Salvador
2014-03-27 19:25           ` Daiane.Angolini
2014-03-27 19:37             ` Otavio Salvador
2014-03-27 19:54               ` Daiane.Angolini
2014-03-27 19:23         ` Daiane.Angolini
2014-03-28 16:04       ` Trevor Woerner
2014-03-28 16:28         ` Daiane.Angolini
2014-03-27 17:53 ` Otavio Salvador

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.