# $Id: PKGBUILD 136888 2015-07-14 14:18:27Z mtorromeo $
# Maintainer: Massimiliano Torromeo <massimiliano.torromeo@gmail.com>
# Maintainer: Mantas M. <grawity@gmail.com>

pkgname=sssd
pkgver=1.13.0
pkgrel=1
pkgdesc="System Security Services Daemon"
arch=('i686' 'x86_64')
url="https://fedorahosted.org/sssd/"
license=('GPL3')
depends=(
  'augeas'
  'bind'          # for nsupdate
  'c-ares'
  'cyrus-sasl-gssapi'
  'ding-libs'
  'libnl'
  'libunistring'
  'nss'
  'smbclient'     # for libndr-nbt
  'nfsidmap'
)
makedepends=(
  'docbook-xsl'
  'doxygen'
  'python'
  'python2'
  'samba'         # for libndr-nbt headers
)
source=("https://fedorahosted.org/released/$pkgname/$pkgname-$pkgver.tar.gz"
        'sssd.service')
sha1sums=('f9c57cfb91d8e0e35d565a1d5b165e8f669989d2'
          '2d10db3d6f54a58bbf8d1f27328e68555256e0ce')

prepare() {
  cd "$srcdir/$pkgname-$pkgver"
  for f in "${source[@]}"; do
    if [[ $f == *.patch ]]; then
      msg2 "Applying $f"
      patch -p1 < "$srcdir/$f"
    fi
  done
}

build() {
  cd "$srcdir/$pkgname-$pkgver"
  ./configure \
    --prefix=/usr                                 \
    --sbindir=/usr/bin                            \
    --sysconfdir=/etc                             \
    --localstatedir=/var                          \
    --libexecdir=/usr/lib/sssd                    \
    --datadir=/usr/share                          \
    --enable-pammoddir=/usr/lib/security          \
    --with-initscript=systemd                     \
    --with-os=fedora                              \
    --with-pid-path=/run                          \
    --with-python2-bindings                       \
    --with-python3-bindings                       \
    --with-syslog=journald                        \
    --without-selinux                             \
    --without-semanage                            \
    --with-systemdunitdir=/usr/lib/systemd/system \
    ;
  sed -i '/\<HAVE_KRB5_SET_TRACE_CALLBACK\>/d' config.h
  make
}

package() {
  cd "$srcdir/$pkgname-$pkgver"
  make -j1 DESTDIR="$pkgdir/" install
  rm -rf "$pkgdir/etc/rc.d"
  rm -rf "$pkgdir/lib"
  rm -rf "$pkgdir/run"
  rm -f "$pkgdir/usr/lib/ldb/modules/ldb/memberof.la"
  find "$pkgdir/usr" -depth -type d \
    -exec rmdir --ignore-fail-on-non-empty {} \;

  cd "$srcdir"
  rm -rf "$pkgdir/etc/systemd" # remove the drop-in
  install -Dm0644 sssd.service  "$pkgdir/usr/lib/systemd/system/sssd.service"
}

# vim: ts=2:sw=2:et:nowrap
