# POWER Maintainer: Alexander Baldeck <alex.bldck@gmail.com>
# Maintainer: Levente Polyak <anthraxx[at]archlinux[dot]org>
# Maintainer: T.J. Townsend <blakkheim@archlinux.org>
# Contributor: Adrian Perez de Castro <aperez@igalia.com>

pkgname=signify
pkgver=32
pkgrel=3.1
pkgdesc='OpenBSD tool to cryptographically sign and verify files'
url='https://github.com/aperezdc/signify'
arch=(x86_64 powerpc64le powerpc64 powerpc riscv64)
license=('BSD')
makedepends=('git')
depends=('glibc' 'libbsd>=0.8')
source=(git+https://github.com/aperezdc/signify.git?signed#tag=v${pkgver}
        ${pkgname}-LICENSE-${pkgver}::https://raw.githubusercontent.com/aperezdc/signify/v${pkgver}/COPYING)
sha512sums=('31eba7b62c87627c7f4998ad975d24a2a0bb019049eab44ac20027e383e9600f4360097306721b34afd95526c68c0a78092544f9c84bcfc3586f4ea49bcc9763'
            '5de1345ef929058040975f1106318ac9443fc107d19a12bfbc919a152ddd4dde11c76201722bc5847bad579e5dc4ba467f0947b6f0fce5cc3eccc68d5f4e9dfe')
validpgpkeys=(
  '5AA3BC334FD7E3369E7C77B291C559DBE4C9123B' # Adrián Pérez de Castro <aperez@igalia.com>
)

prepare() {
  cd ${pkgname}
  # using O_NOFOLLOW doesn't lock anything down here, swapping files
  # without symlinks is still equally open to TOCTOU and it doesn't even
  # matter here. let's prefer supporting symlinked target files.
  sed -E 's/\| ?O_NOFOLLOW//g' -i ./*.c
}

build () {
  cd ${pkgname}
  make PREFIX=/usr \
    LTO=1 \
    EXTRA_CFLAGS="${CFLAGS} ${CPPFLAGS}" \
    EXTRA_LDFLAGS="${LDFLAGS}" \
    GIT_TAG=''
}

package () {
  cd ${pkgname}
  make PREFIX=/usr \
    DESTDIR="${pkgdir}" \
    GIT_TAG='' install
  install -Dm644 README.md CHANGELOG.md -t "${pkgdir}/usr/share/doc/${pkgname}"
  install -Dm644 ../${pkgname}-LICENSE-${pkgver} "${pkgdir}/usr/share/licenses/${pkgname}/LICENSE"
}

# vim: ts=2 sw=2 et:
