#!/usr/bin/env bash
name='shadow'
release='3'
version='4.18.0'
url='https://github.com/shadow-maint/shadow/releases'
description='Password and account management tool suite with support for shadow files and PAM'
email='aliriza.keskin@pardus.org.tr'
maintainer='aliriza'
license=('GPLv3')
source=("https://github.com/shadow-maint/shadow/releases/download/$version/shadow-$version.tar.xz"
        "useradd.defaults"
        "shadow.sysconf"
        "system-auth")
depends=(pam libxcrypt acl attr)
makedepends=( )
sha256sums=('add4604d3bc410344433122a819ee4154b79dd8316a56298c60417e637c07608'
         'SKIP'
         'SKIP'
         'SKIP')
uses=()
arch=('x86_64')
group=(sys.apps)

cd $name-$version

setup(){
    autoreconf -fiv
    ./configure --prefix=/usr \
        --libdir=/usr/lib64 \
        --sysconfdir=/etc \
        --bindir=/usr/bin \
        --sbindir=/usr/sbin \
        --disable-account-tools-setuid \
        --without-sssd \
        --with-fcaps \
        --with-libpam \
        --without-group-name-max-length \
        --without-selinux \
        --without-libbsd \
        --with-yescrypt \
        --without-bcrypt \
        --disable-nls
}

build(){
    make $jobs
}

package(){
    make install $jobs
    # remove selinux stuff
    sed -i "/.*selinux.*/d" ${DESTDIR}/etc/pam.d/*
    install -vDm 600 ../useradd.defaults "${DESTDIR}/etc/default/useradd"
    install -vDm 600 ../system-auth "${DESTDIR}/etc/pam.d/system-auth.d/50-shadow"
    install -vDm 755 ../shadow.sysconf ${DESTDIR}/etc/sysconf.d/shadow
    mkdir -p $DESTDIR/etc/suid.d
    echo "/usr/bin/su" > $DESTDIR/etc/suid.d/shadow
}

