# 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    = "e2fsprogs"
version = "1.47.4"
license = "GPL-2.0-only AND LGPL-2.0-only AND BSD-3-Clause"

[source]
tarball = "https://github.com/tytso/e2fsprogs/archive/v1.47.4.tar.gz"
# FIXME sha256: el wrapper lo calcula (Alpine publica sha512). sha512 de Alpine:
# sha512 = "923c1ba52cf48557e190ee936be47ff3e43e4798950499e3c663f0f077470caefbb69ee845ebe1f969b3e7c1bb0c22e507188f1daca24649c54c5843c835b2f9"
sha256  = "9f82eaa7002673291629077b80ee005cadfcd49854907a22007fed70b0ef596e"

[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    = []

[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 \
		--sysconfdir=/etc \
		--mandir=/usr/share/man \
		--localstatedir=/var \
		--with-udev-rules-dir=no \
		--disable-elf-shlibs \
		--enable-static \
		--enable-symlink-install \
		--disable-fsck \
		--disable-uuidd \
		--disable-libuuid \
		--disable-libblkid \
		--disable-fuse2fs \
		--disable-nls
	make
}
_abuild_phase
'''
# de package() de Alpine (traducido $pkgdir→/out):
install = '''
_abuild_phase() {
make -j1 DESTDIR="/out" install install-libs
	mkdir -p "/out"/sbin/
	local i; for i in e2fsck mke2fs mkfs.* fsck.*; do
		mv "/out"/usr/sbin/$i "/out"/sbin/
	done
	# overwrite busybox symlinks
	mkdir -p "/out"/bin/
	for i in chattr lsattr; do
		mv "/out"/usr/bin/$i "/out"/bin/
	done
}
_abuild_phase
'''

[deps]
build = ["binutils", "linux-headers", "pkgconf"]
