#!/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 |---------------------------------------

pkgbase=libxcrypt
pkgname=(libxcrypt libxcrypt-compat)
pkgver=4.4.36
pkgrel=01
pkgdesc='Modern library for one-way hashing of passwords'
url='https://github.com/besser82/libxcrypt/'
depends=('glibc')
makedepends=(gcc)
provides=('libcrypt.so')
#options=('debug')
install=libxcrypt.install
source=("${url}/releases/download/v${pkgver}/${pkgbase}-${pkgver}.tar.xz"{,.asc})

build() {
  mkdir build-libxcrypt build-libxcrypt-compat

  cd "${srcdir}/build-libxcrypt/"
  "${srcdir}/${pkgbase}-${pkgver}"/configure \
    --prefix=/usr \
    --disable-static \
    --enable-hashes=strong,glibc \
    --enable-obsolete-api=no \
    --disable-failure-tokens
  make
  
  cd "${srcdir}/build-libxcrypt-compat/"
  "${srcdir}/${pkgbase}-${pkgver}"/configure \
    --prefix=/usr \
    --disable-static \
    --enable-hashes=strong,glibc \
    --enable-obsolete-api=glibc \
    --disable-failure-tokens
  make
}

check() {
  cd build-libxcrypt/

  make check 
}

package_libxcrypt() {
  cd build-libxcrypt/

  make DESTDIR="${pkgdir}" install
}

package_libxcrypt-compat() {
  pkgdesc='Modern library for one-way hashing of passwords - legacy API functions'
  depends=('libxcrypt')
  
  cd build-libxcrypt-compat/

  make DESTDIR="${pkgdir}" install

  rm -rf "${pkgdir}"/usr/{include,lib/{lib*.so,pkgconfig},share}
}

#---- arch license gpg-key & sha256sums ----

arch=(x86_64)

#license=('GPL')  # till 4.4.35
license=('LGPL')

validpgpkeys=('678CE3FEE430311596DB8C16F52E98007594C21D') # Björn 'besser82' Esser

sha256sums=(e5e1f4caee0a01de2aee26e3138807d6d3ca2b8e67287966d1fefd65e1fd8943  # libxcrypt-4.4.36.tar.xz
	04f2985349a027dd544806b2b6888402fbfd71322c210a94271e1e02f46fbf74) # libxcrypt-4.4.36.tar.xz.asc

##  7fe4fd52062de4f26d3bd835ac7b8ea928d9e18c3036577ba9640047420ddc5a  libxcrypt-4.4.36-01-x86_64.pkg.tar.lz
##  468ce8b405ed3d488b4ca729651d619904f3c5c0681ea457d314ab11c8d4fb6c  libxcrypt-compat-4.4.36-01-x86_64.pkg.tar.lz

