# Importada de Alpine aports por `hammer import-alpine` (Etapa G). PUNTO DE PARTIDA — pero
# YA trae los parches de musl de Alpine (lo que un import de nix pierde). Pendiente: el
# sha256 del tarball (el wrapper lo calcula), y adaptar build/install del shell de abuild.
name    = "rbw"
version = "1.15.0"

[source]
tarball = "https://git.tozt.net/rbw/snapshot/rbw-1.15.0.tar.gz"
# FIXME sha256: el wrapper lo calcula (Alpine publica sha512). sha512 de Alpine:
# sha512 = "8ec109c62ced929db36aca8b828d01c1fe46ca5b6a7970fdf9c1e4566fa8c7873c076fc8e0500ba3afbe6d1fd91d0e84177eac452a7fb9ec86451b8b2e08d2d6"
sha256  = "660cfa4c727711665bef060046c28dd3924ca1e490fdc058d90d35372b2d2cf6"

[build]
compiler = "zig-cc"
target   = "x86_64-linux-musl"
link     = "static"
flags    = []

[build.phases]
# de build() de Alpine (traducido; el lab provee $CBUILD/$CHOST — Etapa G Fase 3; revisá --shared para estático):
compile = '''
_abuild_phase() {
# p521 fails with stack overflow unless stack size is increased
	export RUST_MIN_STACK=$((16 * 1024 * 1024))
	cargo auditable build --frozen --release

	target/release/rbw gen-completions bash > rbw.bash
	target/release/rbw gen-completions fish > rbw.fish
	target/release/rbw gen-completions zsh > _rbw
}
_abuild_phase
'''
# de package() de Alpine (traducido $pkgdir→/out):
install = '''
_abuild_phase() {
install -Dm755 target/release/rbw "/out"/usr/bin/rbw
	install -Dm755 target/release/rbw-agent "/out"/usr/bin/rbw-agent

	install -Dm644 rbw.bash \
		"/out"/usr/share/bash-completion/completions/rbw
	install -Dm644 rbw.fish \
		"/out"/usr/share/fish/vendor_completions.d/rbw.fish
	install -Dm644 _rbw \
		"/out"/usr/share/zsh/site-functions/_rbw
}
_abuild_phase
'''

# depends de runtime de Alpine (NO build-deps): pinentry
