# 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    = "apko"
version = "0.9.0"

[source]
tarball = "https://github.com/chainguard-dev/apko/archive/v0.9.0/apko-0.9.0.tar.gz"
# FIXME sha256: el wrapper lo calcula (Alpine publica sha512). sha512 de Alpine:
# sha512 = "c8883955a99811762c3d358549d041c464a1dfe67f24b63666664c72dc2d0bb10b8ff517a8205c14d56a826bd0d02770aa254eefa06c50026e91833319387f24"
sha256  = "65f248fecf72ef36303e6c61c5599272f1a0d3eb1fa287a6f021917001e29a0b"

[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() {
mkdir build
	go build -o build/ -tags -tags=pivkey,pkcs11key "$builddir"/...

	for i in bash fish zsh; do
		"$builddir"/build/apko completion $i > "$builddir"/apko.$i
	done
}
_abuild_phase
'''
# de package() de Alpine (traducido $pkgdir→/out):
install = '''
_abuild_phase() {
install -Dm755 "$builddir"/build/apko "/out"/usr/bin/apko

	install -Dm644 "$builddir"/apko.bash "/out"/usr/share/bash-completion/completions/apko
	install -Dm644 "$builddir"/apko.fish "/out"/usr/share/fish/vendor_completions.d/apko.fish
	install -Dm644 "$builddir"/apko.zsh "/out"/usr/share/zsh/site-functions/_apko
}
_abuild_phase
'''
