Compare commits

..

No commits in common. "667453596a1f20bd81e80f838b2242348bdde9f4" and "051485cede185225f634dd356bc5c3de3c179a12" have entirely different histories.

6 changed files with 3 additions and 84 deletions

View File

@ -53,15 +53,6 @@ export ESP_MOUNT="/mnt/boot/efi"
export ROOT_LABEL="void-root"
export EFI_LABEL="EFI"
validate_size() {
local size="$1"
# Allow sizes like: 1GiB, 100MB, 50%, 100%
if [[ "$size" =~ ^[0-9]+(\.[0-9]+)?(GiB|GB|MiB|MB|%)?$ ]]; then
return 0
fi
return 1
}
prompt_with_default() {
local var_name="$1"
local prompt_text="$2"
@ -154,21 +145,9 @@ config_validate() {
*) die "Unsupported LUKS version: $LUKS_VERSION" ;;
esac
# Normalize swap size first
if [[ "$SWAP_SIZE" =~ ^0(G|GB|GiB|M|MB|MiB)?$ ]]; then
if [[ "$SWAP_SIZE" == "0" || "$SWAP_SIZE" == "0G" || "$SWAP_SIZE" == "0GiB" ]]; then
SWAP_SIZE="0"
fi
# Validate size formats
if ! validate_size "$ESP_SIZE"; then
die "Invalid ESP size format: $ESP_SIZE (expected: 1GiB, 100MB, etc.)"
fi
if ! validate_size "$ROOT_END"; then
die "Invalid root partition end format: $ROOT_END (expected: 100%, 200GiB, etc.)"
fi
if [[ "$SWAP_SIZE" != "0" ]] && ! validate_size "$SWAP_SIZE"; then
die "Invalid swap size format: $SWAP_SIZE (expected: 4GiB, 8GB, 0 to disable)"
fi
}
config_print_summary() {

View File

@ -64,18 +64,6 @@ format_filesystems() {
local temp_mount
temp_mount="/tmp/void-wrapper-btrfs"
mkdir -p "$temp_mount"
# Ensure cleanup on error
cleanup_temp_mount() {
if mountpoint -q "$temp_mount" 2>/dev/null; then
umount "$temp_mount" || log_warn "Failed to unmount temp mount: $temp_mount"
fi
if [[ -d "$temp_mount" ]]; then
rmdir "$temp_mount" 2>/dev/null || true
fi
}
trap cleanup_temp_mount EXIT
mount "$root_device" "$temp_mount"
btrfs subvolume create "$temp_mount/@"
btrfs subvolume create "$temp_mount/@home"
@ -85,7 +73,6 @@ format_filesystems() {
btrfs subvolume create "$temp_mount/@swap"
umount "$temp_mount"
rmdir "$temp_mount"
trap - EXIT
else
log_info "Formatting root as ext4 on $root_device"
mkfs.ext4 -L "$ROOT_LABEL" "$root_device"

View File

@ -58,14 +58,4 @@ run_installer() {
fi
read -r -p "Press Enter once the installer is complete..." _
# Verify critical mounts are still intact after installer
if ! findmnt "$MOUNT_ROOT" >/dev/null 2>&1; then
die "Root mount disappeared after installer. The installer may have reformatted the filesystem."
fi
if ! findmnt "$ESP_MOUNT" >/dev/null 2>&1; then
die "ESP mount disappeared after installer. The installer may have reformatted the filesystem."
fi
log_info "Mount verification passed."
}

View File

@ -83,7 +83,6 @@ partition_disk() {
ESP_PART="$(partition_path "$DISK" 1)"
ROOT_PART="$(partition_path "$DISK" 2)"
export ESP_PART ROOT_PART
log_info "ESP partition: $ESP_PART"
log_info "Root partition: $ROOT_PART"

View File

@ -78,7 +78,6 @@ postinstall_run() {
log_info "Post-install: configuring target system in chroot"
postinstall_bind_mounts
trap postinstall_unbind_mounts EXIT
LUKS_UUID="$luks_uuid" ROOT_UUID="$root_uuid" FS_TYPE="$FS_TYPE" SWAP_SIZE="$SWAP_SIZE" HOSTNAME="$HOSTNAME" \
chroot "$MOUNT_ROOT" /bin/bash -s <<'EOS'
@ -118,26 +117,7 @@ if [[ "$SWAP_SIZE" != "0" ]]; then
btrfs property set /swap compression none || true
fi
fi
# Try fallocate first, fall back to dd if it fails
if ! fallocate -l "$SWAP_SIZE" /swap/swapfile 2>/dev/null; then
echo "fallocate failed, using dd as fallback..."
# Extract numeric size and unit for dd
local size_num="${SWAP_SIZE%%[^0-9.]*}"
local size_unit="${SWAP_SIZE##*[0-9]}"
local bs="1M"
local count="$size_num"
# Convert to MB count for dd
case "$size_unit" in
GiB|G|GB) count=$(awk "BEGIN {print int($size_num * 1024)}") ;;
MiB|M|MB) count=$(awk "BEGIN {print int($size_num)}") ;;
*) echo "Warning: unknown size unit, assuming MiB"; count="$size_num" ;;
esac
dd if=/dev/zero of=/swap/swapfile bs="$bs" count="$count" status=progress
fi
fallocate -l "$SWAP_SIZE" /swap/swapfile
chmod 600 /swap/swapfile
mkswap /swap/swapfile
if ! grep -q '^/swap/swapfile' /etc/fstab; then
@ -188,15 +168,12 @@ else
fi
# Regenerate initramfs and GRUB configuration.
echo "Regenerating initramfs for all kernels (this may take a while)..."
xbps-reconfigure -fa
echo "Installing GRUB bootloader..."
grub-install --target=x86_64-efi --efi-directory=/boot/efi --bootloader-id=Void --recheck
echo "Generating GRUB configuration..."
grub-mkconfig -o /boot/grub/grub.cfg
EOS
postinstall_unbind_mounts
log_info "Post-install complete."
}

View File

@ -58,24 +58,11 @@ rollback_offer() {
rollback_cleanup() {
: "${MOUNT_ROOT:?Mount root is required}"
: "${CRYPT_NAME:?Crypt mapping name is required}"
# Clean up bind mounts first (from postinstall)
if [[ -d "$MOUNT_ROOT" ]]; then
for bind_path in dev proc sys run; do
if findmnt "$MOUNT_ROOT/$bind_path" >/dev/null 2>&1; then
log_info "Unmounting bind mount: $MOUNT_ROOT/$bind_path"
umount -R "$MOUNT_ROOT/$bind_path" 2>/dev/null || log_warn "Failed to unmount $MOUNT_ROOT/$bind_path"
fi
done
fi
# Clean up regular mounts
if findmnt "$MOUNT_ROOT" >/dev/null 2>&1; then
log_info "Unmounting $MOUNT_ROOT"
umount -R "$MOUNT_ROOT" || log_warn "Failed to unmount $MOUNT_ROOT"
fi
# Close LUKS mapping
if [[ -e "/dev/mapper/$CRYPT_NAME" ]]; then
log_info "Closing LUKS mapping $CRYPT_NAME"
cryptsetup close "$CRYPT_NAME" || log_warn "Failed to close LUKS mapping"