# 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    = "tar"
version = "1.35"

[source]
tarball = "https://ftp.gnu.org/gnu/tar/tar-1.35.tar.xz"
# FIXME sha256: el wrapper lo calcula (Alpine publica sha512). sha512 de Alpine:
# sha512 = "8b84ed661e6c878fa33eb5c1808d20351e6f40551ac63f96014fb0d0b9c72d5d94d8865d39e36bcb184fd250f84778a3b271bbd8bd2ceb69eece0c3568577510"
sha256  = "4d62ff37342ec7aed748535323930c7cf94acf71c3591882b26a7ea50f3edc16"
patches = ["ignore-apk-tools-checksums.patch"]

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

[deps]
build = ["make"]

[build.phases]
# de build() de Alpine (traducido; el lab provee $CBUILD/$CHOST — Etapa G Fase 3; revisá --shared para estático):
compile = '''
export CFLAGS="$CFLAGS -flto=auto"
	gl_cv_func_gettimeofday_clobber=no \
	gl_cv_func_tzset_clobber=no \
	./configure \
		--build=$CBUILD \
		--host=$CHOST \
		--prefix=/usr \
		--sysconfdir=/etc \
		--mandir=/usr/share/man \
		--localstatedir=/var
	make
'''
# de package() de Alpine (traducido $pkgdir→/out):
install = '''
make DESTDIR="/out" install

	mkdir -p "/out"/bin
	mv -v "/out"/usr/bin/tar "/out"/bin/
'''
