# 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    = "seatd"
version = "0.9.3"

[source]
tarball = "https://git.sr.ht/~kennylevinsen/seatd/archive/0.9.3.tar.gz"
# FIXME sha256: el wrapper lo calcula (Alpine publica sha512). sha512 de Alpine:
# sha512 = "8cb21cfbd9aa25966fe3f586de75d24a8625142ffb49e6ec357875c347d3e92d535467b817d79fdc704f80858a145f1107c488adbf22a1c337dbc6ccccc8b00a"
sha256  = "302564d54d8e28191fadfd734f2675ecb0c9e0615a58011b89ef15dfa4dbaa96"

[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() {
if [ "$CARCH" = 'ppc64le' ]; then
		# https://todo.sr.ht/~kennylevinsen/seatd/10
		# https://www.openwall.com/lists/musl/2020/01/20/3
		export CFLAGS="$CFLAGS -Wno-error=overflow"
	fi

	abuild-meson \
		-Dlibseat-logind=elogind \
		-Dman-pages=enabled \
		. output

	meson compile -C output
}
_abuild_phase
'''
# de package() de Alpine (traducido $pkgdir→/out):
install = '''
_abuild_phase() {
DESTDIR="/out" meson install --no-rebuild -C output
	chmod u+s "/out"/usr/bin/seatd-launch

	install -Dm755 "$srcdir"/seatd.initd "/out"/etc/init.d/seatd
	install -Dm644 "$srcdir"/seatd.confd "/out"/etc/conf.d/seatd
}
_abuild_phase
'''

[deps]
build = ["scdoc", "elogind", "linux-headers"]
