NAME="lightdm"
DESC="Lightweight display manager based upon GTK"
VERSION="1.32.0"
FILES=(
  "https://github.com/CanonicalLtd/lightdm/releases/download/$VERSION/lightdm-$VERSION.tar.xz"
  "service"
)
HASHES=(
  "e62a5da6c35f612e4d9575eda5c8d467"
  "2b17539bb0eab1bf2cc2eb139ddac88de4c125d8e665a5a8e3dab05e97ebb7e2"
)
DEPENDS=(
  "libgcrypt" "itstool" "linux-pam"
  "xorg" "gobject-introspection" "libxklavier"
  "at-spi2-core" 
)

PACKAGE() {
  tar xf $NAME-$VERSION.tar.xz
  cd $NAME-$VERSION

  ./configure --prefix=/usr               \
            --libexecdir=/usr/lib/lightdm \
            --localstatedir=/var          \
            --sbindir=/usr/bin            \
            --sysconfdir=/etc             \
            --disable-static              \
            --disable-tests               \
            --with-greeter-user=lightdm   \
            --with-greeter-session=lightdm-gtk-greeter \
            --docdir=/usr/share/doc/lightdm-$VERSION
  
  make && make DESTDIR="$ROOTDIR" install 
  
  cp tests/src/lightdm-session "$ROOTDIR/usr/bin"
  sed -i '1 s/sh/bash --login/' "$ROOTDIR/usr/bin/lightdm-session"
  rm -rf "$ROOTDIR/etc/init"

  mkdir -pv "$ROOTDIR/usr/lib/systemd/system"
  cp "$ROOTDIR/service" "$ROOTDIR/usr/lib/systemd/system/lightdm.service"

  cd .. && rm -r $NAME-$VERSION
}

INSTALL(){
  groupadd -g 65 lightdm
  useradd  -c "Lightdm Daemon"          -d /var/lib/lightdm          -u 65 -g lightdm             -s /bin/false lightdm
  
  install -v -dm755 -o lightdm -g lightdm /var/lib/lightdm
  install -v -dm755 -o lightdm -g lightdm /var/lib/lightdm-data
  install -v -dm755 -o lightdm -g lightdm /var/cache/lightdm
  install -v -dm770 -o lightdm -g lightdm /var/log/lightdm
  
  exit 0
}
