From patchwork Wed Mar 26 19:33:27 2014 Content-Type: text/plain; charset="utf-8" MIME-Version: 1.0 Content-Transfer-Encoding: 7bit X-Patchwork-Submitter: Trevor Woerner X-Patchwork-Id: 27160 Return-Path: X-Original-To: linaro@patches.linaro.org Delivered-To: linaro@patches.linaro.org Received: from mail-oa0-f69.google.com (mail-oa0-f69.google.com [209.85.219.69]) by ip-10-151-82-157.ec2.internal (Postfix) with ESMTPS id D64F420369 for ; Wed, 26 Mar 2014 19:34:26 +0000 (UTC) Received: by mail-oa0-f69.google.com with SMTP id i7sf9042830oag.8 for ; Wed, 26 Mar 2014 12:34:26 -0700 (PDT) X-Google-DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=1e100.net; s=20130820; h=x-gm-message-state:mime-version:delivered-to:from:to:cc:subject :date:message-id:x-original-sender:x-original-authentication-results :precedence:mailing-list:list-id:list-post:list-help:list-archive :list-unsubscribe; bh=XZn6WOQDM2l4t5FMDxZ+qVPKn4fO0orTdlc64ijzOms=; b=d4RbvTbhBBs5iKXQHu1Ni1/NM7HxPUiZwQunRcvjGU6nK7n7Ngklbh4xN8D+5itz6a TYg6RU99fc288rHQ5kEnvzD7UMAClmul1p5r0EvCE2L2gI9iLSpgV5mjICporSPSOumy 3/Hb6psgKgDOaj4hieR9cQ+Q/7xU99FIwKeL/exnyKFTXPVVf1RVrKANw+RA09FKhJRW 3pXFgjQ/fsocEj6yBR8feK2RPvBMTnhuMPvRvmsiSypcd1KH5TpI6xoYg5NGk1eUbWqN NffiNxpNj4try2MNbZjf96GJhKC5p44SqWu7+F0tAFI/tI5lTApCIEqG3U0h893R4DCf i1uw== X-Gm-Message-State: ALoCoQmXoSafG1g5CqGQun0fLUoeQAyDy83qmifRpnHTBKckqLeuVcnyzWwx8bxwexsWJFWo1cqd X-Received: by 10.43.139.66 with SMTP id iv2mr29861914icc.17.1395862466356; Wed, 26 Mar 2014 12:34:26 -0700 (PDT) MIME-Version: 1.0 X-BeenThere: patchwork-forward@linaro.org Received: by 10.140.20.22 with SMTP id 22ls779559qgi.63.gmail; Wed, 26 Mar 2014 12:34:26 -0700 (PDT) X-Received: by 10.52.90.37 with SMTP id bt5mr25417515vdb.7.1395862466218; Wed, 26 Mar 2014 12:34:26 -0700 (PDT) Received: from mail-ve0-f177.google.com (mail-ve0-f177.google.com [209.85.128.177]) by mx.google.com with ESMTPS id p4si4772615vem.30.2014.03.26.12.34.26 for (version=TLSv1 cipher=ECDHE-RSA-RC4-SHA bits=128/128); Wed, 26 Mar 2014 12:34:26 -0700 (PDT) Received-SPF: neutral (google.com: 209.85.128.177 is neither permitted nor denied by best guess record for domain of patch+caf_=patchwork-forward=linaro.org@linaro.org) client-ip=209.85.128.177; Received: by mail-ve0-f177.google.com with SMTP id sa20so2888965veb.36 for ; Wed, 26 Mar 2014 12:34:26 -0700 (PDT) X-Received: by 10.220.147.16 with SMTP id j16mr34298835vcv.14.1395862465399; Wed, 26 Mar 2014 12:34:25 -0700 (PDT) X-Forwarded-To: patchwork-forward@linaro.org X-Forwarded-For: patch@linaro.org patchwork-forward@linaro.org Delivered-To: patches@linaro.org Received: by 10.220.78.9 with SMTP id i9csp72103vck; Wed, 26 Mar 2014 12:34:25 -0700 (PDT) X-Received: by 10.182.150.40 with SMTP id uf8mr65319956obb.19.1395862463981; Wed, 26 Mar 2014 12:34:23 -0700 (PDT) Received: from mail-oa0-f42.google.com (mail-oa0-f42.google.com [209.85.219.42]) by mx.google.com with ESMTPS id j8si3182016oey.71.2014.03.26.12.34.23 for (version=TLSv1 cipher=ECDHE-RSA-RC4-SHA bits=128/128); Wed, 26 Mar 2014 12:34:23 -0700 (PDT) Received-SPF: neutral (google.com: 209.85.219.42 is neither permitted nor denied by best guess record for domain of trevor.woerner@linaro.org) client-ip=209.85.219.42; Received: by mail-oa0-f42.google.com with SMTP id i4so3161505oah.1 for ; Wed, 26 Mar 2014 12:34:23 -0700 (PDT) X-Received: by 10.60.51.69 with SMTP id i5mr9891843oeo.17.1395862463636; Wed, 26 Mar 2014 12:34:23 -0700 (PDT) Received: from openSUSE-i7.site (69-165-220-158.dsl.teksavvy.com. [69.165.220.158]) by mx.google.com with ESMTPSA id y10sm6943054obk.4.2014.03.26.12.34.22 for (version=TLSv1.2 cipher=ECDHE-RSA-AES128-GCM-SHA256 bits=128/128); Wed, 26 Mar 2014 12:34:22 -0700 (PDT) From: Trevor Woerner To: meta-freescale@yoctoproject.org Cc: patches@linaro.org, Otavio Salvador , Mahesh Mahadevan , Timur Aydin Subject: [PATCH][fsl-community-bsp-base] setup-environment: provide a MACHINE menu Date: Wed, 26 Mar 2014 15:33:27 -0400 Message-Id: <1395862407-29020-1-git-send-email-trevor.woerner@linaro.org> X-Mailer: git-send-email 1.9.0 X-Removed-Original-Auth: Dkim didn't pass. X-Original-Sender: trevor.woerner@linaro.org X-Original-Authentication-Results: mx.google.com; spf=neutral (google.com: 209.85.128.177 is neither permitted nor denied by best guess record for domain of patch+caf_=patchwork-forward=linaro.org@linaro.org) smtp.mail=patch+caf_=patchwork-forward=linaro.org@linaro.org Precedence: list Mailing-list: list patchwork-forward@linaro.org; contact patchwork-forward+owners@linaro.org List-ID: X-Google-Group-Id: 836684582541 List-Post: , List-Help: , List-Archive: List-Unsubscribe: , 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 --- 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 : 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= source $PROGNAME + MACHINE= source $PROGNAME +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`