#!/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.6.0
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 \
    --disable-logind \
    --with-systemdunitdir=no \
    --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

#  This is no longer required as it only builds with logind disabled, no 
#  allowance for consolekit to substitute
#  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=(fff4a34e5bbee77e2e8f1992f27631e2329bcbf8a0563ddeb5c3389b4e3169ad  # Linux-PAM-1.6.0.tar.xz
	de8059f3c5ede8efe8feaa74db64e27f2a8d0b6efb119d6b7b7f9baea78dc57a  # Linux-PAM-1.6.0.tar.xz.asc
	3e82730d3350795c42f3708f6609a92c1df841d518aa17c28fd702fe5ec23a32  # Linux-PAM-1.6.0-docs.tar.xz
	bc052464739edb68fc170b660253cca7adc596056cb2a60f11262639a3d3e1e9  # Linux-PAM-1.6.0-docs.tar.xz.asc
	5631f224e90c4f0459361c2a5b250112e3a91ba849754bb6f67d69d683a2e5ac) #  pam.tmpfiles

##  8fb425ef6dfe311d95408d4cac67f12389a7a5bc5dd81ba9cab6321818367384  pam-1.6.0-03-x86_64.pkg.tar.lz

