feat(build): add podman container support for non-arch linux distributions

Add automatic detection and relaunching of build scripts in an Arch Linux container via podman when running on non-Arch distributions (Fedora, Ubuntu, Debian, etc.).

Key changes:
- Implement host_is_arch() function to detect if running on Arch Linux by checking both pacman availability and /etc/os-release
- When non-Arch host is detected, scripts automatically pull docker.io/library/archlinux:latest and relaunch themselves in rootful podman container with --privileged
- Mount repository at same absolute path inside container so WORK_DIR and out/ directories work transparently
- Set up persistent pacman cache volume (fws-pacman-cache) between runs
- Auto-chown output files back to host user after build completes
- Update pacman config to disable landlock sandbox in containers (similar to WSL workaround)
- Run full pacman -Syu upgrade in container before installing archiso to avoid partial upgrade issues
- Add comprehensive documentation in README about Fedora/non-Arch setup
- Update .gitignore to exclude pkgbuilds/ directory
- Add environnement.md documentation file
This commit is contained in:
2026-06-17 11:05:59 +02:00
parent de9647a00d
commit 2420bf2404
8 changed files with 293 additions and 32 deletions
+70 -7
View File
@@ -9,7 +9,15 @@
set -e
trap 'rc=$?; echo -e "\033[0;31m[ERR] Échec (setup-aur.sh) ligne $LINENO, code $rc.\033[0m" >&2; exit $rc' ERR
AUR_PACKAGES=(winboat-bin)
# Paquets AUR à construire, DANS L'ORDRE (les deps avant les dépendants ; la
# boucle plus bas installe chaque paquet après build pour résoudre les chaînes).
# - libxmlrpc, satyr : deps de libreport (deps officielles uniquement)
# - libreport : tiré par python-meh ; chaîne AUR→AUR → APRÈS satyr+libxmlrpc
# - winboat-bin : app FWS
# - python-* : deps Anaconda présentes dans l'AUR (deps officielles only)
# python-blivet est packagé en LOCAL (pkgbuilds/, patché sans libselinux).
# gnome-kiosk (WM de la session GUI) est différé au chantier C.
AUR_PACKAGES=(libxmlrpc satyr libreport winboat-bin python-langtable python-pid python-iso639 python-xkbregistry python-requests-ftp)
DISTRO_NAME="${ARCH_WSL_DISTRO:-Arch}"
RED='\033[0;31m'; GREEN='\033[0;32m'; YELLOW='\033[1;33m'
@@ -73,6 +81,51 @@ if [[ "$OSTYPE" == "msys" || "$OSTYPE" == "cygwin" || -n "$WINDIR" ]]; then
exit 0
fi
# ============================================================
# Bascule conteneur : hôte non-Arch (Fedora, Ubuntu, …) →
# setup dans un conteneur Arch via podman (rootful, --privileged).
# Voir build.sh pour le détail du design ; même image, même volume de
# cache pacman, dépôt monté au MÊME chemin absolu (→ local-repo/ revient
# sur l'hôte). makepkg refuse root mais on est dans le conteneur en root :
# setup-aur.sh recrée son propre utilisateur fwsbuild, c'est transparent.
# ============================================================
host_is_arch() {
# Fedora empaquette aussi « pacman » → sa seule présence ne suffit pas.
command -v pacman >/dev/null 2>&1 \
&& grep -qiE '^ID(_LIKE)?=.*arch' /etc/os-release 2>/dev/null
}
if [ -z "$FWS_IN_CONTAINER" ] && ! host_is_arch; then
info "Hôte non-Arch détecté — setup dans un conteneur Arch (podman)..."
command -v podman >/dev/null 2>&1 \
|| error "podman introuvable. Fedora : 'sudo dnf install -y podman' ; Debian/Ubuntu : 'sudo apt install -y podman'."
SUDO=(); [ "$EUID" -eq 0 ] || SUDO=(sudo)
TTY=(); [ -t 0 ] && TTY=(-it)
REPO_DIR="$(cd "$(dirname "${BASH_SOURCE[0]}")" && pwd)"
IMAGE="docker.io/library/archlinux:latest"
# pull explicite : « run » ne re-résout pas « latest » une fois en cache.
info "Pull de l'image $IMAGE"
"${SUDO[@]}" podman pull "$IMAGE"
info "Relance dans le conteneur (setup-aur.sh)…"
"${SUDO[@]}" podman run --rm "${TTY[@]}" --privileged \
-e FWS_IN_CONTAINER=1 \
-v "$REPO_DIR":"$REPO_DIR" \
-v fws-pacman-cache:/var/cache/pacman/pkg \
-w "$REPO_DIR" \
"$IMAGE" \
bash "$REPO_DIR/setup-aur.sh"
# podman rootful → local-repo/ appartient à root : on le rend à l'hôte.
OWNER="$(stat -c '%u:%g' "$REPO_DIR" 2>/dev/null || true)"
if [ -n "$OWNER" ] && [ -e "$REPO_DIR/local-repo" ]; then
"${SUDO[@]}" chown -R "$OWNER" "$REPO_DIR/local-repo" 2>/dev/null || true
fi
exit 0
fi
# ============================================================
# Vérifications
# ============================================================
@@ -95,12 +148,12 @@ BUILD_USER="fwsbuild"
# ============================================================
step "0/4 — Préparation pacman (sandbox WSL + keyring)"
# ============================================================
# pacman ≥ 7 utilise landlock pour sandboxer les ops fs.
# Le kernel WSL ne supporte pas landlock → désactivation explicite.
if grep -qi 'microsoft\|wsl' /proc/version 2>/dev/null; then
# pacman ≥ 7 utilise landlock pour sandboxer les ops fs. Ni le kernel WSL
# ni (selon le noyau) le conteneur ne le supportent → désactivation explicite.
if grep -qi 'microsoft\|wsl' /proc/version 2>/dev/null || [ -n "$FWS_IN_CONTAINER" ]; then
if ! grep -qE '^[[:space:]]*DisableSandbox' /etc/pacman.conf; then
sed -i '/^\[options\]/a DisableSandbox' /etc/pacman.conf
warn "WSL détecté → DisableSandbox ajouté à /etc/pacman.conf"
warn "WSL/conteneur détecté → DisableSandbox ajouté à /etc/pacman.conf"
fi
fi
@@ -157,7 +210,13 @@ for pkg in "${AUR_PACKAGES[@]}"; do
info "Build $pkg (peut prendre plusieurs minutes)…"
su - "$BUILD_USER" -c "cd $BUILD_DIR/$pkg && makepkg -s --noconfirm" \
|| error "Build $pkg échoué"
success "$pkg build OK"
# Installe le paquet construit AVANT de passer au suivant : indispensable
# pour les chaînes AUR→AUR (libreport dépend de satyr + libxmlrpc) et pour
# que les PKGBUILD locaux (python-meh → libreport) trouvent leurs deps.
# makepkg -s ne résout que les dépôts officiels, jamais les paquets AUR.
pacman -U --noconfirm "$BUILD_DIR/$pkg/"*.pkg.tar.zst \
|| error "Install du paquet $pkg échouée"
success "$pkg build + install OK"
done
# ------------------------------------------------------------
@@ -174,7 +233,11 @@ if [ -d "$LOCAL_PKGBUILDS_DIR" ]; then
chown -R "$BUILD_USER:$BUILD_USER" "$BUILD_DIR/$name"
su - "$BUILD_USER" -c "cd $BUILD_DIR/$name && makepkg -sf --noconfirm" \
|| error "Build local $name échoué"
success "$name build OK"
# Install (même logique que la boucle AUR) pour que les futurs paquets
# locaux dépendants se résolvent (ex. anaconda → pykickstart/blivet/…).
pacman -U --noconfirm "$BUILD_DIR/$name/"*.pkg.tar.zst \
|| error "Install du paquet local $name échouée"
success "$name build + install OK"
done
fi