fix(installer): Validate hostname, parse disk models, skip zram

- screen_hostname: reject names that break /etc/hostname and /etc/hosts.
- screen_disk: parse lsblk -P by regex so multi-word/empty MODELs show
  correctly, and never offer /dev/zram* (TYPE=disk) as a target.
- packages: add python-distro, the undeclared runtime dep of the shipped
  ssh-import-id (it always crashed and fell back to curl).

Co-Authored-By: Claude Opus 5.5 <noreply@anthropic.com>
This commit is contained in:
alvinlollo
2026-10-11 17:41:38 +11:00
co-authored by Claude Opus 5.5
parent e63f9cb14f
commit 699ed6a935
2 changed files with 13 additions and 8 deletions
+12 -8
View File
@@ -336,15 +336,17 @@ screen_disk() {
live_dev="/dev/${pk:-$(basename "$src")}"
fi
local disks=()
# -P quotes every field (and escapes quotes inside), so multi-word or
# empty MODELs parse correctly - matched by regex, never eval'd.
local disks=() line name size model
local re='^NAME="([^"]*)" SIZE="([^"]*)" MODEL="([^"]*)" TYPE="disk"$'
while IFS= read -r line; do
local name size model
name=$(echo "$line" | awk '{print $1}')
size=$(echo "$line" | awk '{print $2}')
model=$(echo "$line" | awk '{$1=$2=""; sub(/^[ \t]+/,""); print}')
[[ "$line" =~ $re ]] || continue
name=${BASH_REMATCH[1]} size=${BASH_REMATCH[2]} model=${BASH_REMATCH[3]}
[[ "$name" == "$live_dev" ]] && continue
disks+=("${name} ${size} ${model}")
done < <(lsblk -dpno NAME,SIZE,MODEL,TYPE | awk '$NF=="disk" {print $1,$2,$3}')
[[ "$name" == /dev/zram* ]] && continue # compressed RAM swap, TYPE=disk
disks+=("${name} ${size} ${model:-unknown model}")
done < <(lsblk -dpnP -o NAME,SIZE,MODEL,TYPE)
(( ${#disks[@]} > 0 )) || die "No disks found."
@@ -456,9 +458,11 @@ screen_hostname() {
clear
header "Hostname"
echo ""
HOSTNAME=$(gum input --placeholder "archlinux" --char-limit 64 --header "+ Hostname") \
HOSTNAME=$(gum input --placeholder "archlinux" --char-limit 63 --header "+ Hostname") \
|| die "No hostname entered."
[[ -z "$HOSTNAME" ]] && HOSTNAME="archlinux"
[[ "$HOSTNAME" =~ ^[A-Za-z0-9]([A-Za-z0-9-]{0,62})$ && "$HOSTNAME" != *- ]] \
|| die "Invalid hostname. Use letters, digits and '-' (max 63, no leading/trailing '-')."
log "Hostname: $HOSTNAME"
}
+1
View File
@@ -272,6 +272,7 @@ pptpclient
pv
pwgen
python-aiohttp
python-distro
python-hatchling
python-installer
python-packaging