# 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    = "doas"
version = "6.8.2"

[source]
tarball = "https://github.com/Duncaen/OpenDoas/archive/v6.8.2.tar.gz"
# FIXME sha256: el wrapper lo calcula (Alpine publica sha512). sha512 de Alpine:
# sha512 = "4a93ff477413c859ba2702e688fa4f83248fff85e61e12336838a1e9aa1a8d9963a9782e4bc5e58e8d04b86c2c8ceb6b235ae9d3b32b3e548a2514a43653137d"
sha256  = "6da058a0e70b7543bc60624389b0b00b686189ec933828c522bf8b2600495a67"
patches = ["configuration-directory.patch", "manpage-example-path.patch", "change-PATH.patch", "rowhammer.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() {
./configure \
		--prefix=/usr \
		--without-pam \
		--with-timestamp \
		--with-doas-confdir
	make
}
_abuild_phase
'''
# package(): copia manual (make install hace chown root:root → falla en el sandbox;
# doas.conf de aports no viaja). El binario setuid es cosa de la hidratación.
install = '''
_abuild_phase() {
	install -D -m 755 doas "/out"/usr/bin/doas
	install -D -m 644 doas.1 "/out"/usr/share/man/man1/doas.1 2>/dev/null || true
	install -D -m 644 doas.conf.5 "/out"/usr/share/man/man5/doas.conf.5 2>/dev/null || true
}
_abuild_phase
'''

[deps]
build = ["bison"]
