From d430d79f9088c9da0870462edbb764e4edec0683 Mon Sep 17 00:00:00 2001 From: Karol Putra Date: Thu, 8 Dec 2016 13:42:06 +0100 Subject: [PATCH] Rework of installer core screens Before and after results: 1. Partition list screen - http://i.imgur.com/cRDvAlH.jpg 2. Create/modify disk screen - http://i.imgur.com/5se9y2U.jpg --- install/scripts/1-install | 117 +++++++++++++++++++++++++++++++++----- 1 file changed, 102 insertions(+), 15 deletions(-) diff --git a/install/scripts/1-install b/install/scripts/1-install index a03b6d2..c2e5b5a 100644 --- a/install/scripts/1-install +++ b/install/scripts/1-install @@ -1,6 +1,7 @@ # # By Chih-Wei Huang -# Last updated 2016/07/21 +# and Karol Putra +# Last updated 2016/12/08 # # License: GNU Public License # We explicitely grant the right to use the scripts @@ -23,7 +24,7 @@ rebooting() choose() { dialog --clear --title " $1 " \ - --menu "$2" 20 71 13 --file $menufile 2> $tempfile + --menu "$2" 20 90 13 --file $menufile 2> $tempfile retval=$? choice=`cat $tempfile` @@ -43,9 +44,26 @@ partition_drive() echo -n ' "Removable' >> $menufile fi if [ -f $i/size ]; then - echo -n " (" `cat $i/size` "blocks)" >> $menufile + size=$(cat $i/size) + if [ $size ]; then + # Any better way to get GBs? + size_gb_long=$(dc $size 2097152 div p) + size_gb_short=$(printf "%0.2fGB" $size_gb_long) + if [ "$size_gb_short" = "0.00GB" ]; then + printf " %9s" " <0.01GB" >> $menufile + else + printf " %9s" $size_gb_short >> $menufile + fi + else + printf " %9s" "unknown" >> $menufile + fi fi + cd /sys/block + for f in "$i"/device/model "$i"/device/name */"$i"/../device/model */"$i"/../device/name; do + [ -e $f ] && model_name=`cat $f | sed $'s/\x04//g'` && echo -n " ${model_name}" >> $menufile && break + done echo '"' >> $menufile + cd / done count=`wc -l $menufile | awk '{ print $1 }'` if [ $count -eq 0 ]; then @@ -75,6 +93,73 @@ partition_drive() return $retval } +print_partition_info() +{ + partition=$1 + # Must be as first + printf "%-10s " $partition + + # Filesystem + intempfile=$(grep "$partition:" $tempfile) + if [ "$intempfile" ];then + fstype=$(echo $intempfile | awk '{print $2}') + printf "%-10s " $fstype + else + printf "%-10s " unknown + fi + + # Label + label=$(/system/bin/blkid -s LABEL -o value /dev/*$partition | head -1) + if [ "$label" ];then + printf "%-15s " "$label" + else + printf "%-15s " " --- " + fi + + # Free space + tempmount=/tmp/tempmount + mkdir -p $tempmount + mount /dev/*$partition $tempmount 2>/dev/null + ntfs-3g /dev/*$partition $tempmount 2>/dev/null + mounted=$(df | grep -w $tempmount) + if [ "$mounted" ]; then + free=`df -k $tempmount | tail -1 | awk '{print $4}'` + umount $tempmount 2>/dev/null + # Any better way to get GBs? + free_gb_long=`dc $free 1048576 div p` + free_gb_short=`printf "%0.2fGB" $free_gb_long` + if [ "$free_gb_short" = "0.00GB" ]; then + printf "%9s " "<0.01GB" + else + printf "%9s " $free_gb_short + fi + else + umount $tempmount 2>/dev/null + printf "%9s " unknown + fi + + # Full size + size=$(cat /sys/block/*/$partition/size) + if [ $size ]; then + # Any better way to get GBs? + size_gb_long=$(dc $size 2097152 div p) + size_gb_short=$(printf "%0.2fGB" $size_gb_long) + if [ "$size_gb_short" = "0.00GB" ]; then + printf "%9s " "<0.01GB" + else + printf "%9s " $size_gb_short + fi + else + printf "%9s " "unknown" + fi + + # DEVICE MODEL OR NAME + cd /sys/block + for f in "$partition"/device/model "$partition"/device/name */"$partition"/../device/model */"$partition"/../device/name; do + [ -e $f ] && model_name=`cat $f | sed $'s/\x04//g'` && printf "%-15s" "$model_name" && break + done +} + select_dev() { blkid | grep -v -E "^/dev/block/|^/dev/loop" | cut -b6- | sort | awk '{ @@ -87,22 +172,24 @@ select_dev() gsub(/TYPE=|"/, "", t) printf("%s\t%s\n", $1, t) }' > $tempfile - + + printf "\"Create/Modify partitions\" \"\"\n\"Detect devices\" \"\"\n\"\" \"\"\n" > $menufile lsblk=`ls /sys/block | grep -v -E "loop|ram|sr|boot|rpmb"` for d in $lsblk; do for i in /sys/block/$d/$d*; do echo $i | grep -q -E "boot|rpmb" && continue - [ -d $i ] && ( grep "`basename $i:`" $tempfile || echo "`basename $i` unknown" ) - done - done | awk '{ - sub(/:/, "", $1) - printf("\"%-13s%-17s", $1, $2) - system("cd /sys/block; for f in "$1"/device/model "$1"/device/name */"$1"/../device/model */"$1"/../device/name; do [ -e $f ] && echo -n `cat $f` && break; done") - printf("\" \"\"\n") - } END { - printf("\"Create/Modify partitions\" \"\"\n\"Detect devices\" \"\"") - }' > $menufile - choose "Choose Partition" "Please select a partition to install Android-x86:" + if [ -d $i ]; then + partition=$(basename $i) + #Begin menuentry + printf "\"" + #Fill in data - reorderable in function + print_partition_info $partition + #End menuentry + printf "\" \"\"\n" + fi + done && printf "\"\" \"\"\n" >> $menufile + done >> $menufile + choose "Remix OS Installer" " Remix OS requires at least XGB of disk space.\n Select partition for Remix OS or use one of available options:\n\n Partition | Filesystem | Label | Free space | Size | Drive name/model" return $retval }