Files
FWS-ISO/scripts/fws-docker-repl.sh
T
BlackAngelTV 1e0f58e261 feat(scripts): auto-fallback to Docker container when no Arch WSL distro is found
setup-aur.sh, build.sh and build-offi.sh now fall back to an archlinux
Docker container (repo mounted on /fws, shared pacman cache) instead of
erroring on Windows hosts without an Arch WSL distro. Also install sudo
in the container so makepkg -s can resolve makedepends as the non-root
fwsbuild user (the cause of the recurring anaconda build failure).
2026-09-04 14:16:16 +02:00

66 lines
3.2 KiB
Bash

#!/bin/bash
# ============================================================================
# FWS — Repli Docker Desktop (Windows sans distro WSL Arch)
#
# Sur Windows, les scripts racines (setup-aur.sh, build.sh, build-offi.sh)
# cherchent une distro WSL Arch puis basculent dedans. Si aucune n'est
# joignable mais que Docker Desktop tourne, on relance le script à
# l'identique dans un conteneur archlinux : l'équivalent Windows du repli
# podman des hôtes Linux non-Arch (mêmes principes : pull explicite de
# l'image, volume de cache pacman partagé fws-pacman-cache, --privileged
# pour mkarchiso, -e FWS_IN_CONTAINER=1).
#
# Sourcé DEPUIS la branche Git Bash d'un script racine (Windows uniquement) :
# source "$(cd "$(dirname "${BASH_SOURCE[0]}")" && pwd)/scripts/fws-docker-repl.sh"
# if fws_docker_repl "setup-aur.sh" "$SCRIPT_DIR_WIN"; then exit 0; fi
#
# fws_docker_repl ne rend la main QUE si Docker est absent ou injoignable
# (code 1) — dans ce cas l'appelant garde son message « installe une distro
# WSL Arch » et sort. Dès que le conteneur est lancé, elle propage son code
# de sortie et termine le script (exit), donc le code après l'appel n'est
# jamais atteint en cas de succès.
#
# Le dépôt Windows est monté sur un chemin stable /fws dans le conteneur
# (le script calcule son WORK_DIR depuis $0 → local-repo/, out/ et les
# PKGBUILD restent ceux du dépôt monté). makepkg (setup-aur.sh) exige sudo
# dans l'image : installé par le script lui-même (étape 1/4, ligne
# « base-devel git sudo »). Les fichiers écrits par le conteneur sur le
# montage sont créés par le proxy de Docker Desktop côté Windows → pas de
# re-chown nécessaire (contrairement à podman rootful sur Linux).
# ============================================================================
fws_docker_repl() {
local self="$1" repo_win="$2" tty=()
[ -t 0 ] && tty=(-it)
echo -e "\e[36mAucune distro WSL Arch joignable — repli Docker Desktop (conteneur Arch)...\e[0m"
command -v docker >/dev/null 2>&1 || {
echo -e "\e[31m docker introuvable. Installe Docker Desktop, ou une distro WSL Arch (voir message de l'appelant).\e[0m" >&2
return 1
}
if ! docker info >/dev/null 2>&1; then
echo -e "\e[31m Le moteur Docker ne répond pas — démarre Docker Desktop puis relance.\e[0m" >&2
return 1
fi
local image="docker.io/library/archlinux:latest"
# pull explicite : « run » ne re-résout jamais le tag « latest » une fois
# l'image en cache → sinon on build sur une image qui vieillit (même
# parade que le repli podman ; une image fraîche a un keyring valide).
echo -e "\e[36m==> Pull de l'image $image...\e[0m"
docker pull "$image" || return 1
echo -e "\e[36m==> Relance dans le conteneur ($self)...\e[0m"
# MSYS_NO_PATHCONV=1 : passe des arguments bruts (chemin Windows + /fws)
# à docker.exe sans conversion de chemins Git Bash.
MSYS_NO_PATHCONV=1 docker run --rm "${tty[@]}" --privileged \
-e FWS_IN_CONTAINER=1 \
-v fws-pacman-cache:/var/cache/pacman/pkg \
-v "$repo_win:/fws" \
-w /fws \
"$image" \
bash "/fws/$self"
exit $?
}