Add make fetch-nginx: unprivileged nginx binary for the local full-stack test

Co-Authored-By: Claude Sonnet 5.5 <noreply@anthropic.com>
This commit is contained in:
denis
2026-10-16 22:02:29 +02:00
parent e5489d15cd
commit 562f914b3c
3 changed files with 32 additions and 5 deletions
+23
View File
@@ -0,0 +1,23 @@
#!/usr/bin/env bash
# Récupère le binaire nginx de la distribution (Debian/Ubuntu) SANS droits administrateur ni installation :
# le paquet est téléchargé puis extrait dans .local/nginx/. Utilisé par « make dev-nginx » (essai local).
set -euo pipefail
ROOT="$(cd "$(dirname "${BASH_SOURCE[0]}")/.." && pwd)"
TARGET="${ROOT}/.local/nginx"
BINARY="${TARGET}/root/usr/sbin/nginx"
if [[ -x "${BINARY}" ]]; then
echo "nginx déjà présent : ${BINARY}"
exit 0
fi
command -v apt-get >/dev/null || { echo "apt-get absent : installe nginx avec le gestionnaire de ta distribution, ou indique son binaire avec PYQUEST_NGINX." >&2; exit 1; }
command -v dpkg >/dev/null || { echo "dpkg absent : voir PYQUEST_NGINX." >&2; exit 1; }
WORK="$(mktemp -d)"
trap 'rm -rf "${WORK}"' EXIT
(cd "${WORK}" && apt-get download nginx)
mkdir -p "${TARGET}/root"
dpkg -x "${WORK}"/nginx_*.deb "${TARGET}/root"
"${BINARY}" -v
echo "nginx extrait dans ${TARGET} (aucune installation système)."
+5 -4
View File
@@ -57,12 +57,13 @@ http {{
def find_nginx(explicit: str | None) -> str:
candidate = explicit or os.environ.get("PYQUEST_NGINX") or shutil.which("nginx")
fetched = ROOT / ".local/nginx/root/usr/sbin/nginx" # créé par scripts/fetch_nginx.sh (make fetch-nginx)
candidate = explicit or os.environ.get("PYQUEST_NGINX") or shutil.which("nginx") or (str(fetched) if fetched.is_file() else None)
if not candidate or not Path(candidate).is_file():
sys.exit(
"nginx introuvable. Installe-le (sudo apt install nginx) ou récupère seulement le binaire sans droits root :\n"
" mkdir -p /tmp/ngx && cd /tmp/ngx && apt-get download nginx && dpkg -x nginx_*.deb root\n"
" PYQUEST_NGINX=/tmp/ngx/root/usr/sbin/nginx python3 scripts/local_stack.py"
"nginx introuvable. Le plus simple (Debian/Ubuntu, sans droits administrateur ni installation) :\n"
" make fetch-nginx && make dev-nginx\n"
"Ou installe nginx (sudo apt install nginx), ou indique son binaire : PYQUEST_NGINX=/chemin/nginx make dev-nginx"
)
return candidate