# 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    = "sequoia-sq"
version = "1.3.1"

[source]
tarball = "https://gitlab.com/sequoia-pgp/sequoia-sq/-/archive/v1.3.1/sequoia-sq-v1.3.1.tar.bz2"
# FIXME sha256: el wrapper lo calcula (Alpine publica sha512). sha512 de Alpine:
# sha512 = "043d7ff85333e4a126fe86001ebe0f99c1a2142a4d7ac49138c160b7ce9b9c21c013691ac50f4eb153512e38bb1b151cab1f358c65a8797c55ee0bd6c45fe8a1"
sha256  = "ca4a6ef07ab9ca492c8166d6d6ed0354eb81f418bf819cf095c1ee856c461365"
patches = ["sequoia-openpgp-2.3.0.patch"]

[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() {
export CARGO_TARGET_DIR=target
	cargo auditable build --frozen --release --no-default-features --features crypto-openssl
}
_abuild_phase
'''
# de package() de Alpine (traducido $pkgdir→/out):
install = '''
_abuild_phase() {
install -Dm755 target/release/sq \
		-t "/out"/usr/bin/
	install -Dm644 target/release/build/sequoia-sq-*/out/shell-completions/_sq \
		"/out"/usr/share/zsh/site-functions/_sq
	install -Dm644 target/release/build/sequoia-sq-*/out/shell-completions/sq.bash \
		"/out"/usr/share/bash-completion/completions/sq
	install -Dm644 target/release/build/sequoia-sq-*/out/shell-completions/sq.fish \
		"/out"/usr/share/fish/vendor_completions.d/sq.fish
	install -Dm644 target/release/build/sequoia-sq-*/out/man-pages/*.1 \
		-t "/out"/usr/share/man/man1/
}
_abuild_phase
'''

[deps]
build = ["bzip2", "capnproto", "clang", "openssl", "sqlite"]
