# 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    = "sed"
version = "4.10"

[source]
tarball = "https://ftp.gnu.org/pub/gnu/sed/sed-4.10.tar.xz"
# FIXME sha256: el wrapper lo calcula (Alpine publica sha512). sha512 de Alpine:
# sha512 = "20224df834b363ca1357024234bb93df3929c252c40c7ef3d23e78fc05177c7986e3145a5049d63db746a4dc2c97befb0324a87ea081507292ff6cd5383ee9db"
sha256  = "b8e72182b2ec96a3574e2998c47b7aaa64cc20ce000d8e9ac313cc07cecf28c7"
patches = ["skip-test-memset_explicit-on-arm.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 \
		--build=$CBUILD \
		--host=$CHOST \
		--prefix=/usr \
		--bindir=/bin \
		--mandir=/usr/share/man \
		--infodir=/usr/share/info \
		--disable-i18n \
		--disable-nls
	make
}
_abuild_phase
'''
# de package() de Alpine (traducido $pkgdir→/out):
install = '''
_abuild_phase() {
make DESTDIR="/out" install

	rm -rf "/out"/usr/lib/charset.alias || true
	rmdir -p "/out"/usr/lib 2>/dev/null || true
}
_abuild_phase
'''

# perl era build-dep de Alpine sólo para tests/docs; el tarball trae configure + sed.1 pregenerado.
[deps]
build = ["linux-headers", "make"]
