# Helper functions
function distro_picker {
  dialog_choices=
  available_distros=`ls $OE_BUILD_MNT/org.openembedded.dev/conf/distro/ | grep .conf | sed s/\.conf//g`
  default_distro=`ls $OE_BUILD_MNT/org.openembedded.dev/conf/distro/ | grep .conf | sed s/\.conf//g | grep openzaurus | grep - | sort | head -1`
  for target_distro in $available_distros; do
    dialog_choices=$(echo $dialog_choices $target_distro \'\' `if [ "$target_distro" == "$default_distro" ]; then echo on; else echo off; fi`)
  done

  whiptail                                             \
       --title 'Distro'                                \
       --radiolist 'Which distro do you want to build?'\
       0 0 0                                           \
       $dialog_choices
}

function machine_picker {
  dialog_choices=
  available_machines=`ls $OE_BUILD_MNT/org.openembedded.dev/conf/machine/ | grep .conf | sed s/\.conf//g`
  default_machine=`ls $OE_BUILD_MNT/org.openembedded.dev/conf/machine/ | grep .conf | sed s/\.conf//g | grep collie | sort | head -1`
  for target_machine in $available_machines; do
    dialog_choices=$(echo $dialog_choices $target_machine \'\' `if [ "$target_machine" == "$default_machine" ]; then echo on; else echo off; fi`)
  done

  whiptail                                                  \
       --title 'Machine'                                    \
       --radiolist 'Which machine do you want to build for?'\
       0 0 0                                                \
       $dialog_choices
}

#one command to make rebuild
bbrebuild()
{
  bitbake -b $1 --cmd=clean
  bitbake -b $1
}
