%define expat_version           1.95.5
%define glib2_version           2.6.0
%define dbus_version            0.90
%define dbus_glib_version	0.70
%define gtk_doc_version         1.4
#define libselinux_version      1.30
%define pam_version             0.99.6
%define intltool_version        0.36

# uid/gid allocated in this bug:
# https://bugzilla.redhat.com/bugzilla/show_bug.cgi?id=244950
%define polkit_uid              87

Summary: Authorization Toolkit
Summary(ja): 認証ツールキット
Name: PolicyKit
Version: 0.9
Release: 2%{?_dist_release}
License: MIT
Group: System Environment/Libraries
URL: http://gitweb.freedesktop.org/?p=PolicyKit.git;a=summary
Source0: http://hal.freedesktop.org/releases/%{name}-%{version}.tar.gz
BuildRoot: %{_tmppath}/%{name}-%{version}-%{release}-root
Requires(post): chkconfig
Requires(preun): chkconfig
Requires(post): /sbin/ldconfig
Requires(pre): /usr/sbin/useradd
Requires(postun): /sbin/ldconfig
BuildRequires: expat-devel >= %{expat_version}
BuildRequires: glib2-devel >= %{glib2_version}
BuildRequires: dbus-devel  >= %{dbus_version}
BuildRequires: dbus-glib-devel >= %{dbus_glib_version}
BuildRequires: gtk-doc >= %{gtk_doc_version}
#BuildRequires: libselinux-devel >= %{libselinux_version}
BuildRequires: libxslt
BuildRequires: pam-devel >= %{pam_version}
BuildRequires: intltool >= %{intltool_version}
Requires: dbus >= %{dbus_version}
Requires: dbus-glib >= %{dbus_glib_version}
Requires: glib2 >= %{glib2_version}
#Requires: libselinux >= %{libselinux_version}
Requires: pam >= %{pam_version}

# Since PolicyKit 0.7 reading authorizations is a privileged
# operation. So we need to force a new version of hal that makes sure
# that user 'haldaemon' can read authorizations of other users.
#Conflicts: hal < 0.5.10-3%{?_dist_release}

%description 
PolicyKit is a toolkit for defining and handling authorizations. It is
used for allowing unprivileged processes to speak to privileged
processes.

%package devel
Summary: Headers and libraries for PolicyKit
Group: Development/Libraries
Requires: %{name} = %{version}-%{release}
Requires: pkgconfig
Requires: glib2-devel
Requires: dbus-devel

%description devel
Headers and libraries for PolicyKit.

%package docs
Summary: Documentation for PolicyKit
Group: Development/Libraries
Requires: %{name} = %{version}-%{release}
# stupid guidelines require this for ownership of /usr/share/gtk-doc
Requires: gtk-doc

%description docs
Documentation for PolicyKit.

%prep
%setup -q

%build
%configure --disable-selinux --with-os-type=redhat
make

%install
rm -rf $RPM_BUILD_ROOT

make install DESTDIR=$RPM_BUILD_ROOT

mkdir -p $RPM_BUILD_ROOT%{_datadir}/doc/%{name}-%{version}
cp README AUTHORS NEWS COPYING HACKING doc/TODO $RPM_BUILD_ROOT%{_datadir}/doc/%{name}-%{version}

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

%clean
rm -rf $RPM_BUILD_ROOT

%pre
/usr/sbin/useradd -c 'PolicyKit' -u %{polkit_uid} \
	-s /sbin/nologin -r -d '/' polkituser 2> /dev/null || :

%post -p /sbin/ldconfig

%postun -p /sbin/ldconfig

%files
%defattr(-,root,root,-)

%doc %dir %{_datadir}/doc/%{name}-%{version}
%doc %{_datadir}/doc/%{name}-%{version}/NEWS
%doc %{_datadir}/doc/%{name}-%{version}/COPYING
%doc %{_datadir}/doc/%{name}-%{version}/AUTHORS
%doc %{_datadir}/doc/%{name}-%{version}/HACKING
%doc %{_datadir}/doc/%{name}-%{version}/README
%doc %{_datadir}/doc/%{name}-%{version}/TODO

%config(noreplace) %{_sysconfdir}/pam.d/polkit
%dir %{_sysconfdir}/PolicyKit
%config(noreplace) %{_sysconfdir}/PolicyKit/PolicyKit.conf

%{_bindir}/*

%{_libdir}/lib*.so.*

%{_mandir}/man1/*
%{_mandir}/man5/*
%{_mandir}/man8/*

# see upstream design specification for why these permissions are necessary
%attr(4755,polkituser,root) %{_libexecdir}/polkit-set-default-helper
%attr(2755,root,polkituser) %{_libexecdir}/polkit-read-auth-helper
%attr(2755,root,polkituser) %{_libexecdir}/polkit-revoke-helper
%attr(2755,root,polkituser) %{_libexecdir}/polkit-explicit-grant-helper
%attr(2755,root,polkituser) %{_libexecdir}/polkit-grant-helper
%attr(4754,root,polkituser) %{_libexecdir}/polkit-grant-helper-pam
%attr(4755,root,polkituser) %{_libexecdir}/polkit-resolve-exe-helper
%attr(0770,polkituser,polkituser) %dir %{_localstatedir}/run/PolicyKit
%attr(0770,polkituser,polkituser) %dir %{_localstatedir}/lib/PolicyKit
%attr(0755,polkituser,polkituser) %dir %{_localstatedir}/lib/PolicyKit-public
%attr(0775,polkituser,polkituser) %{_localstatedir}/lib/misc/PolicyKit.reload

%dir %{_datadir}/PolicyKit
%dir %{_datadir}/PolicyKit/policy
%{_datadir}/PolicyKit/policy/org.freedesktop.policykit.policy
%{_datadir}/PolicyKit/config.dtd

%{_datadir}/dbus-1/system-services/org.freedesktop.PolicyKit.service
%{_sysconfdir}/dbus-1/system.d/org.freedesktop.PolicyKit.conf
%{_libexecdir}/polkitd

%{_sysconfdir}/profile.d/polkit-bash-completion.sh

%files devel
%defattr(-,root,root,-)

%{_libdir}/lib*.so
%{_libdir}/pkgconfig/*
%{_includedir}/*

# own this directory for now until this is settled on the D-Bus list
%dir %{_datadir}/dbus-1/interfaces
%{_datadir}/dbus-1/interfaces/org.freedesktop.PolicyKit.AuthenticationAgent.xml


%files docs
%defattr(-,root,root,-)

%dir %{_datadir}/gtk-doc/html/polkit
%{_datadir}/gtk-doc/html/polkit/*

%changelog
* Sun Oct 03 2010 Shu KONNO <owa@bg.wakwak.com> 0.9-2
- rebuilt with rpm-4.8.1 for pkg-config

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

* Tue Jun 24 2008 MATSUBAYASHI Kohji <shaolin@vinelinux.org> - 0.8-3
- initial build for Vine Linux
- disable selinux support

* Wed Apr 16 2008 David Zeuthen <davidz@redhat.com> - 0.8-2%{?dist}
- Fix permissions and modes

* Wed Apr 16 2008 David Zeuthen <davidz@redhat.com> - 0.8-1%{?dist}
- Upstream 0.8 release

* Sun Apr  6 2008 David Zeuthen <davidz@redhat.com> - 0.8-0.git20080404%{?dist}.3
- Fix wrong permissions on the resolve exe helper

* Fri Apr  4 2008 David Zeuthen <davidz@redhat.com> - 0.8-0.git20080404%{?dist}.2
- Fix build

* Fri Apr  4 2008 David Zeuthen <davidz@redhat.com> - 0.8-0.git20080404%{?dist}
- Update to git snapshot; drop patches as they are upstream already

* Fri Apr  4 2008 David Zeuthen <davidz@redhat.com> - 0.7-7%{?dist}
- Include fix for CVE-2008-1658 (#439996)

* Mon Feb 18 2008 Fedora Release Engineering <rel-eng@fedoraproject.org> - 0.7-6
- Autorebuild for GCC 4.3

* Thu Jan 24 2008 Jon McCann <jmccann@redhat.com> - 0.7-5%{?dist}
- Remove Requires: ConsoleKit since ConsoleKit now requires PolicyKit

* Thu Dec  6 2007 David Zeuthen <davidz@redhat.com> - 0.7-4%{?dist}
- Only run bash completion script if using bash (#418471)

* Thu Dec  6 2007 David Zeuthen <davidz@redhat.com> - 0.7-3%{?dist}
- Conflict with older hal release

* Thu Dec  6 2007 David Zeuthen <davidz@redhat.com> - 0.7-2%{?dist}
- BR intltool and adjust License to MIT

* Thu Dec  6 2007 David Zeuthen <davidz@redhat.com> - 0.7-1%{?dist}
- Update to latest upstream release

* Thu Oct 11 2007 David Zeuthen <davidz@redhat.com> - 0.6-1%{?dist}
- Update to latest upstream release

* Tue Sep 25 2007 David Zeuthen <davidz@redhat.com> - 0.6-0.git20070925%{?dist}
- Update to git snapshot

* Fri Aug 31 2007 David Zeuthen <davidz@redhat.com> - 0.5-3%{?dist}
- Rebuild

* Fri Aug 31 2007 David Zeuthen <davidz@redhat.com> - 0.5-2%{?dist}
- Upstream release 0.5

* Fri Aug 10 2007 Matthias Clasen <mclasen@redhat.com> - 0.5-1.git20070731%{?dist}
- Add missing Requires (#251268)
- Own /etc/PolicyKit (#251274)

* Tue Jul 31 2007 David Zeuthen <davidz@redhat.com> - 0.5-0.git20070731%{?dist}
- Update to git snapshot

* Fri Jul 27 2007 David Zeuthen <davidz@redhat.com> - 0.4-2%{?dist}
- Incorporate comments from package review (#245015)

* Wed Jul 25 2007 David Zeuthen <davidz@redhat.com> - 0.4-1%{?dist}
- Update to version 0.4.

* Tue Jun 19 2007 David Zeuthen <davidz@redhat.com> - 0.3-1%{?dist}
- Initial build.

