%define glib2_version           2.20.0
%define dbus_version            1.2
%define dbus_glib_version       0.80
%define polkit_version          0.92

Summary: System daemon for tracking users, sessions and seats
Summary(ja): ユーザ、セッションおよび座席を捕捉するシステムデーモン
Name: ConsoleKit
Version: 0.4.1
Release: 1%{?_dist_release}
License: GPLv2+
Group: System Environment/Daemons
URL: http://www.freedesktop.org/wiki/Software/ConsoleKit

Source0: http://people.freedesktop.org/~mccann/dist/ConsoleKit-%{version}.tar.bz2

BuildRoot: %{_tmppath}/%{name}-%{version}-%{release}-root
BuildRequires: glib2-devel >= %{glib2_version}
BuildRequires: dbus-devel  >= %{dbus_version}
BuildRequires: dbus-glib-devel >= %{dbus_glib_version}
BuildRequires: polkit-devel >= %{polkit_version}
BuildRequires: pam-devel
BuildRequires: libX11-devel
BuildRequires: zlib-devel
BuildRequires: xmlto
Requires: dbus
Requires: dbus-glib

%description
ConsoleKit is a system daemon for tracking what users are logged
into the system and how they interact with the computer (e.g.
which keyboard and mouse they use).

It provides asynchronous notification via the system message bus.


%package x11
Summary: X11-requiring add-ons for ConsoleKit
Summary(ja): X11 を必要とする ConsoleKit アドオン
License: GPLv2+
Group: System Environment/Daemons
Requires: %name = %{version}-%{release}
Requires: libX11

%description x11
ConsoleKit contains some tools that require Xlib to be installed,
those are in this separate package so server systems need not install
X. Applications (such as xorg-x11-xinit) and login managers (such as
gdm) that need to register their X sessions with ConsoleKit needs to
have a Requires: for this package.


%package libs
Summary: ConsoleKit libraries
Summary(ja): ConsoleKit ライブラリ
License: MIT
Group: System Environment/Libraries
Requires: pam
Requires: dbus

%description libs
Libraries and a PAM module for interacting with ConsoleKit.


%package devel
Summary: Development libraries and headers for ConsoleKit
Summary(ja): Development libraries and headers for ConsoleKit
License: MIT
Group: Development/Libraries
Requires: dbus-devel
Requires: pkgconfig

%description devel
Headers, libraries and API docs for ConsoleKit


%package docs
Summary: Developer documentation for ConsoleKit
Summary(ja): ConsoleKit の開発用ドキュメント
Group: Development/Libraries
Requires: %name = %{version}-%{release}

%description docs
Developer documentation for ConsoleKit.


%prep
%setup -q

%build
%configure --with-pid-file=%{_localstatedir}/run/console-kit-daemon.pid --enable-pam-module --with-pam-module-dir=/%{_lib}/security --enable-docbook-docs --docdir=%{_datadir}/doc/%{name}-%{version}

make


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

rm -f $RPM_BUILD_ROOT%{_libdir}/*.a
rm -f $RPM_BUILD_ROOT%{_libdir}/*.la
rm -f $RPM_BUILD_ROOT/%{_lib}/security/*.a
rm -f $RPM_BUILD_ROOT/%{_lib}/security/*.la

# make sure we don't package a history log
rm -f $RPM_BUILD_ROOT/%{_var}/log/ConsoleKit/history

cp AUTHORS COPYING ChangeLog HACKING INSTALL NEWS README TODO \
	$RPM_BUILD_ROOT%{_datadir}/doc/%{name}-%{version}

#mkdir -p %{buildroot}%{_sysconfdir}/init.d
#install -m 755 %{SOURCE10} %{buildroot}%{_sysconfdir}/init.d/ConsoleKit


%clean
rm -rf $RPM_BUILD_ROOT


%post
if [ -f /var/log/ConsoleKit/history ]; then
   chmod a+r /var/log/ConsoleKit/history
fi

%post libs -p /sbin/ldconfig

%postun libs -p /sbin/ldconfig

%files
%defattr(-,root,root,-)
%doc %dir %{_datadir}/doc/%{name}-%{version}
%doc %{_datadir}/doc/%{name}-%{version}/[A-Z]*
%{_sysconfdir}/dbus-1/system.d/*
#%{_sysconfdir}/init.d/ConsoleKit
%{_datadir}/dbus-1/system-services/*.service
%{_datadir}/polkit-1/actions/*.policy
%dir %{_sysconfdir}/ConsoleKit
%dir %{_sysconfdir}/ConsoleKit/seats.d
%dir %{_sysconfdir}/ConsoleKit/run-seat.d
%dir %{_sysconfdir}/ConsoleKit/run-session.d
%dir %{_prefix}/lib/ConsoleKit
%dir %{_prefix}/lib/ConsoleKit/scripts
%dir %{_prefix}/lib/ConsoleKit/run-seat.d
%dir %{_prefix}/lib/ConsoleKit/run-session.d
%dir %{_var}/run/ConsoleKit
%attr(755,root,root) %dir %{_var}/log/ConsoleKit
%config %{_sysconfdir}/ConsoleKit/seats.d/00-primary.seat
%{_sbindir}/console-kit-daemon
%{_sbindir}/ck-log-system-restart
%{_sbindir}/ck-log-system-start
%{_sbindir}/ck-log-system-stop
%{_bindir}/ck-history
%{_bindir}/ck-launch-session
%{_bindir}/ck-list-sessions
%{_prefix}/lib/ConsoleKit/scripts/*

%files x11
%defattr(-,root,root,-)
%{_libexecdir}/*

%files libs
%defattr(-,root,root,-)
%{_libdir}/lib*.so.*
/%{_lib}/security/*.so
%{_mandir}/man8/pam_ck_connector.8.gz

%files devel
%defattr(-,root,root,-)
%{_libdir}/lib*.so
%{_libdir}/pkgconfig/*
%{_includedir}/*
%{_datadir}/dbus-1/interfaces/org.freedesktop.ConsoleKit.*.xml

%files docs
%defattr(-,root,root,-)
%doc %dir %{_datadir}/doc/%{name}-%{version}/spec
%doc %{_datadir}/doc/%{name}-%{version}/spec/*


%changelog
* Mon Oct 19 2009 Daisuke SUZUKI <daisuke@linux.or.jp> 0.4.1-1
- new upstream release

* Mon May 04 2009 Daisuke SUZUKI <daisuke@linux.or.jp> 0.3.0-6
- add patch11 to enable policy access to the Manager.GetSessions
  method in the default ConsoleKit.conf
  https://bugs.freedesktop.org/show_bug.cgi?id=20471
  http://bugzilla.gnome.org/show_bug.cgi?id=580259

* Fri Mar 27 2009 Daisuke SUZUKI <daisuke@linux.or.jp> 0.3.0-5
- add patch10 to fix dbus permissions
  https://bugs.freedesktop.org/show_bug.cgi?id=19020
  (This patch is already committed to master)

* Sat Feb 14 2009 Ryoichi INAGAKI <ryo1@bc.wakwak.com> 0.3.0-4
- changed Group to System Environment/Daemons
- changed x11 subpackage's Group to System Environment/Daemons
- changed libs subpackage's Group to System Environment/Libraries
- added %%post, %%postun section fo libs subpackage

* Sat Aug 09 2008 Shu KONNO <owa@bg.wakwak.com> 0.3.0-3
- changed %%{_libdir}/ConsoleKit to %%{_prefix}/lib/ConsoleKit

* Thu Aug 07 2008 Daisuke SUZUKI <daisuke@linux.or.jp> 0.3.0-2
- remove init script, console-kit-daemon is now launched from dbus.

* Mon Aug 04 2008 Daisuke SUZUKI <daisuke@linux.or.jp> 0.3.0-1
- new upstream release

* Tue Jul  1 2008 MATSUBAYASHI Kohji <shaolin@vinelinux.org> - 0.2.10-3
- fix Japanese description
- spec in UTF-8
- add Source10 (init.d script for console-kit-daemon);
  add %%post/%%preun scripts, until "initng" being introduced to Vine

* Wed Jun 25 2008 MATSUBAYASHI Kohji <shaolin@vinelinux.org> - 0.2.10-2
- rebuilt with PolicyKit-0.8

* Sun May 18 2008 Daisuke SUZUKI <daisuke@linux.or.jp> 0.2.10-1
- new upstream release
- new versioning policy

* Tue Jan 22 2008 Daisuke SUZUKI <daisuke@linux.or.jp> 0.2.3-0vl1
- initial build for Vine Linux

* Mon Oct 22 2007 Matthias Clasen  <mclasen@redhat.com> - 0.2.3-2
- Rebuild against new dbus-glib

* Tue Sep 18 2007 Matthias Clasen  <mclasen@redhat.com> - 0.2.3-1
- Update to 0.2.3

* Mon Sep 17 2007 Matthias Clasen  <mclasen@redhat.com> - 0.2.2-1
- Update to 0.2.2

* Mon Aug  6 2007 Matthias Clasen  <mclasen@redhat.com> - 0.2.1-4
- Update license field

* Fri Jul  6 2007 Matthias Clasen  <mclasen@redhat.com> - 0.2.1-3
- Add LSB header to init script (#246894)

* Mon Apr 16 2007 David Zeuthen <davidz@redhat.com> - 0.2.1-2
- Set doc directory correctly

* Mon Apr 16 2007 David Zeuthen <davidz@redhat.com> - 0.2.1-1
- Update to upstream release 0.2.1
- Drop the patch to daemonize properly as that was merged upstream

* Mon Apr 02 2007 David Zeuthen <davidz@redhat.com> - 0.2.1-0.git20070402
- Update to git snapshot to get a lot of bug fixes
- Use libX11 rather than gtk2 to verify X11 sessions; update BR and R
- Split X11-using bits into a new subpackage ConsoleKit-x11 (#233982)
- Use correct location for PAM module on 64-bit (#234545)
- Build developer documentation and put them in ConsoleKit-docs

* Mon Mar 19 2007 David Zeuthen <davidz@redhat.com> - 0.2.0-2
- BR gtk2-devel and make ConsoleKit Require gtk2 (could just be
  libX11 with a simple patch)

* Mon Mar 19 2007 David Zeuthen <davidz@redhat.com> - 0.2.0-1
- Update to upstream release 0.2.0
- Daemonize properly (#229206)

* Sat Mar  3 2007 David Zeuthen <davidz@redhat.com> - 0.1.3-0.git20070301.1
- Allow caller to pass uid=0 in libck-connector

* Thu Mar  1 2007 David Zeuthen <davidz@redhat.com> - 0.1.3-0.git20070301
- Update to git snapshot
- Drop all patches as they are committed upstream
- New tool ck-list-sessions
- New -libs subpackage with run-time libraries and a PAM module
- New -devel subpackage with headers

* Tue Feb  6 2007 David Zeuthen <davidz@redhat.com> - 0.1.0-5%{?dist}
- Start ConsoleKit a bit earlier so it starts before HAL (98 -> 90)
- Minimize stack usage so VIRT size is more reasonable (mclasen)
- Make session inactive when switching to non-session (davidz)

* Fri Jan 12 2007 Matthias Clasen <mclasen@redhat.com> - 0.1.0-4
- Don't mark initscripts %%config
- Use proper lock and pid ile names

* Fri Jan 12 2007 Matthias Clasen <mclasen@redhat.com> - 0.1.0-3
- More package review feedback

* Fri Jan 12 2007 Matthias Clasen <mclasen@redhat.com> - 0.1.0-2
- Incorporate package review feedback

* Thu Jan 11 2007 Matthias Clasen <mclasen@redhat.com> - 0.1.0-1
- Update to the first public release 0.1.0
- Some spec cleanups

* Mon Oct 23 2006 David Zeuthen <davidz@redhat.com> - 0.0.3-1
- Initial build.

