# $Id$
# Maintainer: Massimiliano Torromeo <massimiliano.torromeo@gmail.com>
# Maintainer: Mantas M. <grawity@gmail.com>

pkgname=sssd
pkgver=1.12.0
pkgrel=4
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'
  'dbus-core'
  'ding-libs'
  'libnl'
  'libunistring'
  'nss'
  'smbclient'     # for libndr-nbt
  'systemd'
)
makedepends=(
  'docbook-xsl'
  'doxygen'
  'python2'
  'samba'         # for libndr-nbt headers
)
source=("https://fedorahosted.org/released/$pkgname/$pkgname-$pkgver.tar.gz"
        "https://fedorahosted.org/released/$pkgname/$pkgname-$pkgver.tar.gz.asc"
        '0001-AD-add-missing-debug-to-stderr-option-to-gpo_child.patch'
        '0002-KRB5-add-missing-debug-to-stderr-option-to-krb5_chil.patch'
        'sssd.service')
sha1sums=('482d126430b52e00b49b9ba10276a8f6ed2d8408'
          'SKIP'
          '6cc2704b73d32b0c5b68de038f80ab967e5f3520'
          'ed5961ed325be966e5e1aa204ff430f9a895d510'
          '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"
  export PYTHON=/usr/bin/python2
  ./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-python-bindings                        \
    --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 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
