Only offer a choice of installing alongside existing data if it's actually possible
This commit is contained in:
1 parent
c77a7b555b
commit
588973b0cd
1 file changed
+28
@@ -828,6 +828,30 @@ open_partition_tool() {
|
|||||||
sleep 1
|
sleep 1
|
||||||
}
|
}
|
||||||
|
|
||||||
|
# If the disk has no partition table or no unallocated free space, the only
|
||||||
|
# viable path is a full-disk install. Skip the install-mode picker and go
|
||||||
|
# straight to confirmation.
|
||||||
|
requires_full_disk_install() {
|
||||||
|
local pt_type free_space_b
|
||||||
|
pt_type=$(lsblk -dno PTTYPE "$disk" 2>/dev/null)
|
||||||
|
|
||||||
|
# a) No partition table: disk is empty
|
||||||
|
[[ -z "$pt_type" ]] && return 0
|
||||||
|
|
||||||
|
# b) No usable free space
|
||||||
|
free_space_b=$(parted -ms "$disk" unit B print free </dev/null 2>/dev/null | \
|
||||||
|
awk -F: '
|
||||||
|
$NF ~ /free/ {
|
||||||
|
size=$4;
|
||||||
|
gsub(/B/, "", size);
|
||||||
|
if (size+0 > max+0) max=size;
|
||||||
|
}
|
||||||
|
END {
|
||||||
|
print max+0;
|
||||||
|
}')
|
||||||
|
[[ -z "$free_space_b" || "$free_space_b" -eq 0 ]]
|
||||||
|
}
|
||||||
|
|
||||||
install_mode_form() {
|
install_mode_form() {
|
||||||
local choices=("Full disk install")
|
local choices=("Full disk install")
|
||||||
|
|
||||||
@@ -842,6 +866,9 @@ install_mode_form() {
|
|||||||
install_mode=$(gum choose --header "How should Omarchy be installed on $disk?" "${choices[@]}") || abort
|
install_mode=$(gum choose --header "How should Omarchy be installed on $disk?" "${choices[@]}") || abort
|
||||||
}
|
}
|
||||||
|
|
||||||
|
if requires_full_disk_install; then
|
||||||
|
install_mode="Full disk install"
|
||||||
|
else
|
||||||
while true; do
|
while true; do
|
||||||
install_mode_form
|
install_mode_form
|
||||||
|
|
||||||
@@ -859,6 +886,7 @@ while true; do
|
|||||||
;;
|
;;
|
||||||
esac
|
esac
|
||||||
done
|
done
|
||||||
|
fi
|
||||||
|
|
||||||
confirm_disk_overwrite() {
|
confirm_disk_overwrite() {
|
||||||
local mode="encrypted"
|
local mode="encrypted"
|
||||||
|
|||||||
Reference in new issue
Block a user