summaryrefslogtreecommitdiff
diff options
context:
space:
mode:
authorbill-auger <mr.j.spam.me@gmail.com>2022-08-17 06:33:52 -0400
committerbill-auger <mr.j.spam.me@gmail.com>2022-08-17 06:38:18 -0400
commit89bee2d1cfde6f60779842c4657578bff2dab903 (patch)
tree83c023ae4d020ea0880d4f454af594a55376703c
parentf65c08b70d73188fec4c954b0144f9784de6129c (diff)
move PartitionAuto() into "non-interactive destructive" stage
-rwxr-xr-xinstall.sh183
-rw-r--r--translations.sh.inc86
2 files changed, 135 insertions, 134 deletions
diff --git a/install.sh b/install.sh
index 14dc795..aeacab7 100755
--- a/install.sh
+++ b/install.sh
@@ -420,64 +420,56 @@ SelectPartition()
[[ -n "${part_method}" ]] && SetStateVar 'PART_METHOD' ${part_method} || exit
}
-NoticeReady()
+_FormatAndMount()
{
- # checks to skip this stage per preset config
- ! AreConfiguredStateVars 'READY' || return 0
-
- local ready_msg="${TR[notice_ready-${Lang}]}"
-
- if [[ "$(GetStateVar 'PART_METHOD')" == 'auto' ]]
- then ready_msg+="\n\n\Z1${TR[ready_warn-${Lang}]}\Zn\n\n * $(GetStateVar 'DEVICE')"
- fi
-
- (( $( WizardDlg "${TR[dlg_ready-${Lang}]}" --yesno "${ready_msg}" 0 0 ) )) || exit
-}
+ declare -A partitions=( [Root]=$(GetStateVar 'ROOT_PART') \
+ [Boot]=$(GetStateVar 'BOOT_PART') \
+ [Home]=$(GetStateVar 'HOME_PART') )
+ local partition_role
+ local partition
+ local dlg_msg
-_PartitionAuto()
-{
# sanity checks
- AreConfiguredStateVars 'DEVICE'
+ AreConfiguredStateVars 'ROOT_PART'
- # checks to skip this stage per preset config
- # NOTE: this is the only path for preset unattended-install configurations
- # it currently supports only a single disk (root and swap partitions)
- if [[ -n "$(GetStateVar 'ROOT_PART')" ]]
- then SetStateVar 'BOOT_PART' ''
- SetStateVar 'HOME_PART' ''
- return 0
- fi
+ # format un-formatted partitions or re-format formatted partiions
+ for partition_role in ${!partitions[@]}
+ do partition=${partitions[${partition_role}]}
+ [[ -n "${partition}" ]] || continue
- # automatic partitioning
- local device=$(GetStateVar 'DEVICE')
- local offset_mb=1
- local root_part_n=1
- local swap_part_n=2
- local root_type_n=83
- local swap_type_n=82
- SetStateVar 'ROOT_PART' ${device}${root_part_n}
+ # 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 "${TR[part_error-${Lang}]}"
- # create partition table
- parted -s ${device} -- mklabel msdos
+ # 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
- # configure partitions
- parted -s ${device} -- mkpart primary ${offset_mb}MiB -${SWAP_MB}MiB # $root_part_n
- parted -s ${device} -- mkpart primary -${SWAP_MB}MiB -1s # $swap_part_n
- parted -s ${device} -- set ${root_part_n} boot on
+ # 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
+ls -a /mnt
+ # final verification
+ blkid ${partition} | grep ' TYPE="' > /dev/null || ExitFail "${TR[part_error-${Lang}]}"
+ done
- # format partitions
- format() # (device part_n type_n)
- {
- sleep 0.5 ; partprobe ;
- (echo t ; echo ${part_n} ; echo ${type_n} ; echo w) | fdisk ${device}
- }
- format ${device} ${root_part_n} ${root_type_n} &> /dev/null
- format ${device} ${swap_part_n} ${swap_type_n} &> /dev/null
- yes | mkfs.ext4 ${device}${root_part_n} &> /dev/null
- mkswap ${device}${swap_part_n} &> /dev/null
+ # mount partitions
+ if [[ -n "${partitions[Root]}" ]] ; then mkdir -p /mnt ;
+ mount ${partitions[Root]} /mnt ; fi ;
+ if [[ -n "${partitions[Boot]}" ]] ; then mkdir -p /mnt/boot ;
+ mount ${partitions[Boot]} /mnt/boot ; fi ;
+ if [[ -n "${partitions[Home]}" ]] ; then mkdir -p /mnt/home ;
+ mount ${partitions[Home]} /mnt/home ; fi ;
}
-_PartitionManual()
+PartitionManual()
{
# sanity checks
AreConfiguredStateVars 'DEVICE' 'DEVICE_N'
@@ -526,59 +518,67 @@ _PartitionManual()
RemovePartOption ${part_n}
fi
fi
+
+ _FormatAndMount
}
-Partition()
+NoticeReady()
{
- # switch automatic/manual partitioning
- [[ "$(GetStateVar 'PART_METHOD')" == 'auto' ]] && _PartitionAuto || _PartitionManual
+ # checks to skip this stage per preset config, or if manually partitioning
+ ! AreConfiguredStateVars 'READY' || return 0
- 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
+ local ready_msg="${TR[notice_ready-${Lang}]}"
+ if [[ "$(GetStateVar 'PART_METHOD')" == 'auto' ]]
+ then ready_msg+="\n\n\Z1${TR[ready_warn-${Lang}]}\Zn\n\n * $(GetStateVar 'DEVICE')"
+ fi
+
+ (( $( WizardDlg "${TR[dlg_ready-${Lang}]}" --yesno "${ready_msg}" 0 0 ) )) || exit
+}
+
+PartitionAuto()
+{
# sanity checks
- AreConfiguredStateVars 'ROOT_PART'
+ AreConfiguredStateVars 'DEVICE'
- # format un-formatted partitions or re-format formatted partiions
- for partition_role in ${!partitions[@]}
- do partition=${partitions[${partition_role}]}
- [[ -n "${partition}" ]] || continue
+ # checks to skip this stage per preset config
+ # NOTE: this is the only path for preset unattended-install configurations
+ # it currently supports only a single disk (root and swap partitions)
+ if [[ -n "$(GetStateVar 'ROOT_PART')" ]]
+ then SetStateVar 'BOOT_PART' ''
+ SetStateVar 'HOME_PART' ''
+ return 0
+ fi
- # 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}"
+ # automatic partitioning
+ local device=$(GetStateVar 'DEVICE')
+ local offset_mb=1
+ local root_part_n=1
+ local swap_part_n=2
+ local root_type_n=83
+ local swap_type_n=82
+ SetStateVar 'ROOT_PART' ${device}${root_part_n}
- # 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
+ # create partition table
+ parted -s ${device} -- mklabel msdos
- # 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
+ # configure partitions
+ parted -s ${device} -- mkpart primary ${offset_mb}MiB -${SWAP_MB}MiB # $root_part_n
+ parted -s ${device} -- mkpart primary -${SWAP_MB}MiB -1s # $swap_part_n
+ parted -s ${device} -- set ${root_part_n} boot on
- # final verification
- blkid ${partition} | grep ' TYPE="' &> /dev/null || ExitFail "${err_msg}"
- done
+ # format partitions
+ format() # (device part_n type_n)
+ {
+ sleep 0.5 ; partprobe ;
+ (echo t ; echo ${part_n} ; echo ${type_n} ; echo w) | fdisk ${device}
+ }
+ format ${device} ${root_part_n} ${root_type_n} &> /dev/null
+ format ${device} ${swap_part_n} ${swap_type_n} &> /dev/null
+ yes | mkfs.ext4 ${device}${root_part_n} &> /dev/null
+ mkswap ${device}${swap_part_n} &> /dev/null
- # mount partitions
- if [[ -n "${partitions[Root]}" ]] ; then mkdir -p /mnt ;
- mount ${partitions[Root]} /mnt ; fi ;
- if [[ -n "${partitions[Boot]}" ]] ; then mkdir -p /mnt/boot ;
- mount ${partitions[Boot]} /mnt/boot ; fi ;
- if [[ -n "${partitions[Home]}" ]] ; then mkdir -p /mnt/home ;
- mount ${partitions[Home]} /mnt/home ; fi ;
+ _FormatAndMount
}
InstallPkgs()
@@ -674,10 +674,11 @@ SelectEnv # Set environment parameters for the target system (bypassed p
## essential interactive destructive steps ##
NoticePartition # Explain that the next decisions are mandatory, and destructive
SelectPartition # Choose to partition manually or defer to automatic
-NoticeReady # Display chosen options and offer last chance to bail
-Partition # Partition and mount target disks (may or may not be interactive)
+PartitionManual # Partition and mount target disks (if partitioning manually)
## essential non-interactive destructive steps ##
+NoticeReady # Display chosen options and offer last chance to bail
+PartitionAuto # Partition and mount target disks (if partitioning automatically)
InstallPkgs # Install packages with pacstrap
ConfigChroot # Generate fstab, register login, configure services (in-chroot)
NoticeDone # Yay!!!
diff --git a/translations.sh.inc b/translations.sh.inc
index 24162d6..6dd9cea 100644
--- a/translations.sh.inc
+++ b/translations.sh.inc
@@ -440,28 +440,28 @@ declare -r -A TR=(
[part_man-pt]="Usar o gparted para personalizar"
- ## install.sh::NoticeReady() ##
+ ## install.sh::_FormatAndMount() ##
- [dlg_ready-en]="Stage 5 - Installation"
- [dlg_ready-eo]="Etapo 5 - Instalado"
- [dlg_ready-es]="Etapa 5 - Instalación"
- [dlg_ready-gl]="Etapa 5 - Instalación"
- [dlg_ready-pt]="Etapa 5 - Instalação"
+ [reformat-en]="contains existing files. Do you want to delete them?"
+ [reformat-eo]="entenas 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?"
- [notice_ready-en]="Setup is complete. Installation may begin next. If you do not wish to continue, you can press the \"Cancel\" button or the <ESC> key, to quit now."
- [notice_ready-eo]="La ceteraj paŝoj faros detrua ŝanĝoj pri via diskoj. Neniom de ŝanĝoj faris pri via diskoj jam. Se vi ne volas pluiri, vi devus puŝi la \"Ne\" butonon aŭ la <ESC> klavon sekve, ĉesi nun."
- [notice_ready-es]="La configuración está completa. La instalación puede comenzar a continuación. Si no desea continuar, puede presionar el botón \"Cancelar\" o la tecla <ESC> para salir ahora."
- [notice_ready-gl]="A configuración está completa. A instalación pode comezar a continuación. Se non desexa continuar, pode premer o botón \"Cancelar\" ou a tecla <ESC> para saír agora."
- [notice_ready-pt]="A configuração está completa. A instalação pode começar a seguir. Se você não quiser continuar, pode pressionar o botão \"Cancelar\" ou a tecla <ESC> para sair agora."
+ [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?"
- [ready_warn-en]="You have elected to use the entire disk. If you press the \"Yes\" button, the following disk will be completely erased:"
- [ready_warn-eo]="Vi elektis uzi la tutan diskon. Se vi puŝus la \"Jes\" butonon, sekve la jena disko estos tute viŝota:"
- [ready_warn-es]="Has elegido usar todo el disco. Si presiona el botón \"Sí\", el siguiente disco se borrará por completo:"
- [ready_warn-gl]="Vostede elixiu usar todo o disco. Se preme o botón \"Si\", borrará completamente o disco seguinte:"
- [ready_warn-pt]="Você optou por usar o disco inteiro. Se você pressionar o botão \"Sim\", o disco a seguir será completamente apagado:"
+ [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::_PartitionManual() ##
+ ## install.sh::PartitionManual() ##
[part_none-en]="No partitions found"
[part_none-eo]="Neniom el subdiskoj trovitaj"
@@ -487,38 +487,38 @@ declare -r -A TR=(
[no-gl]="Non"
[no-pt]="Não"
- [mount_boot-en]="(Optional) Mount /boot partition?"
- [mount_boot-eo]="(Laŭvola) Muntu /boot subdiskon?"
- [mount_boot-es]="(Opcional) Montar particion /boot?"
- [mount_boot-gl]="(Opcional) Montar particion /boot?"
- [mount_boot-pt]="(Opcional) Montar a partição /boot?"
+ [mount_boot-en]="(Optional) Mount separate /boot partition?"
+ [mount_boot-eo]="(Laŭvola) Muntu aparta /boot subdiskon?"
+ [mount_boot-es]="(Opcional) Montar particion /boot separado?"
+ [mount_boot-gl]="(Opcional) Montar particion /boot separada?"
+ [mount_boot-pt]="(Opcional) Montar a partição /boot separada?"
- [mount_home-en]="(Optional) Mount /home partition?"
- [mount_home-eo]="(Laŭvola) Muntu /home subdiskon?"
- [mount_home-es]="(Opcional) Montar particion /home?"
- [mount_home-gl]="(Opcional) Montar particion /home?"
- [mount_home-pt]="(Opcional) Montar a partição /home?"
+ [mount_home-en]="(Optional) Mount separate /home partition?"
+ [mount_home-eo]="(Laŭvola) Muntu aparta /home subdiskon?"
+ [mount_home-es]="(Opcional) Montar particion /home separado?"
+ [mount_home-gl]="(Opcional) Montar particion /home? separada"
+ [mount_home-pt]="(Opcional) Montar a partição /home separada?"
- ## install.sh::Partition() ##
+ ## install.sh::NoticeReady() ##
- [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?"
+ [dlg_ready-en]="Stage 5 - Installation"
+ [dlg_ready-eo]="Etapo 5 - Instalado"
+ [dlg_ready-es]="Etapa 5 - Instalación"
+ [dlg_ready-gl]="Etapa 5 - Instalación"
+ [dlg_ready-pt]="Etapa 5 - Instalação"
- [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?"
+ [notice_ready-en]="Setup is complete. Installation may begin next. If you do not wish to continue, you can press the \"Cancel\" button or the <ESC> key, to quit now."
+ [notice_ready-eo]="La ceteraj paŝoj faros detrua ŝanĝoj pri via diskoj. Neniom de ŝanĝoj faris pri via diskoj jam. Se vi ne volas pluiri, vi devus puŝi la \"Ne\" butonon aŭ la <ESC> klavon sekve, ĉesi nun."
+ [notice_ready-es]="La configuración está completa. La instalación puede comenzar a continuación. Si no desea continuar, puede presionar el botón \"Cancelar\" o la tecla <ESC> para salir ahora."
+ [notice_ready-gl]="A configuración está completa. A instalación pode comezar a continuación. Se non desexa continuar, pode premer o botón \"Cancelar\" ou a tecla <ESC> para saír agora."
+ [notice_ready-pt]="A configuração está completa. A instalação pode começar a seguir. Se você não quiser continuar, pode pressionar o botão \"Cancelar\" ou a tecla <ESC> para sair agora."
- [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."
+ [ready_warn-en]="You have elected to use the entire disk. If you press the \"Yes\" button, the following disk will be completely erased:"
+ [ready_warn-eo]="Vi elektis uzi la tutan diskon. Se vi puŝus la \"Jes\" butonon, sekve la jena disko estos tute viŝota:"
+ [ready_warn-es]="Has elegido usar todo el disco. Si presiona el botón \"Sí\", el siguiente disco se borrará por completo:"
+ [ready_warn-gl]="Vostede elixiu usar todo o disco. Se preme o botón \"Si\", borrará completamente o disco seguinte:"
+ [ready_warn-pt]="Você optou por usar o disco inteiro. Se você pressionar o botão \"Sim\", o disco a seguir será completamente apagado:"
## install.sh::InstallPkgs() ##