1a88ab3199
The v0.8 milestone: installable on any Debian-based server via docker (Gitea registry image, honest sandbox degrade), deb (amd64+arm64, advisory postinst), and arch-aware binary — with release consistency enforced by pre-commit hooks + Gitea Actions (3-runner fleet on CT 113, machine-made releases with the full 8-asset matrix + registry image), the CLI carrying the full suite (guide, channel-aware doctor), and the admin runbook (deploy/README.md, evidence-backed recipes). ---ci--- phase: 6 milestone: v0.8 status: complete requirements: covered: [REQ-8-001, REQ-8-002, REQ-8-003, REQ-8-004, REQ-8-005] partial: [] ---/ci---
76 lines
2.5 KiB
Bash
Executable File
76 lines
2.5 KiB
Bash
Executable File
#!/usr/bin/env bash
|
|
# Idempotent bootstrap: create venv + install deps.
|
|
# Handles Debian/Ubuntu systems without python3-venv/ensurepip via --without-pip + get-pip.
|
|
# v2 (v0.3.5): recovers from a poisoned partial .venv left by a failed earlier
|
|
# attempt, cleans before each retry, and dies with a distro-specific fix hint
|
|
# when venv creation is impossible (e.g. missing python3.XX-venv package).
|
|
set -euo pipefail
|
|
SCRIPT_DIR="$(cd "$(dirname "$0")" && pwd)"
|
|
APP_DIR="$(cd "$SCRIPT_DIR/.." && pwd)"
|
|
VENV="$APP_DIR/.venv"
|
|
|
|
venv_usable() {
|
|
[ -x "$VENV/bin/python3" ]
|
|
}
|
|
|
|
rm_broken_venv() {
|
|
echo "bootstrap: removing broken partial .venv from a failed earlier attempt" >&2
|
|
rm -rf "$VENV"
|
|
}
|
|
|
|
mkdir -p "$HOME/.cache/ciagent"
|
|
|
|
if venv_usable && [ ! -x "$VENV/bin/pip" ]; then
|
|
# A usable python3 without pip means the --without-pip fallback half-ran and
|
|
# the get-pip step never completed: start over cleanly.
|
|
rm_broken_venv
|
|
fi
|
|
|
|
if ! venv_usable; then
|
|
if [ -d "$VENV" ]; then
|
|
# Directory exists but no working python3: remains of a crashed venv create.
|
|
rm_broken_venv
|
|
fi
|
|
if python3 -m venv "$VENV" 2>/tmp/venv-create.err; then
|
|
:
|
|
else
|
|
rm -rf "$VENV"
|
|
if python3 -m venv --without-pip "$VENV" 2>>/tmp/venv-create.err; then
|
|
:
|
|
else
|
|
rm -rf "$VENV"
|
|
PYVER="$(python3 -c 'import sys; print("%d.%d" % sys.version_info[:2])' 2>/dev/null || true)"
|
|
PKG="python3-venv"
|
|
[ -n "$PYVER" ] && PKG="python${PYVER}-venv"
|
|
echo "bootstrap: could not create a virtual environment." >&2
|
|
echo " python3 reported:" >&2
|
|
sed 's/^/ /' /tmp/venv-create.err >&2 || true
|
|
echo " fix (Debian/Ubuntu): install the venv support package, then re-run nextcraft bootstrap:" >&2
|
|
echo " apt install $PKG" >&2
|
|
exit 1
|
|
fi
|
|
fi
|
|
fi
|
|
|
|
if [ ! -x "$VENV/bin/pip" ]; then
|
|
GET_PIP="$HOME/.cache/ciagent/get-pip.py"
|
|
if [ ! -f "$GET_PIP" ]; then
|
|
if ! curl -sSf --max-time 60 https://bootstrap.pypa.io/get-pip.py -o "$GET_PIP"; then
|
|
rm -rf "$VENV"
|
|
echo "bootstrap: get-pip.py download failed (no network?)." >&2
|
|
echo " fix: restore network access and re-run nextcraft bootstrap" >&2
|
|
exit 1
|
|
fi
|
|
fi
|
|
if ! "$VENV/bin/python3" "$GET_PIP" --quiet; then
|
|
rm -rf "$VENV"
|
|
echo "bootstrap: pip installation into the venv failed." >&2
|
|
echo " fix: re-run nextcraft bootstrap (the venv was cleaned; this retry is safe)" >&2
|
|
exit 1
|
|
fi
|
|
fi
|
|
|
|
"$VENV/bin/pip" install --quiet --upgrade pip
|
|
"$VENV/bin/pip" install --quiet -e "$APP_DIR[dev]"
|
|
echo "bootstrap complete: $VENV"
|