#!/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=pam
pkgver=1.5.3
pkgrel=03
pkgdesc="PAM (Pluggable Authentication Modules) library - w/o systemd"
url="http://linux-pam.org"
depends=('glibc' 'libtirpc' 'pambase' 'audit' 'libaudit.so' 'libxcrypt' 'libcrypt.so')
makedepends=('flex' 'w3m' 'docbook-xml>=4.4' 'docbook-xsl')
provides=('libpam.so' 'libpamc.so' 'libpam_misc.so')
backup=(etc/security/{access.conf,faillock.conf,group.conf,limits.conf,namespace.conf,namespace.init,pwhistory.conf,pam_env.conf,time.conf} etc/environment) 
source=(https://github.com/linux-pam/linux-pam/releases/download/v$pkgver/Linux-PAM-$pkgver{,-docs}.tar.xz{,.asc}
        $pkgname.tmpfiles)

options=('!emptydirs')

build() {
  cd Linux-PAM-$pkgver
# prevent the installation of an unneeded systemd file:
#	sed -e /service_DATA/d \
#	    -i modules/pam_namespace/Makefile.am &&
# this is the same as proposed by LFS as removing it
# at the end with the post_-install statement at the
# end of the PKGBUILD
# also disabling systemd options here in ./config 
# seems also acceptable

  ./configure \
    --libdir=/usr/lib \
    --sbindir=/usr/bin \
    --disable-db \
    --enable-logind \
    --disable-systemd
  make
}

package() {
  install -Dm 644 $pkgname.tmpfiles "$pkgdir"/usr/lib/tmpfiles.d/$pkgname.conf
  cd Linux-PAM-$pkgver
  make DESTDIR="$pkgdir" SCONFIGDIR=/etc/security install

  # set unix_chkpwd uid
  chmod +s "$pkgdir"/usr/bin/unix_chkpwd

  # remove doc which is not used anymore
  # FS #40749
#  rm $pkgdir/usr/share/doc/Linux-PAM/sag-pam_userdb.html
  rm $pkgdir/usr/lib/systemd/system/pam_namespace.service

}

post_install() {
	# Fix unix_chkpwd perms.
	chmod 4755 ${DESTDIR}/usr/bin/unix_chkpwd
}

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

arch=(x86_64)

license=('GPL2')

validpgpkeys=(8C6BFD92EE0F42EDF91A6A736D1A7F052E5924BB # Thorsten Kukuk
	296D6F29A020808E8717A8842DB5BD89A340AEB7) #Dimitry V. Levin <ldv@altlinux.org>

sha256sums=(7ac4b50feee004a9fa88f1dfd2d2fa738a82896763050cd773b3c54b0a818283  # Linux-PAM-1.5.3.tar.xz
	ce5690766060d60a8f0fba447f480d8d49988821740698cbdf2ecfd84dc8895c  # Linux-PAM-1.5.3.tar.xz.asc
	fe7493aa0a281f8cfe81814768329f953098d0fd8073da1dc0bd64494d022d4d  # Linux-PAM-1.5.3-docs.tar.xz
	eabd232fa4d59e151bc2cffd3f2cefc8f82440113fa4650159b85435542bd60f  # Linux-PAM-1.5.3-docs.tar.xz.asc
	5631f224e90c4f0459361c2a5b250112e3a91ba849754bb6f67d69d683a2e5ac) #  pam.tmpfiles

##  0f3dc4a95d0e43139f72bba9d592f6d28db318f153d98250caa6172bf1000176  pam-1.5.3-03-x86_64.pkg.tar.lz
