# 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    = "screen"
version = "5.0.1"

[source]
tarball = "https://git.savannah.gnu.org/gitweb/?p=screen.git;a=snapshot;h=v.5.0.1;sf=tgz"
# FIXME sha256: el wrapper lo calcula (Alpine publica sha512). sha512 de Alpine:
# sha512 = "1e11374c74c9b4acb49e51baf9af6a151bda333f57392918ebd2167274454eb80b8ac8a17f6aa38d921f7f6d919e4b43f10a35da652a4a36b374ce8b97b8610a"
sha256  = "FIXME-sha256"

[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() {
CFLAGS="$CFLAGS -flto=auto" \
	./configure \
		--build=$CBUILD \
		--host=$CHOST \
		--prefix=/usr \
		--sysconfdir=/etc \
		--with-system_screenrc=/etc/screenrc \
		--mandir=/usr/share/man \
		--infodir=/usr/share/info \
		--localstatedir=/var \
		--enable-telnet
	make
}
_abuild_phase
'''
# de package() de Alpine (traducido $pkgdir→/out):
install = '''
_abuild_phase() {
make -j1 DESTDIR="/out" install

	# remove suid root
	find "/out" -type f -perm -u+s -print0 \
		| xargs -0 chmod -c -s

	install -Dm644 etc/etcscreenrc "/out"/etc/screenrc
	install -Dm644 etc/screenrc "/out"/etc/skel/.screenrc
}
_abuild_phase
'''

[deps]
build = ["autoconf", "automake", "linux-pam", "ncurses"]
