# 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    = "gzip"
version = "1.14"
license = "GPL-3.0-or-later"

[source]
tarball = "https://ftp.gnu.org/gnu/gzip/gzip-1.14.tar.xz"
# FIXME sha256: el wrapper lo calcula (Alpine publica sha512). sha512 de Alpine:
# sha512 = "82aef53188b3e69b51b7ddab5b8c44a11a5b73c0039b22a315a0c7d244694feab0146748add4265901eb1b4c0cee8a9eb69594995f098830d964091af97079c5"
sha256  = "01a7b881bd220bfdf615f97b8718f80bdfd3f6add385b993dcf6efd14e8c0ac6"

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

# Split de la info de depuración (SDD 23 etapa 4, tanda de HOJAS). Entra en `hash_inputs`.
strip_debug = true
flags    = []

[deps]
build = ["binutils", "make"]

[build.phases]
# de build() de Alpine (traducido; el lab provee $CBUILD/$CHOST — Etapa G Fase 3; revisá --shared para estático):
compile = '''
_abuild_phase() {
# avoid text relocation
	export DEFS="NO_ASM"
	./configure \
		--build=$CBUILD \
		--host=$CHOST \
		--prefix=/usr \
		--mandir=/usr/share/man \
		--infodir=/usr/share/info
	make
}
_abuild_phase
'''
# de package() de Alpine (traducido $pkgdir→/out):
install = '''
_abuild_phase() {
make DESTDIR=/out install

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

	mkdir -p "/out"/bin
	local i; for i in gzip gunzip zcat; do
		mv "/out"/usr/bin/$i "/out"/bin/
	done

	# http://bugs.alpinelinux.org/issues/4011
	ln -sf /bin/gunzip "/out"/usr/bin/uncompress
}
_abuild_phase
'''

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