Patchwork [fsl-community-bsp-base] setup-environment: provide a MACHINE menu

login
register
mail settings
Submitter Trevor Woerner
Date March 26, 2014, 7:33 p.m.
Message ID <1395862407-29020-1-git-send-email-trevor.woerner@linaro.org>
Download mbox | patch
Permalink /patch/69337/
State Changes Requested
Delegated to: Otavio Salvador
Headers show

Comments

Trevor Woerner - March 26, 2014, 7:33 p.m.
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.
Daiane Angolini - March 27, 2014, 1:28 p.m.
> -----Original Message-----
> From: meta-freescale-bounces@yoctoproject.org [mailto:meta-freescale-
> bounces@yoctoproject.org] On Behalf Of Trevor Woerner
> Sent: Wednesday, March 26, 2014 4:33 PM
> To: meta-freescale@yoctoproject.org
> Cc: Otavio Salvador; patches@linaro.org
> Subject: [meta-freescale] [PATCH][fsl-community-bsp-base] setup-
> environment: provide a MACHINE menu
> 
> 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>

Hi Trevor, I´m still deciding if I like or dislike your patch =P

It´s queued in my test list and I should let you know what I think after I had tested it

It will take some time, but "you are not alone, i´m here with you, lalalala" OK?

Daiane
John Weber - March 27, 2014, 2:02 p.m.
Hi Trevor -

On 3/27/14, 8:28 AM, Daiane.Angolini@freescale.com wrote:
>
>> -----Original Message-----
>> From: meta-freescale-bounces@yoctoproject.org [mailto:meta-freescale-
>> bounces@yoctoproject.org] On Behalf Of Trevor Woerner
>> Sent: Wednesday, March 26, 2014 4:33 PM
>> To: meta-freescale@yoctoproject.org
>> Cc: Otavio Salvador; patches@linaro.org
>> Subject: [meta-freescale] [PATCH][fsl-community-bsp-base] setup-
>> environment: provide a MACHINE menu
>>
>> 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>
> Hi Trevor, I´m still deciding if I like or dislike your patch =P
>
> It´s queued in my test list and I should let you know what I think after I had tested it
>
> It will take some time, but "you are not alone, i´m here with you, lalalala" OK?
>
> Daiane
I like the concept.  If you don't know the machine name exactly when you start 
out (most do, but some will not), then having a list presented to you to select 
from would be convenient.

John
Trevor Woerner - March 27, 2014, 4:21 p.m.
On 03/27/14 09:28, Daiane.Angolini@freescale.com wrote:
> Hi Trevor, I´m still deciding if I like or dislike your patch =P
>
> It´s queued in my test list and I should let you know what I think after I had tested it

Thanks for the status update.

> It will take some time, but "you are not alone, i´m here with you, lalalala" OK?

:-D

Thanks, I appreciate the support.

Since everything goes so fast, I don't mind a little breather now and again.

Traditionally I've been hesitant to send patches, but I've decided to
not be as shy anymore. Therefore I don't expect everything I send to be
successful :-)
Otavio Salvador - March 27, 2014, 5:45 p.m.
Hello Trevor,

On Thu, Mar 27, 2014 at 1:21 PM, Trevor Woerner
<trevor.woerner@linaro.org> wrote:
> On 03/27/14 09:28, Daiane.Angolini@freescale.com wrote:
>> Hi Trevor, I´m still deciding if I like or dislike your patch =P
>>
>> It´s queued in my test list and I should let you know what I think after I had tested it
>
> Thanks for the status update.
>
>> It will take some time, but "you are not alone, i´m here with you, lalalala" OK?
>
> :-D
>
> Thanks, I appreciate the support.
>
> Since everything goes so fast, I don't mind a little breather now and again.
>
> Traditionally I've been hesitant to send patches, but I've decided to
> not be as shy anymore. Therefore I don't expect everything I send to be
> successful :-)

Don't be hesitant :-) Send it. This is the nice thing about
community... we help each other and learn with it.
Otavio Salvador - March 27, 2014, 5:53 p.m.
Hello Trevor,

On Wed, Mar 26, 2014 at 4:33 PM, Trevor Woerner
<trevor.woerner@linaro.org> wrote:
> 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>

Conceptually I like the idea. My current concern is about using
numbers to choose the machine.

The numbers are not going to be consistent during time (the number 20
today may point, in future to a different board). Maybe you could
offer a prompt for user to type the board name?
Daiane Angolini - March 27, 2014, 6:08 p.m.
> -----Original Message-----
> From: Trevor Woerner [mailto:trevor.woerner@linaro.org]
> Sent: Thursday, March 27, 2014 1:21 PM
> To: Angolini Daiane-B19406; meta-freescale@yoctoproject.org
> Subject: Re: [meta-freescale] [PATCH][fsl-community-bsp-base] setup-
> environment: provide a MACHINE menu
> 


> 
> Traditionally I've been hesitant to send patches, but I've decided to not
> be as shy anymore. Therefore I don't expect everything I send to be
> successful :-)
> 

Yes, please, don't be shy anymore and send all patches you have ;-)

I like your patch. But it have several important problems.

1) assign a number to a board may lead user to error. I love the machine list, and I love that imx53qsb is 20, but when a new board is added I will try to use 20 and it will not be imx53qsb. This is only one example, and this only happens if you use a dynamic order for the machine list.

2) it only list machines from meta-fsl-arm and meta-fsl-arm-extra. I tried 

MACHINE="qemuarm" source setup-environment build

And I faced a big error message!

I´m not sure if we want to list external boards, but it looks weird to me not being able to have a qemu build dir.


3) In error message, instead of list all boards one before the other, list one machine per line.


I like to prompt user instead of assuming a default machine. But a list of machines is not good when you have 150 machines. And I start to try to group the machines in SOC family, or in meta-fsl-arm/meta-fsl-arm-extra, or any other criteria to help user to decide it.


Please, let me know what you think.

Daiane
Otavio Salvador - March 27, 2014, 6:17 p.m.
Hello Daiane,

On Thu, Mar 27, 2014 at 3:08 PM, Daiane.Angolini@freescale.com
<Daiane.Angolini@freescale.com> wrote:
...
> Yes, please, don't be shy anymore and send all patches you have ;-)
>
> I like your patch. But it have several important problems.
>
> 1) assign a number to a board may lead user to error. I love the machine list, and I love that imx53qsb is 20, but when a new board is added I will try to use 20 and it will not be imx53qsb. This is only one example, and this only happens if you use a dynamic order for the machine list.

Agreed.

> 2) it only list machines from meta-fsl-arm and meta-fsl-arm-extra. I tried
>
> MACHINE="qemuarm" source setup-environment build
>
> And I faced a big error message!

Agreed this is not user friendly heh...

> I´m not sure if we want to list external boards, but it looks weird to me not being able to have a qemu build dir.

Good point. Even though we may not list the other machines I think it
is expected those to me usable.

> 3) In error message, instead of list all boards one before the other, list one machine per line.
>
>
> I like to prompt user instead of assuming a default machine. But a list of machines is not good when you have 150 machines. And I start to try to group the machines in SOC family, or in meta-fsl-arm/meta-fsl-arm-extra, or any other criteria to help user to decide it.

I am a bit unsure we ought to do a list by default. Maybe one more
user friendly way is:

* If no machine is set (using MACHINE=foo source ./setup-environment
build-foo), say to run ./setup-environment list-machines
* If user sets the machine, use it
* If user runs ./setup-environment list-machines, a list of machine
plus its verbose description might be output and use the 'more -d'
trick as EULA to paginate it.

Thoughts?
Daiane Angolini - March 27, 2014, 6:55 p.m.
> -----Original Message-----
> From: otavio.salvador@gmail.com [mailto:otavio.salvador@gmail.com] On
> Behalf Of Otavio Salvador
> Sent: Thursday, March 27, 2014 3:18 PM
> To: Angolini Daiane-B19406
> Cc: Trevor Woerner; meta-freescale@yoctoproject.org
> Subject: Re: [meta-freescale] [PATCH][fsl-community-bsp-base] setup-
> environment: provide a MACHINE menu


> * If no machine is set (using MACHINE=foo source ./setup-environment build-
> foo), say to run ./setup-environment list-machines
> * If user sets the machine, use it
> * If user runs ./setup-environment list-machines, a list of machine plus
> its verbose description might be output and use the 'more -d'
> trick as EULA to paginate it.

I like the setup-environment list-machines, and I remember there is some other /list/ scripts from poky that may set a standard


> 
> Thoughts?
> 
> --
> Otavio Salvador                             O.S. Systems
> http://www.ossystems.com.br        http://code.ossystems.com.br
> Mobile: +55 (53) 9981-7854            Mobile: +1 (347) 903-9750
>
Trevor Woerner - March 27, 2014, 7:01 p.m.
On 03/27/14 14:08, Daiane.Angolini@freescale.com wrote:
>> Traditionally I've been hesitant to send patches, but I've decided to not
>> be as shy anymore. Therefore I don't expect everything I send to be
>> successful :-)
> Yes, please, don't be shy anymore and send all patches you have ;-)

The can of worms is now open :-)

> I like your patch. But it have several important problems.
>
> 1) assign a number to a board may lead user to error. I love the machine list, and I love that imx53qsb is 20, but when a new board is added I will try to use 20 and it will not be imx53qsb. This is only one example, and this only happens if you use a dynamic order for the machine list.

I hadn't thought of that, but I agree completely.

> 2) it only list machines from meta-fsl-arm and meta-fsl-arm-extra. I tried 
>
> MACHINE="qemuarm" source setup-environment build
>
> And I faced a big error message!

Whoops! I hadn't tested the emulators, but I agree they should certainly
be in the list too. Getting a big error message isn't what I wanted to
have happen.

> I´m not sure if we want to list external boards, but it looks weird to me not being able to have a qemu build dir.

By "external boards" I assume you mean non-ARM or non-freescale boards
(e.g. beagle)? If so, I don't think we should worry too much about
listing external boards, setup-environment comes from a
freescale-specific repository. If someone is following the steps to
checkout and build for a freescale board (and therefore using
setup-environment), I think it's a safe enough assumption they're going
to want to build for one of the boards supported by the freescale BSP
repositories (or qemu). I don't think it's too much to say that someone
would be in the wrong place if they were complaining that the freescale
setup script didn't include options to build for a MIPS64 target :-)

In other words, I believe the setup-environment script provided in
fsl-community-bsp-base is already freescale-specific. Making it more so
shouldn't be a problem?

> 3) In error message, instead of list all boards one before the other, list one machine per line.

Okay.

> I like to prompt user instead of assuming a default machine. But a list of machines is not good when you have 150 machines. And I start to try to group the machines in SOC family, or in meta-fsl-arm/meta-fsl-arm-extra, or any other criteria to help user to decide it.

Actually, an early version of my script did that, but I thought it was
too "text-y" so I shortened it to just the machine name. I figure the
person has the board sitting there, they know the board name, so finding
that name in a list that is sorted alphabetically shouldn't be too hard :-D

But in this decision you can also see my bias. I don't look at the
boards as being either from freescale or not, so sorting them that way
is not something I would do by default :-)
Otavio Salvador - March 27, 2014, 7:12 p.m.
On Thu, Mar 27, 2014 at 4:01 PM, Trevor Woerner
<trevor.woerner@linaro.org> wrote:
> On 03/27/14 14:08, Daiane.Angolini@freescale.com wrote:
>>> Traditionally I've been hesitant to send patches, but I've decided to not
>>> be as shy anymore. Therefore I don't expect everything I send to be
>>> successful :-)
>> Yes, please, don't be shy anymore and send all patches you have ;-)
>
> The can of worms is now open :-)
>
>> I like your patch. But it have several important problems.
>>
>> 1) assign a number to a board may lead user to error. I love the machine list, and I love that imx53qsb is 20, but when a new board is added I will try to use 20 and it will not be imx53qsb. This is only one example, and this only happens if you use a dynamic order for the machine list.
>
> I hadn't thought of that, but I agree completely.
>
>> 2) it only list machines from meta-fsl-arm and meta-fsl-arm-extra. I tried
>>
>> MACHINE="qemuarm" source setup-environment build
>>
>> And I faced a big error message!
>
> Whoops! I hadn't tested the emulators, but I agree they should certainly
> be in the list too. Getting a big error message isn't what I wanted to
> have happen.

Not sure I'd list those. But I'd like others to comment on this.

>> I´m not sure if we want to list external boards, but it looks weird to me not being able to have a qemu build dir.
>
> By "external boards" I assume you mean non-ARM or non-freescale boards
> (e.g. beagle)? If so, I don't think we should worry too much about
> listing external boards, setup-environment comes from a
> freescale-specific repository. If someone is following the steps to
> checkout and build for a freescale board (and therefore using
> setup-environment), I think it's a safe enough assumption they're going
> to want to build for one of the boards supported by the freescale BSP
> repositories (or qemu). I don't think it's too much to say that someone
> would be in the wrong place if they were complaining that the freescale
> setup script didn't include options to build for a MIPS64 target :-)
>
> In other words, I believe the setup-environment script provided in
> fsl-community-bsp-base is already freescale-specific. Making it more so
> shouldn't be a problem?

Ok; agreed.

>> 3) In error message, instead of list all boards one before the other, list one machine per line.
>
> Okay.
>
>> I like to prompt user instead of assuming a default machine. But a list of machines is not good when you have 150 machines. And I start to try to group the machines in SOC family, or in meta-fsl-arm/meta-fsl-arm-extra, or any other criteria to help user to decide it.
>
> Actually, an early version of my script did that, but I thought it was
> too "text-y" so I shortened it to just the machine name. I figure the
> person has the board sitting there, they know the board name, so finding
> that name in a list that is sorted alphabetically shouldn't be too hard :-D
>
> But in this decision you can also see my bias. I don't look at the
> boards as being either from freescale or not, so sorting them that way
> is not something I would do by default :-)

I am not sure we ought to split between reference boards and 3rd party
ones. I think what Daiane means here is:

MX23
...
...

MX3
....

MX5
....

MX6
...
Daiane Angolini - March 27, 2014, 7:23 p.m.
> -----Original Message-----
> From: Trevor Woerner [mailto:trevor.woerner@linaro.org]
> Sent: Thursday, March 27, 2014 4:02 PM
> To: Angolini Daiane-B19406; meta-freescale@yoctoproject.org
> Subject: Re: [meta-freescale] [PATCH][fsl-community-bsp-base] setup-
> environment: provide a MACHINE menu
> 
> On 03/27/14 14:08, Daiane.Angolini@freescale.com wrote:
> >> Traditionally I've been hesitant to send patches, but I've decided to
> >> not be as shy anymore. Therefore I don't expect everything I send to
> >> be successful :-)
> > Yes, please, don't be shy anymore and send all patches you have ;-)
> 
> The can of worms is now open :-)

Yumi

> 
> 
> > 2) it only list machines from meta-fsl-arm and meta-fsl-arm-extra. I
> > tried
> >
> > MACHINE="qemuarm" source setup-environment build
> >
> > And I faced a big error message!
> 
> Whoops! I hadn't tested the emulators, but I agree they should certainly be
> in the list too. Getting a big error message isn't what I wanted to have
> happen.
> 
> > I´m not sure if we want to list external boards, but it looks weird to me
> not being able to have a qemu build dir.
> 
> By "external boards" I assume you mean non-ARM or non-freescale boards
> (e.g. beagle)? If so, I don't think we should worry too much about listing
> external boards, setup-environment comes from a freescale-specific
> repository. If someone is following the steps to checkout and build for a
> freescale board (and therefore using setup-environment), I think it's a
> safe enough assumption they're going to want to build for one of the boards
> supported by the freescale BSP repositories (or qemu). I don't think it's
> too much to say that someone would be in the wrong place if they were
> complaining that the freescale setup script didn't include options to build
> for a MIPS64 target :-)
> 
> In other words, I believe the setup-environment script provided in fsl-
> community-bsp-base is already freescale-specific. Making it more so
> shouldn't be a problem?

And in the case a user has its own customer layer /inside/ fsl community bsp environment with a custom board?
Would this case be possible?
Daiane Angolini - March 27, 2014, 7:25 p.m.
> -----Original Message-----
> From: otavio.salvador@gmail.com [mailto:otavio.salvador@gmail.com] On
> Behalf Of Otavio Salvador
> Sent: Thursday, March 27, 2014 4:12 PM
> To: Trevor Woerner
> Cc: Angolini Daiane-B19406; meta-freescale@yoctoproject.org
> Subject: Re: [meta-freescale] [PATCH][fsl-community-bsp-base] setup-
> environment: provide a MACHINE menu
> >
> > But in this decision you can also see my bias. I don't look at the
> > boards as being either from freescale or not, so sorting them that way
> > is not something I would do by default :-)
> 
> I am not sure we ought to split between reference boards and 3rd party
> ones. I think what Daiane means here is:
> 
> MX23
> ...
> ...
> 
> MX3
> ....
> 
> MX5
> ....
> 
> MX6
> ...

When you have 150 imx6 boards, this cluttering is not enough and you must find a second level.

The second level would ~naturaly~ be meta-fsl-arm/extra (naturaly because they are 2 separate layers)

In other hand, I don´t think the clustering approach is the right one to go

Daiane
Otavio Salvador - March 27, 2014, 7:37 p.m.
On Thu, Mar 27, 2014 at 4:25 PM, Daiane.Angolini@freescale.com
<Daiane.Angolini@freescale.com> wrote:
> When you have 150 imx6 boards, this cluttering is not enough and you must find a second level.
>
> The second level would ~naturaly~ be meta-fsl-arm/extra (naturaly because they are 2 separate layers)
>
> In other hand, I don´t think the clustering approach is the right one to go

Yes; or in future we may group it by vendor.

Freescale
...

Boundary Devices
...

SolidRun
...

OLIMEX
...

I am just thinking if it is overkill or not.

Another solution is:

* if machine is set, use it
* if machine is not set:
  - Ask user to go to release notes and choose the machine
  - call again with MACHINE=foo

?
Daiane Angolini - March 27, 2014, 7:54 p.m.
> -----Original Message-----
> From: otavio.salvador@gmail.com [mailto:otavio.salvador@gmail.com] On
> Behalf Of Otavio Salvador
> Sent: Thursday, March 27, 2014 4:38 PM
> To: Angolini Daiane-B19406
> Cc: Trevor Woerner; meta-freescale@yoctoproject.org
> Subject: Re: [meta-freescale] [PATCH][fsl-community-bsp-base] setup-
> environment: provide a MACHINE menu
> 
> On Thu, Mar 27, 2014 at 4:25 PM, Daiane.Angolini@freescale.com
> <Daiane.Angolini@freescale.com> wrote:
> > When you have 150 imx6 boards, this cluttering is not enough and you must
> find a second level.
> >
> > The second level would ~naturaly~ be meta-fsl-arm/extra (naturaly
> > because they are 2 separate layers)
> >
> > In other hand, I don´t think the clustering approach is the right one
> > to go
> 
> Yes; or in future we may group it by vendor.
> 
> Freescale
> ...
> 
> Boundary Devices
> ...
> 
> SolidRun
> ...
> 
> OLIMEX
> ...
> 
> I am just thinking if it is overkill or not.
> 
> Another solution is:
> 
> * if machine is set, use it
> * if machine is not set:
>   - Ask user to go to release notes and choose the machine

I prefer the list of alphabetically sorted 150K machines instead of "go to release notes" approach.

Let´s get is simpler instead of more complex. No need for external sources/infos


Daiane

>   - call again with MACHINE=foo
> 
> ?
> 
> --
> Otavio Salvador                             O.S. Systems
> http://www.ossystems.com.br        http://code.ossystems.com.br
> Mobile: +55 (53) 9981-7854            Mobile: +1 (347) 903-9750
>
Trevor Woerner - March 28, 2014, 4:04 p.m.
On 03/27/14 14:08, Daiane.Angolini@freescale.com wrote:
> 2) it only list machines from meta-fsl-arm and meta-fsl-arm-extra. I tried 
>
> MACHINE="qemuarm" source setup-environment build
>
> And I faced a big error message!
>
> I´m not sure if we want to list external boards, but it looks weird to me not being able to have a qemu build dir.

As it turns out, this is existing behaviour. The build script in its
current form considers "qemuarm" to be invalid. The setup-environment
script is very freescale-specific, and I think that's okay :-)

> 3) In error message, instead of list all boards one before the other, list one machine per line.

This too is existing behaviour; but don't worry, I'm working on some
clean-up patches :-D
Daiane Angolini - March 28, 2014, 4:28 p.m.
> -----Original Message-----
> From: Trevor Woerner [mailto:trevor.woerner@linaro.org]
> Sent: Friday, March 28, 2014 1:05 PM
> To: Angolini Daiane-B19406; meta-freescale@yoctoproject.org
> Subject: Re: [meta-freescale] [PATCH][fsl-community-bsp-base] setup-
> environment: provide a MACHINE menu
> 
> 
> This too is existing behaviour; but don't worry, I'm working on some clean-
> up patches :-D

When you´re working on this, please send me a private email with the console output of the error message, I want to let you know some points I want changed (before you send v2)

It´s some dumb crazy tiny stuff, but I would like to have it changed.

If you don´t mind, of course.

;-)

Daiane

Patch

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`