Mueve las recetas de Alpine de "importan" a "casi buildean": - alpine_import.rs: translate_abuild() en las fases — substituye $pkgdir→/out (el DESTDIR del lab), $pkgname→nombre, $pkgver→versión. NO toca $CBUILD/$CHOST/--shared (juicio por-paquete, marcado). +1 test. - scripts/alpine-import.sh: baja el tarball UNA vez y calcula el sha256 (Alpine publica sha512, hammer pide sha256), reemplazando el FIXME ⇒ receta lista sin tocar el hash a mano. - VALIDADO real: import bzip2 → sha256 ab5a0317… resuelto, 5 parches musl bajados, install traducido a /out. Recipe build-ready (sin $pkgdir ni FIXME en código). 31 suites verde. Co-Authored-By: Claude Opus 4.8 <noreply@anthropic.com>
43 lines
2.0 KiB
Bash
Executable File
43 lines
2.0 KiB
Bash
Executable File
#!/bin/sh
|
|
# alpine-import.sh <pkg> [main|community] — Etapa G, fuente #2: baja el APKBUILD de Alpine aports
|
|
# (y SUS PARCHES de musl), y emite la receta hammer vía `hammer import-alpine`. Alpine es la mejor
|
|
# semilla cuando importar de nix falla en musl: su receta YA incluye el trabajo de portabilidad.
|
|
#
|
|
# Ej: scripts/alpine-import.sh coreutils main > recipes/coreutils-alpine.toml
|
|
# (los .patch se bajan a $OUTDIR, default el dir actual)
|
|
# Env: ALPINE_BRANCH (default master), OUTDIR (default .), HAMMER (cmd del cli)
|
|
set -eu
|
|
|
|
PKG="${1:?uso: alpine-import.sh <pkg> [main|community]}"
|
|
REPO="${2:-main}"
|
|
BRANCH="${ALPINE_BRANCH:-master}"
|
|
OUTDIR="${OUTDIR:-.}"
|
|
HAMMER="${HAMMER:-cargo run -q -p hammer-cli --}"
|
|
BASE="https://gitlab.alpinelinux.org/alpine/aports/-/raw/${BRANCH}/${REPO}/${PKG}"
|
|
|
|
apk=$(curl -fsSL "${BASE}/APKBUILD") || { echo "no encontré ${REPO}/${PKG} en aports@${BRANCH}" >&2; exit 1; }
|
|
toml=$(printf '%s' "$apk" | $HAMMER import-alpine -)
|
|
|
|
# sha256 automático: Alpine publica sha512, pero hammer pide sha256. Bajamos el tarball UNA vez y
|
|
# lo calculamos, reemplazando el FIXME ⇒ receta lista para `pack --build` sin tocar el hash a mano.
|
|
url=$(printf '%s\n' "$toml" | sed -n 's/^tarball = "\(.*\)"$/\1/p' | head -1)
|
|
if [ -n "$url" ]; then
|
|
sha=$(curl -fsSL "$url" 2>/dev/null | sha256sum | cut -d' ' -f1)
|
|
if [ -n "$sha" ] && [ "$sha" != "$(printf '' | sha256sum | cut -d' ' -f1)" ]; then
|
|
toml=$(printf '%s\n' "$toml" | sed "s|FIXME-sha256|$sha|")
|
|
echo " sha256 calculado: $sha" >&2
|
|
else
|
|
echo " ⚠ no pude bajar el tarball para sha256 (queda FIXME): $url" >&2
|
|
fi
|
|
fi
|
|
printf '%s\n' "$toml"
|
|
|
|
# Bajar los .patch referenciados (los parches de musl que hacen al paquete compilar).
|
|
printf '%s\n' "$toml" | grep -oE '"[^"]+\.(patch|diff)"' | tr -d '"' | while read -r p; do
|
|
if curl -fsSL "${BASE}/${p}" -o "${OUTDIR}/${p}" 2>/dev/null; then
|
|
echo " ✓ parche bajado: ${OUTDIR}/${p}" >&2
|
|
else
|
|
echo " ✗ no pude bajar ${p} (¿está en otra ruta del aport?)" >&2
|
|
fi
|
|
done
|