summaryrefslogtreecommitdiffstats
path: root/scripts
diff options
context:
space:
mode:
authorBruno Bottazzini <bruno.bottazzini@intel.com>2015-09-14 18:29:04 -0300
committerRichard Purdie <richard.purdie@linuxfoundation.org>2015-09-18 09:05:26 +0100
commit935a8bd1d9a20c650a31d654dab9cc7001e68a38 (patch)
tree4fa294802231fb2d7dd13c0d79de5a6ec2ea8a8d /scripts
parent6c05e6a71ad89c398f04f4f0c06bfea1def2d8e7 (diff)
downloadpoky-935a8bd1d9a20c650a31d654dab9cc7001e68a38.tar.gz
mkefidisk: Create interactive menu for the script
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. (From OE-Core rev: 768fb686b8dfd47ff4cb4833ce166c213502f419) Signed-off-by: Bruno Bottazzini <bruno.bottazzini@intel.com> Signed-off-by: Ross Burton <ross.burton@intel.com> Signed-off-by: Richard Purdie <richard.purdie@linuxfoundation.org>
Diffstat (limited to 'scripts')
-rwxr-xr-xscripts/contrib/mkefidisk.sh63
1 files changed, 58 insertions, 5 deletions
diff --git a/scripts/contrib/mkefidisk.sh b/scripts/contrib/mkefidisk.sh
index 55f72b0f54..cd4de05336 100755
--- a/scripts/contrib/mkefidisk.sh
+++ b/scripts/contrib/mkefidisk.sh
@@ -152,8 +152,55 @@ unmount() {
152# Parse and validate arguments 152# Parse and validate arguments
153# 153#
154if [ $# -lt 3 ] || [ $# -gt 4 ]; then 154if [ $# -lt 3 ] || [ $# -gt 4 ]; then
155 usage 155 if [ $# -eq 1 ]; then
156 exit 1 156 AVAILABLE_DISK=`lsblk | grep "disk" | cut -f 1 -d " "`
157 X=0
158 for disk in `echo $AVAILABLE_DISK`; do
159 mounted=`lsblk /dev/$disk | awk {'print $7'} | sed "s/MOUNTPOINT//"`
160 if [ -z "$mounted" ]; then
161 UNMOUNTED_AVAILABLES="$UNMOUNTED_AVAILABLES /dev/$disk"
162 info "$X - /dev/$disk"
163 X=`expr $X + 1`
164 fi
165 done
166 if [ $X -eq 0 ]; then
167 die "No unmounted device found."
168 fi
169 read -p "Choose unmounted device number: " DISK_NUMBER
170 X=0
171 for line in `echo $UNMOUNTED_AVAILABLES`; do
172 if [ $DISK_NUMBER -eq $X ]; then
173 DISK_TO_BE_FLASHED=$line
174 break
175 else
176 X=`expr $X + 1`
177 fi
178 done
179 if [ -z "$DISK_TO_BE_FLASHED" ]; then
180 die "Option \"$DISK_NUMBER\" is invalid. Choose a valid option"
181 else
182 if [ -z `echo $DISK_TO_BE_FLASHED | grep "mmc"` ]; then
183 TARGET_TO_BE_BOOT="/dev/sda"
184 else
185 TARGET_TO_BE_BOOT="/dev/mmcblk0"
186 fi
187 fi
188 echo ""
189 echo "Choose a name of the device that will be boot from"
190 echo -n "Recommended name is: "
191 info "$TARGET_TO_BE_BOOT"
192 read -p "Is target device okay? [y/N]: " RESPONSE
193 if [ "$RESPONSE" != "y" ]; then
194 read -p "Choose target device name: " TARGET_TO_BE_BOOT
195 fi
196 echo ""
197 if [ -z "$TARGET_TO_BE_BOOT" ]; then
198 die "Error: choose a valid target name"
199 fi
200 else
201 usage
202 exit 1
203 fi
157fi 204fi
158 205
159if [ "$1" = "-v" ]; then 206if [ "$1" = "-v" ]; then
@@ -162,9 +209,15 @@ if [ "$1" = "-v" ]; then
162 shift 209 shift
163fi 210fi
164 211
165DEVICE=$1 212if [ -z "$AVAILABLE_DISK" ]; then
166HDDIMG=$2 213 DEVICE=$1
167TARGET_DEVICE=$3 214 HDDIMG=$2
215 TARGET_DEVICE=$3
216else
217 DEVICE=$DISK_TO_BE_FLASHED
218 HDDIMG=$1
219 TARGET_DEVICE=$TARGET_TO_BE_BOOT
220fi
168 221
169LINK=$(readlink $DEVICE) 222LINK=$(readlink $DEVICE)
170if [ $? -eq 0 ]; then 223if [ $? -eq 0 ]; then