# gnupg 2.4.9 — GnuPG (gpg: firma/cifrado/verificación). De-Alpinizada (Etapa G).
# Cadena crypto canónica sellada: libgpg-error, libgcrypt, libassuan, libksba, npth.
# Objetivo mínimo: binario gpg (y gpgv) estático musl. scdaemon/dirmngr/tofu desactivados
# (quitan deps de red/smartcard/sqlite); doc/nls/bzip2 fuera para no arrastrar deps ausentes.
name    = "gnupg"
version = "2.4.9"
license = "GPL-3.0-or-later"

[source]
tarball = "https://gnupg.org/ftp/gcrypt/gnupg/gnupg-2.4.9.tar.bz2"
sha256  = "dd17ab2e9a04fd79d39d853f599cbc852062ddb9ab52a4ddeb4176fd8b302964"
patches = ["0001-include-unistd.patch", "0010-avoid-beta-warning.patch", "0020-avoid-regenerating-defsincdate-use-shipped-file.patch", "0110-avoid-simple-memory-dumps-via-ptrace.patch", "0210-dirmngr-hkp-avoid-potential-race-condition-when-some-host-die.patch", "0230-dirmngr-avoid-automatically-checking-upstream-swdb.patch", "0330-gpg-default-to-sha512-for-all-signature-types-on-rsa-keys.patch", "0340-gpg-prefer-sha512-and-sha384-in-personal-digest.patch", "0420-gpg-drop-import-clean-from-default-keyserver-import-options.patch", "fix-i18n.patch", "HACK-revert-rfc4880bis-default.patch"]

[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]
configure = '''
./configure \
	--build=$CBUILD \
	--host=$CHOST \
	--prefix=/usr \
	--sysconfdir=/etc \
	--localstatedir=/var \
	--enable-static \
	--disable-shared \
	--disable-nls \
	--disable-tofu \
	--disable-scdaemon \
	--disable-dirmngr \
	--disable-doc \
	--disable-gpgtar \
	--disable-wks-tools \
	--disable-photo-viewers \
	--without-readline \
	--disable-bzip2 \
	--with-libgpg-error-prefix=/usr \
	--with-libgcrypt-prefix=/usr \
	--with-libassuan-prefix=/usr \
	--with-ksba-prefix=/usr \
	--with-npth-prefix=/usr
'''
compile = 'make'
install = '''
make DESTDIR="/out" install

cd "/out"

# compat symlinks
ln -s gpg  usr/bin/gpg2
ln -s gpgv usr/bin/gpgv2

# tool interno de tests
rm -f usr/bin/gpgscm
'''

[deps]
build = ["binutils", "libgpg-error", "libgcrypt", "libassuan", "libksba", "npth", "zlib", "linux-headers", "pkgconf", "make"]
