Name:             polkit
Version:          0.116
Release:          4
Summary:          Define and Handle authorizations tool
License:          LGPLv2+
URL:              http://www.freedesktop.org/wiki/Software/polkit
Source0:          http://www.freedesktop.org/software/polkit/releases/%{name}-%{version}.tar.gz
Source1:          http://www.freedesktop.org/software/polkit/releases/%{name}-%{version}.tar.gz.sign
Source2:          10-shutdown.rules

Patch9000:        modify-admin-authorization-from-wheel-group-to-root.patch

BuildRequires:    gcc-c++ glib2-devel >= 2.30.0 expat-devel pam-devel gtk-doc intltool
BuildRequires:    gobject-introspection-devel systemd systemd-devel pkgconfig(mozjs-60)
BuildRequires:    libxslt autoconf automake libtool
Requires:         dbus polkit-pkla-compat
Requires:         %{name}-libs%{?_isa} = %{version}-%{release}
Requires(pre):    shadow-utils
Requires(post):   /sbin/ldconfig, systemd
Requires(preun):  systemd
Requires(postun): /sbin/ldconfig, systemd

Obsoletes:        PolicyKit <= 0.10 polkit-desktop-policy < 0.103 polkit-js-engine < 0.110-4 polkit < 0.113-3
Provides:         PolicyKit = 0.11 polkit-desktop-policy = 0.103 polkit-js-engine = %{version}-%{release}
Conflicts:        polkit-gnome < 0.97

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

%package libs
Summary:          Libraries for polkit

%description libs
Libraries files for polkit.

%package          devel
Summary:          Development files for %{name}
Requires:         %{name}-libs%{?_isa} = %{version}-%{release}
Requires:         %{name}-help = %{version}-%{release}
Requires:         glib2-devel
Obsoletes:        PolicyKit-devel <= 0.10 PolicyKit-docs <= 0.10 polkit-docs
Provides:         PolicyKit-devel = 0.11 PolicyKit-docs = 0.11 polkit-docs

%description      devel
Development files for polkit.

%package_help

%prep
%autosetup -n %{name}-%{version} -p1

%build
autoreconf -i
export CFLAGS='-fPIC %optflags'
export LDFLAGS='-pie -Wl,-z,now -Wl,-z,relro'
%configure --enable-gtk-doc \
        --disable-static \
        --enable-introspection \
        --disable-examples \
        --enable-libsystemd-login=yes --with-mozjs=mozjs-17.0
%make_build

sed -i 's/=\"ientry-idm[0-9]\{5,32\}\"/=\"ientry-idm123456789123456\"/g' docs/polkit/html/polit-index.html

%install
%make_install

%delete_la

install -D -p -m 0644 %{SOURCE2} %{buildroot}%{_sysconfdir}/polkit-1/rules.d/10-shutdown.rules
%find_lang polkit-1

%pre
getent group polkitd >/dev/null || groupadd -r polkitd
getent passwd polkitd >/dev/null || useradd -r -g polkitd -d / -s /sbin/nologin -c "User for polkitd" polkitd
exit 0

%post
%systemd_post polkit.service

%preun
%systemd_preun polkit.service

%postun
%systemd_postun_with_restart polkit.service

%files -f polkit-1.lang
%doc COPYING NEWS README
%dir %{_sysconfdir}/polkit-1
%{_sysconfdir}/polkit-1/rules.d/50-default.rules
%{_sysconfdir}/polkit-1/rules.d/10-shutdown.rules
%attr(0700,polkitd,root) %dir %{_sysconfdir}/polkit-1/rules.d
%{_sysconfdir}/dbus-1/system.d/org.freedesktop.PolicyKit1.conf
%{_sysconfdir}/pam.d/polkit-1
%{_unitdir}/polkit.service
%{_datadir}/dbus-1/system-services/*
%dir %{_datadir}/polkit-1/
%dir %{_datadir}/polkit-1/actions
%attr(0700,polkitd,root) %dir %{_datadir}/polkit-1/rules.d
%{_datadir}/polkit-1/actions/org.freedesktop.policykit.policy
%{_bindir}/pkaction
%{_bindir}/pkcheck
%{_bindir}/pkttyagent
%dir %{_prefix}/lib/polkit-1
%{_prefix}/lib/polkit-1/polkitd
%attr(4755,root,root) %{_bindir}/pkexec
%attr(4755,root,root) %{_prefix}/lib/polkit-1/polkit-agent-helper-1

%post libs -p /sbin/ldconfig
%postun libs -p /sbin/ldconfig
%files libs
%{_libdir}/lib*.so.*
%{_libdir}/girepository-1.0/*.typelib

%files devel
%{_includedir}/*
%{_libdir}/pkgconfig/*.pc
%{_libdir}/lib*.so
%{_datadir}/gir-1.0/*.gir
%{_datadir}/gettext/its/polkit.its
%{_datadir}/gettext/its/polkit.loc
%{_datadir}/gtk-doc

%files help
%{_datadir}/man/man1/*
%{_datadir}/man/man8/*

%changelog
* Sun Sep 29 2019 openEuler Buildteam <buildteam@openeuler.org> - 0.116-4
- Add libs

* Sat Sep 28 2019 openEuler Buildteam <buildteam@openeuler.org> - 0.116-3
- Fix requires

* Tue Sep 24 2019 chengquan <chengquan3@huawei.com> - 0.116-2
- Type:bugfix
- ID:NA
- SUG:NA
- DESC:revise requires of polkit

* Wed Sep 18 2019 openEuler Buildteam <buildteam@openeuler.org> - 0.116-1
- Package init
