fix(Calamares): Installater will ask the desktop env before the calamares install
- The installer is still W.I.P
This commit is contained in:
Regular → Executable
+41
-7
@@ -7,6 +7,7 @@
|
||||
# rafraîchir le repo local.
|
||||
# ============================================================
|
||||
set -e
|
||||
trap 'rc=$?; echo -e "\033[0;31m[ERR] Échec (setup-calamares.sh) ligne $LINENO, code $rc.\033[0m" >&2; exit $rc' ERR
|
||||
|
||||
AUR_PACKAGES=(calamares winboat-bin)
|
||||
DISTRO_NAME="${ARCH_WSL_DISTRO:-Arch}"
|
||||
@@ -29,19 +30,45 @@ if [[ "$OSTYPE" == "msys" || "$OSTYPE" == "cygwin" || -n "$WINDIR" ]]; then
|
||||
export MSYS_NO_PATHCONV=1
|
||||
export MSYS2_ARG_CONV_EXCL="*"
|
||||
|
||||
if ! wsl.exe -d "$DISTRO_NAME" -u root -- echo ok >/dev/null 2>&1; then
|
||||
# Auto-détection
|
||||
for name in "Arch" "ArchLinux" "archlinux" "arch" "ArchWSL"; do
|
||||
if wsl.exe -d "$name" -u root -- echo ok >/dev/null 2>&1; then
|
||||
DISTRO_NAME="$name"; break
|
||||
fi
|
||||
# WSL doit être présent.
|
||||
command -v wsl.exe >/dev/null 2>&1 \
|
||||
|| error "WSL introuvable — PowerShell admin : 'wsl --install', puis installe une distro Arch et relance."
|
||||
|
||||
# Choix de la distro Arch : override $ARCH_WSL_DISTRO, sinon nom exact,
|
||||
# sinon 1re distro « arch » réellement joignable (énum via `wsl -l -q`,
|
||||
# sortie UTF-16LE → on retire NUL/CR ; on garde la sonde « echo ok »).
|
||||
pick_arch_distro() {
|
||||
wsl.exe -d "$DISTRO_NAME" -u root -- echo ok >/dev/null 2>&1 && return 0
|
||||
local d distros=()
|
||||
mapfile -t distros < <(wsl.exe -l -q 2>/dev/null | tr -d '\0\r' | sed 's/[[:space:]]*$//;/^$/d')
|
||||
for d in "${distros[@]}"; do
|
||||
[[ "$d" == "$DISTRO_NAME" ]] || continue
|
||||
wsl.exe -d "$d" -u root -- echo ok >/dev/null 2>&1 && { DISTRO_NAME="$d"; return 0; }
|
||||
done
|
||||
for d in "${distros[@]}"; do
|
||||
[[ "$d" =~ [Aa][Rr][Cc][Hh] ]] || continue
|
||||
wsl.exe -d "$d" -u root -- echo ok >/dev/null 2>&1 && { DISTRO_NAME="$d"; return 0; }
|
||||
done
|
||||
return 1
|
||||
}
|
||||
if ! pick_arch_distro; then
|
||||
warn "Distros WSL installées :"
|
||||
wsl.exe -l -v 2>/dev/null | tr -d '\0' >&2 || true
|
||||
error "Aucune distro WSL Arch joignable. Installe ArchWSL (nom 'Arch') ou 'wsl --install -d archlinux', ou exporte ARCH_WSL_DISTRO=<nom>."
|
||||
fi
|
||||
info "Distro WSL : $DISTRO_NAME"
|
||||
|
||||
SCRIPT_DIR_WIN="$(cd "$(dirname "${BASH_SOURCE[0]}")" && pwd -W)"
|
||||
SCRIPT_PATH_WSL=$(MSYS_NO_PATHCONV=1 wsl.exe -d "$DISTRO_NAME" -u root -- \
|
||||
wslpath "$(echo "$SCRIPT_DIR_WIN" | sed 's|/|\\\\|g')/setup-calamares.sh" \
|
||||
2>/dev/null | tr -d '\r\n')
|
||||
[ -n "$SCRIPT_PATH_WSL" ] \
|
||||
|| error "Traduction du chemin vers WSL échouée (wslpath). Vérifie ARCH_WSL_DISTRO ($DISTRO_NAME)."
|
||||
wsl.exe -d "$DISTRO_NAME" -u root -- test -f "$SCRIPT_PATH_WSL" \
|
||||
|| error "Script introuvable dans WSL : $SCRIPT_PATH_WSL"
|
||||
|
||||
# Relance en root depuis le vrai chemin ($0 → SCRIPT_DIR correct).
|
||||
# Fins de ligne garanties LF par .gitattributes (*.sh text eol=lf).
|
||||
MSYS_NO_PATHCONV=1 wsl.exe -d "$DISTRO_NAME" -u root -- bash "$SCRIPT_PATH_WSL"
|
||||
exit 0
|
||||
fi
|
||||
@@ -50,7 +77,14 @@ fi
|
||||
# Vérifications
|
||||
# ============================================================
|
||||
command -v pacman >/dev/null || error "pacman introuvable (lance depuis Arch / WSL)"
|
||||
[ "$EUID" -eq 0 ] || exec su -c "bash $0" root
|
||||
# Élévation root : sudo de préférence, sinon su. $0 cité (chemins à espaces).
|
||||
if [ "$EUID" -ne 0 ]; then
|
||||
if command -v sudo >/dev/null 2>&1; then
|
||||
exec sudo bash "$0" "$@"
|
||||
else
|
||||
exec su -c "bash \"$0\"" root
|
||||
fi
|
||||
fi
|
||||
success "Arch Linux (root) ✓"
|
||||
|
||||
SCRIPT_DIR="$(cd "$(dirname "${BASH_SOURCE[0]}")" && pwd)"
|
||||
|
||||
Reference in New Issue
Block a user