diff options
author | bill-auger <mr.j.spam.me@gmail.com> | 2022-08-16 09:21:13 -0400 |
---|---|---|
committer | bill-auger <mr.j.spam.me@gmail.com> | 2022-08-17 06:37:01 -0400 |
commit | ffc78c28309b7789d821dd3683924dc8f3026ce1 (patch) | |
tree | 3ae3f8c2ac5db30ca1d295557a353b701e61588a | |
parent | d27bb2c7a41a266bcf86628e1e147b03ae7968b3 (diff) |
prompt to re-format target partitions
-rwxr-xr-x | install.sh | 36 | ||||
-rw-r--r-- | session-common.sh.inc | 1 | ||||
-rw-r--r-- | translations.sh.inc | 16 |
3 files changed, 37 insertions, 16 deletions
@@ -533,29 +533,43 @@ Partition() # switch automatic/manual partitioning [[ "$(GetStateVar 'PART_METHOD')" == 'auto' ]] && _PartitionAuto || _PartitionManual - # sanity checks - AreConfiguredStateVars 'ROOT_PART' - declare -A partitions=( [Root]=$(GetStateVar 'ROOT_PART') \ [Boot]=$(GetStateVar 'BOOT_PART') \ [Home]=$(GetStateVar 'HOME_PART') ) + local err_msg="${TR[part_error-${Lang}]}" local partition_role local partition local dlg_msg - # format un-formatted partitions + # sanity checks + AreConfiguredStateVars 'ROOT_PART' + + # format un-formatted partitions or re-format formatted partiions for partition_role in ${!partitions[@]} do partition=${partitions[${partition_role}]} - dlg_msg="${partition_role} partiion: ${partition} ${TR[format-${Lang}]}" [[ -n "${partition}" ]] || continue - # prompt to format un-formatted partiion - ! blkid ${partition} | grep ' TYPE="' &> /dev/null && \ - (( $( WizardDlg "${TR[dlg_part-${Lang}]}" --yesno "${dlg_msg}" 20 70 ) )) && \ - mkfs.ext4 ${partition} > /dev/null || true + # let's be paranoid about this (also, so pipefail is not needed below) + # GetDisksPartsData() has ensured that /mnt exists and nothing is mounted on it + blkid ${partition} > /dev/null || ExitFail "${err_msg}" + + # determine whether each target partition is already formatted + if blkid ${partition} | grep ' TYPE="' &> /dev/null + then mount ${partition} /mnt + if [[ -n "$(ls --almost-all /mnt)" ]] + then dlg_msg="${partition_role} partiion: ${partition} ${TR[reformat-${Lang}]}" + fi + umount ${partition} + else dlg_msg="${partition_role} partiion: ${partition} ${TR[format-${Lang}]}" + fi + + # prompt to re-format formatted partiion or format un-formatted partition + if (( $( WizardDlg "${TR[dlg_part-${Lang}]}" --yesno "${dlg_msg}" 20 70 ) )) + then yes | mkfs.ext4 -q ${partition} + fi - # final validation - blkid ${partition} | grep ' TYPE="' &> /dev/null || ExitFail "${TR[abort-${Lang}]}" + # final verification + blkid ${partition} | grep ' TYPE="' &> /dev/null || ExitFail "${err_msg}" done # mount partitions diff --git a/session-common.sh.inc b/session-common.sh.inc index 6c82854..165cdd9 100644 --- a/session-common.sh.inc +++ b/session-common.sh.inc @@ -192,6 +192,7 @@ declare -a DlgParams # dialog options UnmountAll() { + mkdir -p /mnt umount /mnt/boot &> /dev/null || true umount /mnt/home &> /dev/null || true umount /mnt &> /dev/null || true diff --git a/translations.sh.inc b/translations.sh.inc index 4f0a28c..24162d6 100644 --- a/translations.sh.inc +++ b/translations.sh.inc @@ -502,17 +502,23 @@ declare -r -A TR=( ## install.sh::Partition() ## + [reformat-en]="contains existing files. Do you want to delete them?" + [reformat-eo]="tenas ekzistantaj dosieroj. Ĉu vi volas forigi tiujn?" + [reformat-es]="contiene archivos existentes. ¿Quieres eliminarlos?" + [reformat-gl]="contén ficheiros existentes. ¿Queres eliminalos?" + [reformat-pt]="contém arquivos existentes. Você quer excluí -los?" + [format-en]="does not appear to be formatted. The installer can not continue unless it is formatted. Do you want to format it with EXT4 now?" [format-eo]="ne aspektas kiel strukturita. La instalilo ne povas progresi, krom se ĝin estas strukturita. Ĉu vi volas strukturas ĝin kiel EXT4 nun?" [format-es]="no parece estar formateado. El instalador no puede continuar a menos que esté formateado. ¿Quieres formatearlo con EXT4 ahora?" [format-gl]="non parece ter formato. O instalador non pode continuar a menos que estea formatado. ¿Quere formatalo agora con EXT4?" [format-pt]="não parece estar formatado. O instalador não pode continuar a menos que seja formatado. Quer formatar com EXT4 agora?" - [abort-en]="The installer must abort now. The installation can be restarted or resumed." - [abort-eo]="La instalilo devas ĉesigi nun. La instalado eblas restarti aŭ rekomenci." - [abort-es]="La instalación debe abortar ahora. La instalación se puede reiniciar o reanudar." - [abort-gl]="A instalación debe abortar agora. A instalación pódese reiniciar ou retomar." - [abort-pt]="A instalação deve abortar agora. A instalação pode ser reiniciada ou retomada." + [part_error-en]="is not usable. The installation can be restarted or resumed." + [part_error-eo]="ne estas uzebla. La instalado eblas restarti aŭ rekomenci." + [part_error-es]="no es utilizable. La instalación se puede reiniciar o reanudar." + [part_error-gl]="non se pode usar. A instalación pódese reiniciar ou retomar." + [part_error-pt]="não é utilizável. A instalação pode ser reiniciada ou retomada." ## install.sh::InstallPkgs() ## |