From: Priya N S <priya...@ti.com>

From: Priya N S <priya...@ti.com>

* Validate user input of rootfs tarball selection.
* This will not allow the user to proceed with wrong rootfs
  tarball selection.

Signed-off-by: Priya N S <priya...@ti.com>
Signed-off-by: Sekhar Nori <nsek...@ti.com>
---
 create-sdcard.sh | 16 +++++++++++++---
 1 file changed, 13 insertions(+), 3 deletions(-)

diff --git a/create-sdcard.sh b/create-sdcard.sh
index 264095a..8f99687 100644
--- a/create-sdcard.sh
+++ b/create-sdcard.sh
@@ -767,9 +767,19 @@ cat << EOM
 
 EOM
                ls --sort=size $ROOTFILEPARTH | grep "tisdk.*image" | grep 
'tar.xz' | grep -n '' | awk {'print "        " , $1'}
-               echo ""
-               read -p "Enter Number of rootfs Tarball: " TARNUMBER
-               echo " "
+               COUNT=`ls $ROOTFILEPARTH | grep "tisdk.*image" | grep 'tar.xz' 
| grep -n '' | awk {'print $1'} | wc -l`
+               ENTERCORRECTLY="0"
+               while [ $ENTERCORRECTLY -ne 1 ]
+               do
+                       read -p "Enter Number of rootfs Tarball: " TARNUMBER
+                       echo " "
+                       if [ -z "${TARNUMBER//[0-$COUNT]}" ] && [ -n 
"$TARNUMBER" ] ; then
+                               ENTERCORRECTLY=1
+                       else
+                               echo "Invalid selection!"
+                       fi
+                       echo ""
+               done
                FOUNDTARFILENAME=`ls --sort=size $ROOTFILEPARTH | grep "image" 
| grep 'tar.xz' | grep -n '' | grep "${TARNUMBER}:" | cut -c3- | awk 
{'print$1'}`
                ROOTFSTAR=$FOUNDTARFILENAME
 
-- 
2.19.1.windows.1

_______________________________________________
meta-arago mailing list
meta-arago@arago-project.org
http://arago-project.org/cgi-bin/mailman/listinfo/meta-arago

Reply via email to