# Tanım: Hafif bir giriş yönetici
# URL: https://launchpad.net/lightdm
# Paketçi: yasarciv67@gmail.com
# Gerekler: gcc glib gobject-introspection gtk-doc intltool itstool libgcrypt xorg-libx11 libxcb xorg-libxdmcp xorg-libxklavier pam polkit qt4 qt5 vala

isim=lightdm
surum=1.22.0
devir=1

kaynak=(https://launchpad.net/lightdm/${surum%.*}.tar.xz
        lightdm.service
        lightdm.tmpfiles
        lightdm.pam
        lightdm-autologin.pam
        lightdm.rules
        lightdm-default-config.patch
        Xsession)

derle() {
	cd $isim-$surum
patch -Np1 -i ../lightdm-default-config.patch

  export MOC4=moc-qt4
  export MOC5=moc-qt5

  ./configure \
    --prefix=/usr \
    --libexecdir=/usr/lib/lightdm \
    --localstatedir=/var \
    --sbindir=/usr/bin \
    --sysconfdir=/etc \
    --with-greeter-user=lightdm \
    --with-greeter-session=lightdm-gtk-greeter \
    --disable-static \
    --enable-liblightdm-qt5=no \
    --disable-tests
  
  make DESTDIR=${PKG} install
  make DESTDIR=${PKG} -C liblightdm-qt uninstall
  install -m 755 ../Xsession ${PKG}/etc/lightdm/Xsession
  rm -rf ${PKG}/etc/init
  rm -rf ${PKG}/usr/include/lightdm-qt{,5}-*

  install -dm 755 ${PKG}/var/cache/lightdm
  install -dm 770 ${PKG}/var/lib/lightdm{,-data}
  install -dm 711 ${PKG}/var/log/lightdm
  chmod +t ${PKG}/var/{cache/lightdm,lib/lightdm{,-data}}
  chown 620:620 -R ${PKG}/var/lib/lightdm{,-data}
  chgrp 620 ${PKG}/var/log/lightdm

  # PAM
  install -m 644 ../lightdm.pam ${PKG}/etc/pam.d/lightdm
  install -m 644 ../lightdm-autologin.pam ${PKG}/etc/pam.d/lightdm-autologin

  # PolicyKit
  install -dm 750 -g 102 ${PKG}/usr/share/polkit-1/rules.d
  install -m 644 ../lightdm.rules ${PKG}/usr/share/polkit-1/rules.d/lightdm.rules

   make DESTDIR=${PKG} -C liblightdm-gobject install
  make DESTDIR=${PKG} -C liblightdm-qt install
  make DESTDIR=${PKG} -C liblightdm-gobject uninstall
  find ${PKG} -type d -name *qt5* -exec rm -rf {} +
  find ${PKG} -type f -name *qt5* -exec rm {} +
  find ${PKG} -type l -name *qt5* -exec rm {} +

 
  make DESTDIR=${PKG} -C liblightdm-gobject install
  make DESTDIR=${PKG} -C liblightdm-qt install
  make DESTDIR=${PKG} -C liblightdm-gobject uninstall
  find ${PKG} -type d -name *qt[!5]* -exec rm -rf {} +
  find ${PKG} -type f -name *qt[!5]* -exec rm {} +
  find ${PKG} -type l -name *qt[!5]* -exec rm {} +

  make
  make DESTDIR=$PKG install
}
