%bcond_with systemd

Summary: A lightweight display manager
Summary(ja): 軽量ディスプレイマネージャー
Name: lightdm
Version: 1.30.0
Group: system
Release: 1%{?_dist_release}%{?with_systemd:.systemd}
Vendor: Project Vine
Distribution: Vine Linux

License: GPLv3,LGPLv2,LGPLv3
URL: https://github.com/canonical/lightdm
Source0: https://github.com/canonical/lightdm/releases/download/%{version}/%{name}-%{version}.tar.xz

Source10:	lightdm-pam
Source11:	lightdm-autologin-pam
Source12:	lightdm-tmpfiles.conf
Source13:	lightdm.service
Source14:	lightdm.logrotate
Source15:	lightdm.rules

# .conf snippets
Source20:	50-backup-logs.conf
Source21:	50-minimum-vt.conf
Source22:	50-session-wrapper.conf
Source23:	50-user-authority-in-system-dir.conf
Source24:	50-xserver-command.conf
Source25:	50-disable-guest.conf
Source26:	50-run-directory.conf

Patch0:		gcc-10.patch

# Upstreamed:
Patch1:		lightdm-1.25.1-disable_dmrc.patch

Patch101: lightdm-1.11.2-nodaemon_option.patch
# for Vine Linux
Patch1000: lightdm-1.17.2-vine.patch

Requires(pre): shadow-utils
Requires: accountsservice
Requires: dbus-x11
Requires: pam
Requires: xorg-x11-xinit
Requires: %{name}-gobject = %{version}-%{release}
Requires: lightdm-greeter

BuildRequires: glib2-devel >= 2.30.0
BuildRequires: gobject-introspection-devel
BuildRequires: libXdmcp-devel
BuildRequires: libxcb-devel
BuildRequires: libxklavier-devel
BuildRequires: libX11-devel
BuildRequires: pam-devel
BuildRequires: libgcrypt-devel
BuildRequires: yelp-tools

Obsoletes:		%{name}-qt < 1.30.0
Obsoletes:		%{name}-qt-devel < 1.30.0

%description
An display manager that:
 * Has a lightweight codebase
 * Is standards compliant (PAM, ConsoleKit, etc)
 * Has a well defined interface between the server and user interface
 * Cross-desktop (greeters can be written in any toolkit)


%package		gobject
Summary:		LightDM GObject client library
Group:			system

%description	gobject
This package contains a GObject based library for LightDM clients to
use to interface with LightDM.


%package		gobject-devel
Summary:		Development files and headers for %{name}-gobject
Group:			programming
Requires:		%{name}-gobject = %{version}-%{release}
Requires:		pkgconfig

%description	gobject-devel
Development files and headers for %{name}-gobject.


%prep
%setup -q
%autosetup -p 1


%build
autoreconf -if
%configure \
	--disable-dmrc \
	--disable-silent-rules \
	--disable-static \
	--enable-liblightdm-gobject \
	--enable-introspection \
	--disable-liblightdm-qt \
	--disable-liblightdm-qt5 \
	--with-greeter-user=lightdm

make %{?_smp_mflags}


%install
rm -rf $RPM_BUILD_ROOT
make install DESTDIR=$RPM_BUILD_ROOT

# We need to own these
%{__mkdir_p} %{buildroot}%{_sysconfdir}/lightdm/lightdm.conf.d/		\
	%{buildroot}%{_datadir}/dbus-1/interfaces		\
	%{buildroot}%{_datadir}/dbus-1/system.d			\
	%{buildroot}%{_datadir}/lightdm/lightdm.conf.d/		\
	%{buildroot}%{_datadir}/lightdm/remote-sessions/	\
	%{buildroot}%{_datadir}/xgreeters/			\
	%{buildroot}%{_localstatedir}/cache/lightdm/		\
	%{buildroot}%{_rundir}/lightdm/		\
	%{buildroot}%{_localstatedir}/log/lightdm/		\
	%{buildroot}%{_localstatedir}/lib/lightdm/		\
	%{buildroot}%{_localstatedir}/lib/lightdm-data/

# libtool cruft
rm -fv %{buildroot}%{_libdir}/lib*.la

# We don't ship AppAmor
%{__rm} -rfv %{buildroot}%{_sysconfdir}/apparmor.d/

# omit upstart support
%{__rm} -rfv %{buildroot}%{_sysconfdir}/init

# install pam file
%{__install} -Dpm 0644 %{SOURCE10} %{buildroot}%{_sysconfdir}/pam.d/lightdm
%{__install} -Dpm 0644 %{SOURCE11} %{buildroot}%{_sysconfdir}/pam.d/lightdm-autologin
%{__install} -Dpm 0644 %{SOURCE14} %{buildroot}%{_sysconfdir}/logrotate.d/lightdm
%{__install} -Dpm 0644 %{SOURCE15} %{buildroot}%{_datadir}/polkit-1/rules.d/lightdm.rules
%{__install} -pm 0644 %{SOURCE20} %{SOURCE21} %{SOURCE22} %{SOURCE23}	\
	%{SOURCE24} %{SOURCE25} %{SOURCE26} %{buildroot}%{_datadir}/lightdm/lightdm.conf.d/

%if %{with systemd}
%{__install} -Dpm 0644 %{SOURCE12} %{buildroot}%{_tmpfilesdir}/lightdm.conf
%{__install} -Dpm 0644 %{SOURCE13} %{buildroot}%{_unitdir}/lightdm.service
%{__install} -pm 0644 %{SOURCE26} %{buildroot}%{_datadir}/lightdm/lightdm.conf.d/
%else
mkdir -p %{buildroot}%{_localstatedir}/run/lightdm
%endif

# Move DBus config to proper location.
# why is this needed? -- rex
%{__mv} -f %{buildroot}%{_sysconfdir}/dbus-1/system.d/*.conf		\
	%{buildroot}%{_datadir}/dbus-1/system.d

%find_lang lightdm --with-gnome


%triggerun -- lightdm < 1.30.0
getent passwd lightdm >/dev/null && \
  /usr/sbin/usermod -d /var/lib/lightdm lightdm >/dev/null ||:

%pre
getent group lightdm >/dev/null || groupadd -r lightdm
getent passwd lightdm >/dev/null || \
  /usr/sbin/useradd -g lightdm -M -d /var/lib/lightdm -s /sbin/nologin -r lightdm
exit 0

%if %{with systemd}
%post
# todo: document need/purpose for this snippet
if [ $1 = 1 ] ; then
	%{_bindir}/killall -HUP dbus-daemon 2>&1 > /dev/null
fi
%systemd_post lightdm.service

%preun
%systemd_preun lightdm.service

%postun
%systemd_postun lightdm.service
%endif

%post gobject -p /sbin/ldconfig
%postun gobject -p /sbin/ldconfig


%files -f %{name}.lang
%defattr(-, root, root, -)
%license COPYING.GPL3
%doc NEWS
%dir %{_sysconfdir}/lightdm
%dir %{_sysconfdir}/lightdm/lightdm.conf.d
%config(noreplace) %{_sysconfdir}/pam.d/lightdm*
%config(noreplace) %{_sysconfdir}/lightdm/keys.conf
%config(noreplace) %{_sysconfdir}/lightdm/lightdm.conf
%config(noreplace) %{_sysconfdir}/lightdm/users.conf
%dir %{_sysconfdir}/logrotate.d/
%{_sysconfdir}/logrotate.d/lightdm
%dir %attr(-,lightdm,lightdm) %{_localstatedir}/cache/lightdm/
%dir %attr(-,lightdm,lightdm) %{_localstatedir}/lib/lightdm/
%dir %attr(-,lightdm,lightdm) %{_localstatedir}/lib/lightdm-data/
%dir %attr(-,lightdm,lightdm) %{_localstatedir}/log/lightdm/
%dir %{_datadir}/bash-completion
%dir %{_datadir}/bash-completion/completions
%dir %{_datadir}/xgreeters/
%{_bindir}/dm-tool
%{_sbindir}/lightdm
%{_libexecdir}/lightdm-guest-session
%{_datadir}/lightdm/
%{_mandir}/man1/dm-tool.1.gz
%{_mandir}/man1/lightdm.1.gz
%{_datadir}/accountsservice
%{_datadir}/dbus-1/interfaces/*.xml
%{_datadir}/dbus-1/system.d/*.conf
%{_datadir}/polkit-1/rules.d/lightdm.rules
%{_datadir}/polkit-1/actions/org.freedesktop.DisplayManager.AccountsService.policy
%{_datadir}/bash-completion/completions/dm-tool
%{_datadir}/bash-completion/completions/lightdm
%if %{with systemd}
%{_unitdir}/lightdm.service
%{_tmpfilesdir}/lightdm.conf
%ghost %dir %{_rundir}/lightdm
%else
%dir %{_localstatedir}/run/lightdm
%endif

%files gobject
%defattr(-, root, root, -)
%license COPYING.LGPL2 COPYING.LGPL3
%{_libdir}/liblightdm-gobject-1.so.*
%{_libdir}/girepository-1.0/LightDM-1.typelib

%files gobject-devel
%defattr(-, root, root, -)
%{_includedir}/lightdm-gobject-1
%{_libdir}/liblightdm-gobject-1.so
%{_libdir}/pkgconfig/liblightdm-gobject-1.pc
%{_datadir}/gir-1.0/LightDM-1.gir
%{_datadir}/gtk-doc/html/lightdm-gobject-1


%changelog
* Tue Aug 11 2020 Tomohiro "Tomo-p" KATO <tomop@teamgedoh.net> 1.30.0-1
- new upstream release.
- added systemd support (disabled as default).
- dropped subpackages: lightdm-qt{,-devel}.

* Mon Jul  4 2016 Tomohiro "Tomo-p" KATO <tomop@teamgedoh.net> 1.19.2-1
- updated to 1.19.2.

* Sat Nov 28 2015 Yoji TOYODA <bsyamato@sea.plala.or.jp> 1.17.2-1
- update to 1.17.2
- update Patch1000 (lightdm-1.17.2-vine.patch)

* Sat May 09 2015 Yoji TOYODA <bsyamato@sea.plala.or.jp> 1.12.3-1
- update to 1.12.3

* Tue Sep 16 2014 Yoji TOYODA <bsyamato@sea.plala.or.jp> 1.11.9-1
- new upstream release

* Wed Aug 20 2014 Yoji TOYODA <bsyamato@sea.plala.or.jp> 1.11.5-1
- new upstream release
- update Patch1000 (lightdm-1.11.5-vine.patch)

* Sun Jul 06 2014 Yoji TOYODA <bsyamato@sea.plala.or.jp> 1.11.4-1
- new upstream release

* Sun Jun 01 2014 Yoji TOYODA <bsyamato@sea.plala.or.jp> 1.11.2-1
- initial build

