diff options
Diffstat (limited to 'scripts/bootstrap.sh')
| -rwxr-xr-x | scripts/bootstrap.sh | 155 |
1 files changed, 77 insertions, 78 deletions
diff --git a/scripts/bootstrap.sh b/scripts/bootstrap.sh index 9ba694e..809e4e2 100755 --- a/scripts/bootstrap.sh +++ b/scripts/bootstrap.sh @@ -1,132 +1,131 @@ #!/usr/bin/env bash -# Deja el repositorio en condiciones de ejecutarse: submódulos, parches, -# binarios y modelos. +# Gets the repository ready to run: submodules, patches, binaries and models. # -# Es idempotente: se puede volver a lanzar sin miedo. Y no copia modelos —son -# más de 5 GB—, sino que los enlaza desde donde ya estén. +# It is idempotent: it can be run again safely. And it does not copy models +# (they are more than 5 GB); it links them from wherever they already are. set -euo pipefail cd "$(dirname "$0")/.." -RAIZ="$PWD" +ROOT="$PWD" -# Repositorios ya clonados en el sistema, para no volver a bajar de la red ni -# recompilar lo que ya está compilado. -ESPEJO="${ASIST_ESPEJO:-$HOME/GIT-MIRRO}" +# Repositories already cloned on the system, so nothing is downloaded or +# rebuilt again. ASIST_ESPEJO is the old name of ASIST_MIRROR. +MIRROR="${ASIST_MIRROR:-${ASIST_ESPEJO:-$HOME/GIT-MIRRO}}" HF="${ASIST_HF:-$HOME/HF}" -azul() { printf '\033[36m%s\033[0m\n' "$*"; } -verde() { printf '\033[32m%s\033[0m\n' "$*"; } -aviso() { printf '\033[33m%s\033[0m\n' "$*" >&2; } -malo() { printf '\033[31m%s\033[0m\n' "$*" >&2; } +blue() { printf '\033[36m%s\033[0m\n' "$*"; } +green() { printf '\033[32m%s\033[0m\n' "$*"; } +warn() { printf '\033[33m%s\033[0m\n' "$*" >&2; } +bad() { printf '\033[31m%s\033[0m\n' "$*" >&2; } -enlazar() { # origen destino descripción - local origen="$1" destino="$2" que="$3" - if [ ! -e "$origen" ]; then - aviso " no está $que: $origen" +link() { # source target description + local src="$1" dst="$2" what="$3" + if [ ! -e "$src" ]; then + warn " $what not found: $src" return 1 fi - mkdir -p "$(dirname "$destino")" - if [ -L "$destino" ] || [ -e "$destino" ]; then - rm -rf "$destino" + mkdir -p "$(dirname "$dst")" + if [ -L "$dst" ] || [ -e "$dst" ]; then + rm -rf "$dst" fi - ln -s "$origen" "$destino" - verde " $que -> $(basename "$origen")" + ln -s "$src" "$dst" + green " $what -> $(basename "$src")" } # --------------------------------------------------------------------------- -azul "1/5 Submódulos" -# Si el repositorio está clonado al lado, se usa como referencia: llama.cpp son -# 406 MB de objetos que no hace falta volver a descargar. -for nombre in canary-rs qwentts.cpp llama.cpp; do - ruta="vendor/$nombre" - if [ -f "$ruta/.git" ] || [ -d "$ruta/.git" ]; then +blue "1/5 Submodules" +# If the repository is cloned next door, it is used as a reference: llama.cpp +# is 406 MB of objects that do not need downloading again. +for name in canary-rs qwentts.cpp llama.cpp; do + path="vendor/$name" + if [ -f "$path/.git" ] || [ -d "$path/.git" ]; then continue fi - if [ -d "$ESPEJO/$nombre/.git" ]; then + if [ -d "$MIRROR/$name/.git" ]; then git -c protocol.file.allow=always submodule update --init \ - --reference "$ESPEJO/$nombre" "$ruta" + --reference "$MIRROR/$name" "$path" else - git submodule update --init "$ruta" + git submodule update --init "$path" fi done git submodule status | sed 's/^/ /' # --------------------------------------------------------------------------- -azul "2/5 Parches y ficheros sueltos" -# Los parches recogen los cambios locales sobre cada repositorio: sin ellos, el -# ASR se comporta distinto al que se midió. -for nombre in canary-rs qwentts.cpp llama.cpp; do - parche="$RAIZ/vendor/patches/$nombre.patch" - [ -s "$parche" ] || continue +blue "2/5 Patches and loose files" +# The patches hold the local changes on each repository: without them the ASR +# behaves differently from the one that was measured. +for name in canary-rs qwentts.cpp llama.cpp; do + patch="$ROOT/vendor/patches/$name.patch" + [ -s "$patch" ] || continue ( - cd "vendor/$nombre" - if git apply --check "$parche" 2>/dev/null; then - git apply "$parche" - verde " $nombre: parche aplicado" - elif git apply --reverse --check "$parche" 2>/dev/null; then - verde " $nombre: parche ya aplicado" + cd "vendor/$name" + if git apply --check "$patch" 2>/dev/null; then + git apply "$patch" + green " $name: patch applied" + elif git apply --reverse --check "$patch" 2>/dev/null; then + green " $name: patch already applied" else - malo " $nombre: el parche no aplica; revísalo a mano" + bad " $name: the patch does not apply; review it by hand" fi ) done -# Ficheros que sólo existían en el árbol de trabajo local y que un parche no -# puede llevar. canary-rs no compila sin bench_live.rs: su Cargo.toml lo declara. +# Files that only existed in the local working tree and a patch cannot carry. +# canary-rs does not build without bench_live.rs: its Cargo.toml declares it. if [ -d vendor/extra ]; then - for nombre in canary-rs qwentts.cpp; do - [ -d "vendor/extra/$nombre" ] || continue - cp -rn "vendor/extra/$nombre/." "vendor/$nombre/" 2>/dev/null || true + for name in canary-rs qwentts.cpp; do + [ -d "vendor/extra/$name" ] || continue + cp -rn "vendor/extra/$name/." "vendor/$name/" 2>/dev/null || true done - verde " ficheros sueltos copiados" + green " loose files copied" fi # --------------------------------------------------------------------------- -azul "3/5 Motores en C++" -enlazar_o_construir() { # nombre ruta_build orden_de_construccion... - local nombre="$1" build="$2"; shift 2 - if [ -e "vendor/$nombre/$build" ]; then - verde " $nombre ya está construido" +blue "3/5 C++ engines" +link_or_build() { # name build_path build_command... + local name="$1" build="$2"; shift 2 + if [ -e "vendor/$name/$build" ]; then + green " $name is already built" return fi - if [ -e "$ESPEJO/$nombre/$build" ]; then - enlazar "$ESPEJO/$nombre/$(dirname "$build")" \ - "$RAIZ/vendor/$nombre/$(dirname "$build")" "build de $nombre" + if [ -e "$MIRROR/$name/$build" ]; then + link "$MIRROR/$name/$(dirname "$build")" \ + "$ROOT/vendor/$name/$(dirname "$build")" "$name build" return fi - aviso " $nombre sin construir. Construyendo (esto tarda)…" - ( cd "vendor/$nombre" && "$@" ) + warn " $name not built. Building (this takes a while)…" + ( cd "vendor/$name" && "$@" ) } -enlazar_o_construir llama.cpp build/bin/llama-server \ +link_or_build llama.cpp build/bin/llama-server \ bash -c 'cmake -B build -DCMAKE_BUILD_TYPE=Release -DGGML_CUDA=ON && cmake --build build -j --target llama-server' -enlazar_o_construir qwentts.cpp build/tts-server \ +link_or_build qwentts.cpp build/tts-server \ bash -c './buildcuda.sh' # --------------------------------------------------------------------------- -azul "4/5 Modelos" -# Se enlazan, no se copian: son más de 5 GB entre todos. -enlazar "$HF/Qwen/Qwen3.5-2B.Q5_K_M.gguf" "$RAIZ/models/Qwen3.5-2B.Q5_K_M.gguf" "modelo del LLM" || true -enlazar "$HF/Qwen/mmproj-BF16.gguf" "$RAIZ/models/mmproj-BF16.gguf" "proyector multimodal" || true +blue "4/5 Models" +# Linked, not copied: together they are more than 5 GB. +link "$HF/Qwen/Qwen3.5-2B.Q5_K_M.gguf" "$ROOT/models/Qwen3.5-2B.Q5_K_M.gguf" "LLM model" || true +link "$HF/Qwen/mmproj-BF16.gguf" "$ROOT/models/mmproj-BF16.gguf" "multimodal projector" || true for m in qwen-talker-1.7b-base-Q8_0.gguf qwen-tokenizer-12hz-Q8_0.gguf; do - enlazar "$ESPEJO/qwentts.cpp/models/$m" "$RAIZ/models/$m" "$m" || true + link "$MIRROR/qwentts.cpp/models/$m" "$ROOT/models/$m" "$m" || true done if [ ! -d vendor/canary-rs/models/canary-180m-flash-onnx ] \ - && [ -d "$ESPEJO/canary-rs/models/canary-180m-flash-onnx" ]; then - enlazar "$ESPEJO/canary-rs/models/canary-180m-flash-onnx" \ - "$RAIZ/vendor/canary-rs/models/canary-180m-flash-onnx" "modelo Canary" || true + && [ -d "$MIRROR/canary-rs/models/canary-180m-flash-onnx" ]; then + link "$MIRROR/canary-rs/models/canary-180m-flash-onnx" \ + "$ROOT/vendor/canary-rs/models/canary-180m-flash-onnx" "Canary model" || true fi # --------------------------------------------------------------------------- -azul "5/5 Voz de referencia" -# El asistente habla con una voz clonada. Si no hay una preparada, se dice cómo -# hacerla en vez de fallar: el resto ya funciona con una voz del modelo. +blue "5/5 Reference voice" +# The assistant speaks with a cloned voice. If none is prepared, say how to make +# one instead of failing: everything else already works with a model voice. if [ -f assets/voices/asistente.spk ]; then - verde " ya hay una voz en assets/voices/" + green " there is already a voice in assets/voices/" else - aviso " sin voz clonada. Prepárala con:" - aviso " scripts/clonar-voz.sh <grabacion.wav> <transcripcion.txt>" - aviso " o quita la sección [tts.reference] de config/asistente.toml para" - aviso " usar una voz del propio modelo." + warn " no cloned voice. Prepare one with:" + warn " scripts/clone-voice.sh <recording.wav> <transcript.txt>" + warn " or remove the [tts.reference] section from config/asistente.toml to" + warn " use one of the model's own voices." fi echo -azul "Listo. Comprueba con: cargo run --release -- check" +blue "Done. Check with: cargo run --release -- check" |