From e15727782dece70d9b2700d653e8a5fa42b969c2 Mon Sep 17 00:00:00 2001 From: josevi Date: Tue, 23 Jun 2026 21:29:11 +0200 Subject: [PATCH] Adapta el instalador a archinstall 4.3 y arregla paru/helpwire MIME-Version: 1.0 Content-Type: text/plain; charset=UTF-8 Content-Transfer-Encoding: 8bit - disk_config: archinstall 4.3 cambió el schema (exige sector_size, sin unidad Percent). Nuevo shared/gen-disk-config.py genera el layout con los modelos de archinstall, dimensionado al disco real; ambos setup.sh lo invocan y se quita el disk_config 3.0 muerto de los JSON. - paru: compilar de fuente, no paru-bin (su binario enlaza contra una libalpm.so concreta y rompe si la del sistema nuevo difiere). - rustup default stable antes de compilar paru (si no, no hay cargo). - helpwire: debtap nombra el paquete 'helpwire', no 'helpwire-operator'; convertir en dir limpio e instalar el único .zst. Co-Authored-By: Claude Opus 4.8 --- gnome/archinstall-config.json | 86 +++++++++++------------------------ gnome/setup.sh | 6 ++- kde/archinstall-config.json | 86 +++++++++++------------------------ kde/setup.sh | 6 ++- shared/gen-disk-config.py | 77 +++++++++++++++++++++++++++++++ shared/packages-common.sh | 20 +++++--- 6 files changed, 153 insertions(+), 128 deletions(-) create mode 100644 shared/gen-disk-config.py diff --git a/gnome/archinstall-config.json b/gnome/archinstall-config.json index db10205..fe65200 100644 --- a/gnome/archinstall-config.json +++ b/gnome/archinstall-config.json @@ -3,7 +3,9 @@ "archinstall-language": "Spanish", "bootloader": "Grub", "hostname": "arch-gnome", - "kernels": ["linux"], + "kernels": [ + "linux" + ], "ntp": true, "swap": true, "timezone": "Europe/Madrid", @@ -13,67 +15,31 @@ "sys_lang": "es_ES.UTF-8" }, "mirror_config": { - "mirror_regions": { "Spain": [] } + "mirror_regions": { + "Spain": [] + } + }, + "network_config": { + "type": "nm" + }, + "audio_config": { + "audio": "pipewire" }, - "network_config": { "type": "nm" }, - "audio_config": { "audio": "pipewire" }, "profile_config": { "gfx_driver": "All open-source", "greeter": "gdm", - "profile": { "main": "Desktop", "details": ["GNOME"] } + "profile": { + "main": "Desktop", + "details": [ + "GNOME" + ] + } }, - "packages": ["networkmanager", "git", "sudo", "vim", "curl"], - "disk_config": { - "config_type": "manual_partitioning", - "device_modifications": [ - { - "device": "/dev/nvme0n1", - "wipe": true, - "partitions": [ - { - "type": "primary", - "status": "create", - "fs_type": "fat32", - "mountpoint": "/boot/efi", - "start": { "unit": "MiB", "value": 1 }, - "size": { "unit": "MiB", "value": 512 }, - "flags": ["boot", "esp"] - }, - { - "type": "primary", - "status": "create", - "fs_type": "ext4", - "mountpoint": "/boot", - "start": { "unit": "MiB", "value": 513 }, - "size": { "unit": "GiB", "value": 1 }, - "flags": [] - }, - { - "type": "primary", - "status": "create", - "fs_type": "btrfs", - "mountpoint": "/", - "start": { "unit": "GiB", "value": 2 }, - "size": { "unit": "Percent", "value": 100 }, - "flags": [] - } - ] - }, - { - "device": "/dev/sda", - "wipe": true, - "partitions": [ - { - "type": "primary", - "status": "create", - "fs_type": "ext4", - "mountpoint": "/home", - "start": { "unit": "MiB", "value": 1 }, - "size": { "unit": "Percent", "value": 100 }, - "flags": [] - } - ] - } - ] - } -} + "packages": [ + "networkmanager", + "git", + "sudo", + "vim", + "curl" + ] +} \ No newline at end of file diff --git a/gnome/setup.sh b/gnome/setup.sh index df3a809..07e4a44 100755 --- a/gnome/setup.sh +++ b/gnome/setup.sh @@ -25,8 +25,12 @@ if [[ "$SETUP_PHASE" == "host" ]]; then read -rp "Nombre para git [$INSTALL_USER]: " GIT_NAME; GIT_NAME="${GIT_NAME:-$INSTALL_USER}" read -rp "Email para git [josevisw@gmail.com]: " GIT_EMAIL; GIT_EMAIL="${GIT_EMAIL:-josevisw@gmail.com}" + echo ">> Generando disk_config dimensionado a los discos reales..." + # archinstall 4.x quitó "Percent": el layout se calcula aquí (ver shared/gen-disk-config.py) + python3 "$REPO_DIR/shared/gen-disk-config.py" "$REPO_DIR/$DE/archinstall-config.json" >/tmp/archinstall-merged.json + echo ">> Lanzando archinstall (instala base + GNOME en /mnt)..." - archinstall --config "$REPO_DIR/$DE/archinstall-config.json" --silent + archinstall --config /tmp/archinstall-merged.json --silent echo ">> Copiando arch-setup al sistema nuevo y entrando en chroot..." cp -r "$REPO_DIR" /mnt/root/arch-setup diff --git a/kde/archinstall-config.json b/kde/archinstall-config.json index 884b0e0..2dbcd73 100644 --- a/kde/archinstall-config.json +++ b/kde/archinstall-config.json @@ -3,7 +3,9 @@ "archinstall-language": "Spanish", "bootloader": "Grub", "hostname": "arch-kde", - "kernels": ["linux"], + "kernels": [ + "linux" + ], "ntp": true, "swap": true, "timezone": "Europe/Madrid", @@ -13,67 +15,31 @@ "sys_lang": "es_ES.UTF-8" }, "mirror_config": { - "mirror_regions": { "Spain": [] } + "mirror_regions": { + "Spain": [] + } + }, + "network_config": { + "type": "nm" + }, + "audio_config": { + "audio": "pipewire" }, - "network_config": { "type": "nm" }, - "audio_config": { "audio": "pipewire" }, "profile_config": { "gfx_driver": "All open-source", "greeter": "sddm", - "profile": { "main": "Desktop", "details": ["KDE Plasma"] } + "profile": { + "main": "Desktop", + "details": [ + "KDE Plasma" + ] + } }, - "packages": ["networkmanager", "git", "sudo", "vim", "curl"], - "disk_config": { - "config_type": "manual_partitioning", - "device_modifications": [ - { - "device": "/dev/nvme0n1", - "wipe": true, - "partitions": [ - { - "type": "primary", - "status": "create", - "fs_type": "fat32", - "mountpoint": "/boot/efi", - "start": { "unit": "MiB", "value": 1 }, - "size": { "unit": "MiB", "value": 512 }, - "flags": ["boot", "esp"] - }, - { - "type": "primary", - "status": "create", - "fs_type": "ext4", - "mountpoint": "/boot", - "start": { "unit": "MiB", "value": 513 }, - "size": { "unit": "GiB", "value": 1 }, - "flags": [] - }, - { - "type": "primary", - "status": "create", - "fs_type": "btrfs", - "mountpoint": "/", - "start": { "unit": "GiB", "value": 2 }, - "size": { "unit": "Percent", "value": 100 }, - "flags": [] - } - ] - }, - { - "device": "/dev/sda", - "wipe": true, - "partitions": [ - { - "type": "primary", - "status": "create", - "fs_type": "ext4", - "mountpoint": "/home", - "start": { "unit": "MiB", "value": 1 }, - "size": { "unit": "Percent", "value": 100 }, - "flags": [] - } - ] - } - ] - } -} + "packages": [ + "networkmanager", + "git", + "sudo", + "vim", + "curl" + ] +} \ No newline at end of file diff --git a/kde/setup.sh b/kde/setup.sh index 46d9051..b925656 100755 --- a/kde/setup.sh +++ b/kde/setup.sh @@ -22,8 +22,12 @@ if [[ "$SETUP_PHASE" == "host" ]]; then read -rp "Nombre para git [$INSTALL_USER]: " GIT_NAME; GIT_NAME="${GIT_NAME:-$INSTALL_USER}" read -rp "Email para git [josevisw@gmail.com]: " GIT_EMAIL; GIT_EMAIL="${GIT_EMAIL:-josevisw@gmail.com}" + echo ">> Generando disk_config dimensionado a los discos reales..." + # archinstall 4.x quitó "Percent": el layout se calcula aquí (ver shared/gen-disk-config.py) + python3 "$REPO_DIR/shared/gen-disk-config.py" "$REPO_DIR/$DE/archinstall-config.json" >/tmp/archinstall-merged.json + echo ">> Lanzando archinstall (instala base + KDE en /mnt)..." - archinstall --config "$REPO_DIR/$DE/archinstall-config.json" --silent + archinstall --config /tmp/archinstall-merged.json --silent echo ">> Copiando arch-setup al sistema nuevo y entrando en chroot..." cp -r "$REPO_DIR" /mnt/root/arch-setup diff --git a/shared/gen-disk-config.py b/shared/gen-disk-config.py new file mode 100644 index 0000000..c551127 --- /dev/null +++ b/shared/gen-disk-config.py @@ -0,0 +1,77 @@ +#!/usr/bin/env python3 +# Genera el disk_config de archinstall (>=4.x) dimensionado al disco REAL y lo +# inyecta en el JSON base. archinstall 4.x quitó la unidad "Percent", así que un +# JSON con tamaños fijos no es portable entre la VM (20G/10G) y el hardware +# (250G/1TB): por eso se calcula en tiempo de instalación con los propios modelos +# de archinstall (válido ante cambios de schema entre versiones). +# +# gen-disk-config.py BASE.json [NVME_DEV] [SDA_DEV] > merged.json +# +# Layout (replica el hardware): NVMe = ESP 512M + /boot 1G ext4 + / btrfs (resto); +# SDA = /home ext4 (todo). swap = zram (lo pone "swap": true del base). +import json, sys +from pathlib import Path +from archinstall.lib.disk.device_handler import device_handler +from archinstall.lib.models.device import ( + DiskLayoutConfiguration, DiskLayoutType, DeviceModification, + PartitionModification, ModificationStatus, PartitionType, + FilesystemType, PartitionFlag, Size, Unit, +) + +MiB = 1024 ** 2 +END_MARGIN = MiB # deja 1 MiB al final para la cabecera GPT de respaldo + +def part(status, ptype, start_b, len_b, ss, fs=None, mnt=None, flags=()): + return PartitionModification( + status=status, type=ptype, + start=Size(start_b, Unit.B, ss), + length=Size(len_b, Unit.B, ss), + fs_type=fs, mountpoint=Path(mnt) if mnt else None, + flags=list(flags), + ) + +def nvme_mods(dev): + ss = dev.device_info.sector_size + total = dev.device_info.total_size._normalize() + esp_start, esp_len = 1 * MiB, 511 * MiB # 1 -> 512 MiB + boot_start, boot_len = 512 * MiB, 1024 * MiB # 512 -> 1536 MiB + root_start = boot_start + boot_len # 1536 MiB + root_len = total - root_start - END_MARGIN + return DeviceModification(device=dev, wipe=True, partitions=[ + part(ModificationStatus.CREATE, PartitionType.PRIMARY, esp_start, esp_len, ss, + FilesystemType.FAT32, "/boot/efi", (PartitionFlag.BOOT, PartitionFlag.ESP)), + part(ModificationStatus.CREATE, PartitionType.PRIMARY, boot_start, boot_len, ss, + FilesystemType.EXT4, "/boot"), + part(ModificationStatus.CREATE, PartitionType.PRIMARY, root_start, root_len, ss, + FilesystemType.BTRFS, "/"), + ]) + +def sda_mods(dev): + ss = dev.device_info.sector_size + total = dev.device_info.total_size._normalize() + start = 1 * MiB + return DeviceModification(device=dev, wipe=True, partitions=[ + part(ModificationStatus.CREATE, PartitionType.PRIMARY, start, + total - start - END_MARGIN, ss, FilesystemType.EXT4, "/home"), + ]) + +def main(): + base_path = sys.argv[1] + nvme = sys.argv[2] if len(sys.argv) > 2 else "/dev/nvme0n1" + sda = sys.argv[3] if len(sys.argv) > 3 else "/dev/sda" + + dev_nvme = device_handler.get_device(Path(nvme)) + dev_sda = device_handler.get_device(Path(sda)) + if not dev_nvme or not dev_sda: + sys.exit(f"No encuentro los discos {nvme} / {sda} (revisa lsblk)") + + layout = DiskLayoutConfiguration( + config_type=DiskLayoutType.Manual, + device_modifications=[nvme_mods(dev_nvme), sda_mods(dev_sda)], + ) + cfg = json.loads(Path(base_path).read_text()) + cfg["disk_config"] = layout.json() + json.dump(cfg, sys.stdout, indent=2) + +if __name__ == "__main__": + main() diff --git a/shared/packages-common.sh b/shared/packages-common.sh index ee249cc..53c4d4b 100755 --- a/shared/packages-common.sh +++ b/shared/packages-common.sh @@ -41,9 +41,14 @@ as_user() { sudo -u "$INSTALL_USER" bash -lc "$*"; } bootstrap_paru() { command -v paru &>/dev/null && return 0 install_pacman git base-devel - as_user 'cd /tmp && rm -rf paru-bin && \ - git clone https://aur.archlinux.org/paru-bin.git && \ - cd paru-bin && makepkg -si --noconfirm' + # rustup sin toolchain por defecto no expone cargo y rompe el build de paru + as_user 'rustup default stable' + # paru (fuente, no paru-bin): el binario de paru-bin enlaza contra una + # libalpm.so concreta y rompe si la del sistema nuevo difiere; compilar de + # fuente enlaza contra la libalpm instalada. + as_user 'cd /tmp && rm -rf paru && \ + git clone https://aur.archlinux.org/paru.git && \ + cd paru && makepkg -si --noconfirm' } install_aur() { @@ -57,7 +62,10 @@ install_helpwire() { local url="https://www.helpwire.app/downloads/operator/linux/helpwire-operator.deb" install_aur debtap as_user "sudo debtap -u || true" - as_user "cd /tmp && curl -fsSL -o helpwire.deb '$url' && \ - yes '' | sudo debtap -Q helpwire.deb && \ - sudo pacman -U --noconfirm helpwire-operator*.pkg.tar.zst" + # debtap nombra el paquete por el campo Package del .deb ('helpwire', no + # 'helpwire-operator'): convertir en un dir limpio e instalar el único .zst, + # sin depender del nombre exacto. + as_user "d=\$(mktemp -d) && cd \"\$d\" && curl -fsSL -o hw.deb '$url' && \ + yes '' | sudo debtap -Q hw.deb && \ + sudo pacman -U --noconfirm \"\$d\"/*.pkg.tar.zst && rm -rf \"\$d\"" }