From 7c1a06fdd2c946f24ef4f0f736502975943a697e Mon Sep 17 00:00:00 2001 From: Puechberty Arthur Date: Sat, 27 Jun 2026 01:09:51 +0200 Subject: [PATCH] fix creation of iso --- .gitignore | 9 ++ README.md | 2 +- airootfs/root/.config/hypr/hyprland.lua | 11 +- airootfs/root/.install.sh | 176 +++++++++--------------- build.sh | 101 ++++++++++++-- 5 files changed, 167 insertions(+), 132 deletions(-) diff --git a/.gitignore b/.gitignore index 5907a7a..28c2aa8 100644 --- a/.gitignore +++ b/.gitignore @@ -13,6 +13,15 @@ work/ *.img *.fs +# --- AJOUTS POUR LE HORS-LIGNE --- +# Dossiers temporaires de compilation (créés par build.sh) +offline_cache/ +aur_build/ + +# Le cache des paquets générés dans l'arborescence de l'ISO (GROS FICHIERS) +airootfs/root/offline_cache/ +# --------------------------------- + # Editor .vscode/ .idea/ diff --git a/README.md b/README.md index 22b2294..ff7b2b7 100644 --- a/README.md +++ b/README.md @@ -39,7 +39,7 @@ Run build script: ```bash chmod +x build.sh -sudo ./build.sh +./build.sh ``` --- diff --git a/airootfs/root/.config/hypr/hyprland.lua b/airootfs/root/.config/hypr/hyprland.lua index 8d154ea..825f114 100644 --- a/airootfs/root/.config/hypr/hyprland.lua +++ b/airootfs/root/.config/hypr/hyprland.lua @@ -216,7 +216,7 @@ hl.config({ hl.config({ input = { - kb_layout = "fr", + kb_layout = "__KB_LAYOUT__", -- MARQUEUR REMPLACÉ PAR LE SCRIPT BASH kb_variant = "", kb_model = "", kb_options = "", @@ -271,10 +271,13 @@ hl.bind(mainMod .. " + down", hl.dsp.focus({ direction = "down" })) -- Switch workspaces with mainMod + [0-9] -- Move active window to a workspace with mainMod + SHIFT + [0-9] +-- CORRECTION : Utilisation des keycodes (code:10 à code:19) pour que ça marche sur AZERTY/QWERTY for i = 1, 10 do - local key = i % 10 -- 10 maps to key 0 - hl.bind(mainMod .. " + " .. key, hl.dsp.focus({ workspace = i})) - hl.bind(mainMod .. " + SHIFT + " .. key, hl.dsp.window.move({ workspace = i })) + local keycode = 9 + i -- 10=1, 11=2, 12=3 ... 18=9, 19=0 + local key_str = "code:" .. keycode + + hl.bind(mainMod .. " + " .. key_str, hl.dsp.workspace(i)) + hl.bind(mainMod .. " + SHIFT + " .. key_str, hl.dsp.movetoworkspace(i)) end -- Example special workspace (scratchpad) diff --git a/airootfs/root/.install.sh b/airootfs/root/.install.sh index 020b173..c371368 100755 --- a/airootfs/root/.install.sh +++ b/airootfs/root/.install.sh @@ -88,7 +88,6 @@ print_grid_menu() { done } -# Fonction pour échapper les caractères spéciaux JSON (Remplace jq) json_escape() { local s="$1" s="${s//\\/\\\\}" @@ -260,10 +259,7 @@ run_configurator() { done disk=$(echo "${DISKS[$((PAGE - 1))]}" | awk '{print $1}') - # --- 5. ENCRYPTION (FORCE ACTIVÉ) --- - local encrypt_installation="true" - - # --- JSON GENERATION (100% BASH PUR) --- + # --- 5. JSON GENERATION --- local pw_esc="\"$(json_escape "$password")\"" local hash_esc="\"$(json_escape "$password_hash")\"" local user_esc="\"$(json_escape "$username")\"" @@ -416,53 +412,60 @@ if [[ $(tty) == "/dev/tty1" ]]; then echo "Installing base system..." install_base_system + # --- 0. CONFIGURATION HORS-LIGNE --- + ISO_CACHE="/root/offline_cache" + # On monte le cache dans un dossier à part pour ne pas saturer la RAM + CHROOT_OFFLINE_DIR="/mnt/opt/offline_cache" + + if [[ -d "$ISO_CACHE" && -n "$(ls -A $ISO_CACHE/*.pkg.tar.zst 2>/dev/null)" ]]; then + echo ">>> Mode HORS-LIGNE activé : Utilisation du cache de l'ISO" + mkdir -p "$CHROOT_OFFLINE_DIR" + mount --bind "$ISO_CACHE" "$CHROOT_OFFLINE_DIR" + else + echo ">>> Mode EN-LIGNE : Cache de l'ISO non trouvé, téléchargement depuis internet." + fi + # --- 1. INSTALLATION PACKAGES OFFICIELS --- clear - echo "Installing Neovim, Ghostty and Hyprland..." + echo "Installing packages (Offline or Online)..." EXTRA_PACKAGES=( - "neovim" - "ghostty" - "hyprland" - "xdg-desktop-portal-hyprland" - "git" - "yazi" - "dolphin" - "rofi" - "waybar" - "wiremix" - "impala" - "bluetui" - "btop" - "cava" - "fastfetch" - "obsidian" - "obs-studio" - "lazygit" - "docker" - "docker-buildx" - "docker-compose" - "lazydocker" - "mpv" - "prismlauncher" - "rust" - "chromium" - "bat" - "base-devel" - "cmake" - "nodejs" - "npm" - "pnpm" - "python" - "python-pip" - "curl" - "wget" - "unzip" + "neovim" "ghostty" "hyprland" "xdg-desktop-portal-hyprland" + "git" "yazi" "dolphin" "rofi" "waybar" "wiremix" "impala" + "bluetui" "btop" "cava" "fastfetch" "obsidian" "obs-studio" + "lazygit" "docker" "docker-buildx" "docker-compose" "lazydocker" + "mpv" "prismlauncher" "rust" "chromium" "bat" "base-devel" + "cmake" "nodejs" "npm" "pnpm" "python" "python-pip" + "curl" "wget" "unzip" ) - arch-chroot /mnt pacman -S --noconfirm "${EXTRA_PACKAGES[@]}" + # On dit à pacman d'utiliser le disque dur pour écrire, et le dossier /opt/offline_cache pour LIRE les paquets pré-téléchargés + if [[ -d "$CHROOT_OFFLINE_DIR" ]]; then + arch-chroot /mnt pacman -S --noconfirm --cachedir /var/cache/pacman/pkg --cachedir /opt/offline_cache "${EXTRA_PACKAGES[@]}" + else + arch-chroot /mnt pacman -S --noconfirm "${EXTRA_PACKAGES[@]}" + fi - # --- 2. CONFIGURATION TTY AUTO-LOGIN --- + # --- 2. INSTALLATION PACKAGES AUR (HORS-LIGNE) --- + clear + echo "Installing pre-compiled AUR packages..." + for pkg in visual-studio-code-bin subtui-bin localsend-bin; do + # On cherche le nom exact du fichier depuis l'hôte + PKG_PATH=$(ls ${CHROOT_OFFLINE_DIR}/${pkg}*.pkg.tar.zst 2>/dev/null | head -n 1) + + if [[ -n "$PKG_PATH" ]]; then + echo ">>> Installation de $pkg" + # On enlève "/mnt" du chemin pour que ça corresponde au point de vue du chroot + CHROOT_PKG_PATH="${PKG_PATH#/mnt}" + + # On passe le chemin exact (sans étoile) à pacman + arch-chroot /mnt pacman -U --noconfirm "$CHROOT_PKG_PATH" + else + echo ">>> $pkg non trouvé, ignoré." + fi + done + + # --- 3. CONFIGURATION TTY AUTO-LOGIN --- echo "Configuring TTY auto-login for $username..." mkdir -p /mnt/etc/systemd/system/getty@tty1.service.d @@ -472,12 +475,9 @@ ExecStart= ExecStart=-/sbin/agetty --autologin $username --noclear %I \$TERM EOF -# --- 3. LANCEMENT AUTOMATIQUE DE HYPRLAND (sans casser le chroot) --- -echo "Configuring auto-start Hyprland..." - -# On garde .bash_profile mais on ajoute une garde anti-chroot -cat > "/mnt/home/$username/.bash_profile" << 'EOF' -# Ne pas démarrer Hyprland si on est dans un chroot archinstall + # --- 4. LANCEMENT AUTOMATIQUE DE HYPRLAND --- + echo "Configuring auto-start Hyprland..." + cat > "/mnt/home/$username/.bash_profile" << 'EOF' if [ -f /.arch-chroot ] || [ -n "$INSTALLING" ]; then return 0 2>/dev/null || exit 0 fi @@ -485,77 +485,27 @@ if [ -z "${DISPLAY:-}" ] && [ "$(tty 2>/dev/null)" = "/dev/tty1" ]; then exec Hyprland fi EOF -chown 1000:1000 "/mnt/home/$username/.bash_profile" + chown 1000:1000 "/mnt/home/$username/.bash_profile" -# --- 4. PRÉPARATION DU RUNTIME DIR pour paru (Rust) --- -echo "Preparing XDG_RUNTIME_DIR for user $username..." - -USER_UID=$(awk -F: -v u="$username" '$1==u{print $3}' /mnt/etc/passwd) -USER_GID=$(awk -F: -v u="$username" '$1==u{print $4}' /mnt/etc/passwd) - -# Crée le répertoire runtime standard systemd DANS le chroot -mkdir -p "/mnt/run/user/${USER_UID}" -chown "${USER_UID}:${USER_GID}" "/mnt/run/user/${USER_UID}" -chmod 700 "/mnt/run/user/${USER_UID}" - -# --- 5. INSTALLATION DE PARU (sans su -, avec sudo -u) --- -clear -echo "Installing paru (AUR Helper)..." - -# Évite su - (login shell) → utilise sudo -u avec env propre -arch-chroot /mnt \ - sudo -u "$username" \ - XDG_RUNTIME_DIR="/run/user/${USER_UID}" \ - HOME="/home/$username" \ - bash -c ' - set -e - cd /tmp - rm -rf paru - git clone https://aur.archlinux.org/paru.git - cd paru - makepkg -si --noconfirm --needed - cd /tmp - rm -rf paru - ' - -echo "paru installed successfully!" - -# --- 6. INSTALLATION PACKAGES AUR --- -clear -echo "Installing AUR packages..." - -AUR_PACKAGES=( - visual-studio-code-bin - subtui-bin - localsend-bin -) - -arch-chroot /mnt \ - sudo -u "$username" \ - XDG_RUNTIME_DIR="/run/user/${USER_UID}" \ - HOME="/home/$username" \ - bash -c " - set -e - paru -S --noconfirm --needed ${AUR_PACKAGES[*]} - " - -echo "AUR packages installed successfully!" - - # --- 6. COPIE DES DOTFILES --- + # --- 5. COPIE DES DOTFILES & INJECTION CLAVIER --- clear echo "Copying custom .config files..." - # On vérifie si le dossier .config existe bien à côté du script sur l'ISO if [[ -d ".config" ]]; then - # On le copie dans le home de l'utilisateur sur le disque dur cp -r .config "/mnt/home/$username/" - # On s'assure que l'utilisateur est bien le propriétaire (1000:1000 est le 1er user par défaut) + + HYPRLAND_CONF="/mnt/home/$username/.config/hypr/init.lua" + if [[ -f "$HYPRLAND_CONF" ]]; then + sed -i "s/__KB_LAYOUT__/$keyboard/g" "$HYPRLAND_CONF" + echo "Hyprland keyboard set to: $keyboard" + fi + chown -R 1000:1000 "/mnt/home/$username/.config" - echo "Dotfiles copied successfully!" + echo "Dotfiles configured successfully!" else - echo "No .config folder found next to the script, skipping." + echo "No .config folder found, skipping." fi - # --- REBOOT AUTOMATIQUE --- + # --- REBOOT --- echo "Installation finished! Rebooting in 3 seconds..." sleep 3 reboot diff --git a/build.sh b/build.sh index be2112f..4e7fec2 100755 --- a/build.sh +++ b/build.sh @@ -1,37 +1,110 @@ #!/bin/bash + +# Si l'utilisateur a oublié de mettre sudo, on redémarre le script avec sudo +if [ "$EUID" -ne 0 ]; then + echo "Le build nécessite les droits administrateur (sudo). Redémarrage..." + exec sudo bash "$0" "$@" +fi + set -e ISO_NAME="arch-custom-iso" +# On récupère le nom de l'utilisateur normal (pas root) pour makepkg +BUILD_USER="${SUDO_USER:-root}" + +# ============================================================================== +# LES LISTES DE PAQUETS +# ============================================================================== +EXTRA_PACKAGES=( + "neovim" "ghostty" "hyprland" "xdg-desktop-portal-hyprland" + "git" "yazi" "dolphin" "rofi" "waybar" "wiremix" "impala" + "bluetui" "btop" "cava" "fastfetch" "obsidian" "obs-studio" + "lazygit" "docker" "docker-buildx" "docker-compose" "lazydocker" + "mpv" "prismlauncher" "rust" "chromium" "bat" "base-devel" + "cmake" "nodejs" "npm" "pnpm" "python" "python-pip" + "curl" "wget" "unzip" +) + +AUR_PACKAGES=( + "visual-studio-code-bin" + "subtui-bin" + "localsend-bin" +) + +# ============================================================================== +# PROCESSUS DE BUILD +# ============================================================================== echo "=====================================" echo " Building Arch Linux ISO" echo " Project: $ISO_NAME" +echo " Build lancé par l'utilisateur: $BUILD_USER" echo "=====================================" -# Check archiso if ! command -v mkarchiso &> /dev/null; then echo "[ERROR] archiso is not installed" echo "Run: sudo pacman -S archiso" exit 1 fi -# Clean previous build -echo "[1/3] Cleaning previous build..." -rm -rf work out +echo "[1/5] Cleaning previous build..." +rm -rf work out offline_cache -# Build ISO -echo "[2/3] Building ISO..." +# --- TÉLÉCHARGEMENT DES PAQUETS OFFICIELS --- +echo "[2/5] Downloading Official Packages for offline cache..." +# On utilise /tmp pour éviter tout problème de permissions dans le Home +TMP_CACHE="/tmp/archiso_cache_$$" +mkdir -p "$TMP_CACHE" +sudo pacman -Sy --noconfirm + +# On télécharge (-w) sans installer, dans le dossier temporaire +sudo pacman -Sw --noconfirm --cachedir "$TMP_CACHE" "${EXTRA_PACKAGES[@]}" || true + +# On crée le vrai dossier de cache et on déplace les paquets +mkdir -p offline_cache +cp "$TMP_CACHE"/*.pkg.tar.zst offline_cache/ 2>/dev/null || true +rm -rf "$TMP_CACHE" + +# --- COMPILATION DES PAQUETS AUR --- +echo "[3/5] Building AUR Packages for offline cache..." +mkdir -p aur_build + +for pkg in "${AUR_PACKAGES[@]}"; do + echo " -> Building AUR package: $pkg" + cd aur_build + rm -rf "$pkg" + git clone "https://aur.archlinux.org/${pkg}.git" --depth 1 + + # CRUCIAL : On donne les droits à l'utilisateur NORMAL pour que makepkg accepte de tourner + chown -R "$BUILD_USER":"$BUILD_USER" "$pkg" + cd "$pkg" + + # CRUCIAL : On lance makepkg EN TANT QU'UTILISATEUR NORMAL (pas de -s pour éviter de reboucler sur sudo) + sudo -u "$BUILD_USER" makepkg -f --noconfirm --needed + + # On déplace le paquet compilé dans notre cache + mv *.pkg.tar.zst ../../offline_cache/ + cd ../.. +done +rm -rf aur_build + +# --- INJECTION DANS L'ISO --- +echo "[4/5] Injecting offline cache into ISO skeleton..." +mkdir -p airootfs/root/offline_cache +cp offline_cache/*.pkg.tar.zst airootfs/root/offline_cache/ +rm -rf offline_cache + +# --- CRÉATION DE L'ISO --- +echo "[5/5] Building ISO (this will take a while)..." sudo mkarchiso -v . -# Check result if [ -f out/*.iso ]; then - echo "[3/3] Build successful!" - echo "ISO located in: out/" + echo "" + echo "=====================================" + echo " Build successful!" + echo " ISO located in: out/" + echo "=====================================" else echo "[ERROR] ISO not found in out/" exit 1 -fi - -echo "=====================================" -echo "Done." -echo "=====================================" \ No newline at end of file +fi \ No newline at end of file