Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

Rework of installer core screens #3

Open
wants to merge 1 commit into
base: jide_x86_marshmallow
Choose a base branch
from
Open
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
117 changes: 102 additions & 15 deletions install/scripts/1-install
Original file line number Diff line number Diff line change
@@ -1,6 +1,7 @@
#
# By Chih-Wei Huang <[email protected]>
# Last updated 2016/07/21
# and Karol Putra <[email protected]>
# Last updated 2016/12/08
#
# License: GNU Public License
# We explicitely grant the right to use the scripts
Expand All @@ -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`
Expand All @@ -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
Expand Down Expand Up @@ -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 '{
Expand All @@ -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"
Copy link
Author

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Replace the X with the appropriate number of GBs required for the OS.

return $retval
}

Expand Down