From: Saul Wold <sgw@linux.intel.com>
To: Bruno Bottazzini <bruno.bottazzini@intel.com>,
openembedded-core@lists.openembedded.org, "Hart,
Darren" <darren.hart@intel.com>
Subject: Re: [PATCH] scripts: Create interactive menu for mkefidisk script
Date: Thu, 3 Sep 2015 16:36:10 -0700 [thread overview]
Message-ID: <55E8D96A.80403@linux.intel.com> (raw)
In-Reply-To: <1441135341-2048-1-git-send-email-bruno.bottazzini@intel.com>
On 09/01/2015 12:22 PM, Bruno Bottazzini wrote:
> If it is passed only the image parameter, it will show some interactive
> options to help to conclude the script.
>
> With this patch it will detect devices available in the machine, asking
> to choose what it is wanted to be flashed.
>
> it will suggest the target device. If it is a SD card the suggestion
> is /dev/mmcblk0. If it is a pendrive it will suggest to use /dev/sda.
>
I am little concerned by this patch since it allows the root disk to be
selected, even if someone can type it on the command line, but offering
it in list would make someone believe that it was OK.
> Signed-off-by: Bruno Bottazzini <bruno.bottazzini@intel.com>
> ---
> scripts/contrib/mkefidisk.sh | 60 ++++++++++++++++++++++++++++++++++++++++----
> 1 file changed, 55 insertions(+), 5 deletions(-)
>
> diff --git a/scripts/contrib/mkefidisk.sh b/scripts/contrib/mkefidisk.sh
> index 55f72b0..7628de7 100755
> --- a/scripts/contrib/mkefidisk.sh
> +++ b/scripts/contrib/mkefidisk.sh
> @@ -152,8 +152,52 @@ unmount() {
> # Parse and validate arguments
> #
> if [ $# -lt 3 ] || [ $# -gt 4 ]; then
> - usage
> - exit 1
> + if [ $# -eq 1 ]; then
> + AVAILABLE_DISK=`fdisk -l | grep "Disk /" | cut -f 1 -d ':' | cut -f 2 -d ' '`
> + if [ -z "$AVAILABLE_DISK" ]; then
> + die "Starting mkefidisk.sh as root is required"
> + fi
> + echo "Available disks are"
> + X=0
> + for line in `echo $AVAILABLE_DISK`; do
> + info "$X - $line"
> + X=`expr $X + 1`
> + done
> + read -p "Choose flashable device number: " DISK_NUMBER
> + X=0
> + for line in `echo $AVAILABLE_DISK`; do
> + if [ $DISK_NUMBER -eq $X ]; then
> + DISK_TO_BE_FLASHED=$line
> + break
> + else
> + X=`expr $X + 1`
> + fi
> + done
> + if [ -z "$DISK_TO_BE_FLASHED" ]; then
> + die "Option \"$DISK_NUMBER\" is invalid. Choose a valid option"
> + else
> + if [ -z `echo $DISK_TO_BE_FLASHED | grep "mmc"` ]; then
> + TARGET_TO_BE_BOOT="/dev/sda"
> + else
> + TARGET_TO_BE_BOOT="/dev/mmcblk0"
> + fi
> + fi
> + echo ""
> + echo "Choose a name of the device that will be boot from"
> + echo -n "Recommended name is: "
> + info "$TARGET_TO_BE_BOOT\n"
The \n usage is probably wrong here.
> + read -p "Is target device okay? [y/N]: " RESPONSE
> + if [ "$RESPONSE" != "y" ]; then
> + read -p "Choose target device name: " TARGET_TO_BE_BOOT
> + fi
> + echo ""
> + if [ -z "$TARGET_TO_BE_BOOT" ]; then
> + die "Error: choose a valid target name"
> + fi
> + else
> + usage
> + exit 1
> + fi
> fi
>
> if [ "$1" = "-v" ]; then
> @@ -162,9 +206,15 @@ if [ "$1" = "-v" ]; then
> shift
> fi
>
> -DEVICE=$1
> -HDDIMG=$2
> -TARGET_DEVICE=$3
> +if [ -z "$AVAILABLE_DISK" ]; then
> + DEVICE=$1
> + HDDIMG=$2
> + TARGET_DEVICE=$3
> +else
> + DEVICE=$DISK_TO_BE_FLASHED
> + HDDIMG=$1
> + TARGET_DEVICE=$TARGET_TO_BE_BOOT
> +fi
>
> LINK=$(readlink $DEVICE)
> if [ $? -eq 0 ]; then
>
next prev parent reply other threads:[~2015-09-03 23:36 UTC|newest]
Thread overview: 5+ messages / expand[flat|nested] mbox.gz Atom feed top
2015-09-01 19:22 [PATCH] scripts: Create interactive menu for mkefidisk script Bruno Bottazzini
2015-09-03 16:28 ` Bottazzini, Bruno
2015-09-03 23:36 ` Saul Wold [this message]
2015-09-04 13:32 ` Bottazzini, Bruno
2015-09-04 13:36 ` Bottazzini, Bruno
Reply instructions:
You may reply publicly to this message via plain-text email
using any one of the following methods:
* Save the following mbox file, import it into your mail client,
and reply-to-all from there: mbox
Avoid top-posting and favor interleaved quoting:
https://en.wikipedia.org/wiki/Posting_style#Interleaved_style
* Reply using the --to, --cc, and --in-reply-to
switches of git-send-email(1):
git send-email \
--in-reply-to=55E8D96A.80403@linux.intel.com \
--to=sgw@linux.intel.com \
--cc=bruno.bottazzini@intel.com \
--cc=darren.hart@intel.com \
--cc=openembedded-core@lists.openembedded.org \
/path/to/YOUR_REPLY
https://kernel.org/pub/software/scm/git/docs/git-send-email.html
* If your mail client supports setting the In-Reply-To header
via mailto: links, try the mailto: link
Be sure your reply has a Subject: header at the top and a blank line
before the message body.
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.