#!/usr/bin/bash
# JOBoRun		: Jwm OpenBox Obarun RUNit
# Maintainer	: Joe Bo Run <joborun@disroot.org>
# PkgSource		: url="https://gittea.disroot.org/joborun-pkg/jobcore/$pkgname"
# Website		: https://pozol.eu
#-----------------------------------------| DESCRIPTION |---------------------------------------

pkgname=gnupg
pkgver=2.2.41
pkgrel=01
pkgdesc='Complete and free implementation of the OpenPGP standard w/o systemd'
arch=('x86_64')
url='https://www.gnupg.org/'
depends=( 'bzip2' 'libbz2.so' 'glibc' 'gnutls' 'libgcrypt'
  'libgpg-error' 'libksba' 'libassuan' 'libassuan.so' 'npth'
  'libnpth.so' 'pinentry' 'readline' 'libreadline.so' 'sqlite' 'zlib')
checkdepends=('openssh')
makedepends=('libldap' 'libusb-compat' 'pcsclite' 'automake' 'autoconf' 'gettext')
optdepends=('libldap: gpg2keys_ldap'
            'libusb-compat: scdaemon'
            'pcsclite: scdaemon')

# options=('debug')  ###  uncomment this line to have the debug pkg produced
source=("https://gnupg.org/ftp/gcrypt/${pkgname}/${pkgname}-${pkgver}.tar.bz2"{,.sig}
	'drop-import-clean.patch'
	'avoid-beta-warning.patch')

# install=$pkgname.install  ###  this was for linking systemd sockets and such crap !!

prepare() {
  cd "${srcdir}/${pkgname}-${pkgver}"

  local src
  for src in "${source[@]}"; do
    src="${src%%::*}"
    src="${src##*/}"
    [[ $src = *.patch ]] || continue
    msg2 "Applying patch $src..."
    patch -Np1 < "../$src"
  done

  # improve reproducibility
  rm doc/gnupg.info*

  ./autogen.sh
}

build() {
	cd "${srcdir}/${pkgname}-${pkgver}"
	./configure \
		--prefix=/usr \
		--sysconfdir=/etc \
		--sbindir=/usr/bin \
		--libexecdir=/usr/lib/gnupg \
		--enable-maintainer-mode \
		--disable-systemd

	make
}

check() {
	cd "${srcdir}/${pkgname}-${pkgver}"
	make check
}

package() {
  local units=({dirmngr,gpg-agent{,-{browser,extra,ssh}}}.socket)

	local unit
	cd "${srcdir}/${pkgname}-${pkgver}"
	make DESTDIR="${pkgdir}" install
	ln -s gpg "${pkgdir}"/usr/bin/gpg2
	ln -s gpgv "${pkgdir}"/usr/bin/gpgv2
	install -Dm 644 COPYING.{CC0,other} -t "${pkgdir}/usr/share/licenses/$pkgname/"
}

#---- license gpg-key sha256sums ----

#license=('GPL')
#license=(BSD custom CC0 GPL2 GPL3 LGPL3 LGPL2.1 MIT) # 2.35.1-02
license=(BSD custom custom:CC0 GPL2 GPL3 LGPL3 LGPL2.1 MIT) # 2.37

validpgpkeys=(5B80C5754298F0CB55D8ED6ABCEF7E294B092E28 # Andre Heinecke (Release Signing Key)
	6DAA6E64A76D2840571B4902528897B826403ADA # Werner Koch (dist signing 2020)
	AC8E115BF73E2D8D47FA9908E98E9B2D19C6C8BD # Niibe Yutaka (GnuPG Release Key)
	02F38DFF731FF97CB039A1DA549E695E905BA208) # GnuPG.com (Release Signing Key 2021)

sha256sums=(13f3291007a5e8546fcb7bc0c6610ce44aaa9b3995059d4f8145ba09fd5be3e1  # gnupg-2.2.41.tar.bz2
	36428c1b7ff352d3762df8f78a24d77d90b12d652367cd7f7f43707ece1b8c46  # gnupg-2.2.41.tar.bz2.sig
	02d375f0045f56f7dd82bacdb5ce559afd52ded8b75f6b2673c39ec666e81abc  # drop-import-clean.patch
	22fdf9490fad477f225e731c417867d9e7571ac654944e8be63a1fbaccd5c62d) #  avoid-beta-warning.patch

##   c4eb373e3ae03a9e49d444d8836e385359766c28c10f834e0fb1b400c3008bea  gnupg-2.2.41-01-x86_64.pkg.tar.lz



