%bcond_with systemd

%define _unpackaged_files_terminate_build 1
%global __global_cflags %{optflags}
%global __global_ldflags ""

Summary:        D-Bus interfaces for querying and manipulating user account information
Summary(ja):    ユーザーアカウント情報の照会・処理を行うための D-Bus I/F
Name:           accountsservice
Version:        0.6.55
Release:        1%{?_dist_release}%{?with_systemd:.systemd}
Vendor:         Project Vine
Distribution:   Vine Linux

Group:          System Environment/Daemons
License:        GPLv3+
URL:            https://www.freedesktop.org/wiki/Software/AccountsService/
#VCS: git:git://git.freedesktop.org/accountsservice
Source0:        https://www.freedesktop.org/software/accountsservice/accountsservice-%{version}.tar.xz

# upstream patch

# for Vine Linux

BuildRoot:      %{_tmppath}/%{name}-%{version}-%{release}-root
BuildRequires:  meson
BuildRequires:  glib2-devel
BuildRequires:  dbus-glib-devel
BuildRequires:  polkit-devel
BuildRequires:  intltool
# BuildRequires:  systemd-units
BuildRequires:  gobject-introspection-devel
BuildRequires:  python3-setuptools
%if %{with systemd}
BuildRequires:  systemd-devel
%{?systemd_requires}
%else
BuildRequires:  elogind-devel
%endif

Requires:       polkit
Requires:       shadow-utils


%description
The accountsservice project provides a set of D-Bus interfaces for
querying and manipulating user account information and an implementation
of these interfaces, based on the useradd, usermod and userdel commands.


%package libs
Summary: Client-side library to talk to accountsservice
Summary(ja): accountsservice と対話するためのクライアント側ライブラリ
Group: System Environment/Libraries
Requires: %{name} = %{version}-%{release}

%description libs
The accountsservice-libs package contains a library that can
be used by applications that want to interact with the accountsservice
daemon.


%package devel
Summary: Development files for accountsservice-libs
Summary(ja): accountsservice-libs の開発用ファイル
Group: Development/Libraries
Requires: %{name}-libs = %{version}-%{release}

%description devel
The accountsservice-devel package contains headers and other
files needed to build applications that use accountsservice-libs.


%package        doc
Summary:        Documentation for %{name}
Summary(ja):    %{name} 用のドキュメント
Group:          Documentation
Requires:       %{name} = %{version}-%{release}
BuildArch:      noarch

%description    doc
This package contains documentation for %{name}.


%prep
%autosetup -p1
sed -i -e '/"gnome-initial-setup",/a "selfbuild",' src/user-classify.c


%build
%meson \
%if %{with systemd}
  -Dsystemd=true \
  -Delogind=false \
  -Dsystemdsystemunitdir=%{_unitdir} \
%else
  -Dsystemd=false \
  -Delogind=true \
  -Dsystemdsystemunitdir=no \
%endif
  -Dadmin_group=wheel \
  -Dminimum_uid=500 \
  -Dgtk_doc=true

%meson_build


%install
rm -rf $RPM_BUILD_ROOT
%meson_install

%find_lang accounts-service


%clean
rm -rf $RPM_BUILD_ROOT


%if %{with systemd}
%post
%systemd_post accounts-daemon.service

%preun
%systemd_preun accounts-daemon.service

%postun
%systemd_postun accounts-daemon.service
%endif

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


%files -f accounts-service.lang
%defattr(-,root,root,-)
%license COPYING
%doc README* AUTHORS
%{_sysconfdir}/dbus-1/system.d/org.freedesktop.Accounts.conf
%{_libexecdir}/accounts-daemon
%{_datadir}/dbus-1/interfaces/org.freedesktop.Accounts.xml
%{_datadir}/dbus-1/interfaces/org.freedesktop.Accounts.User.xml
%{_datadir}/dbus-1/system-services/org.freedesktop.Accounts.service
%{_datadir}/polkit-1/actions/org.freedesktop.accounts.policy
%dir %{_localstatedir}/lib/AccountsService/
%dir %{_localstatedir}/lib/AccountsService/users
%dir %{_localstatedir}/lib/AccountsService/icons
%if %{with systemd}
%{_unitdir}/accounts-daemon.service
%endif

%files libs
%defattr(-,root,root,-)
%{_libdir}/libaccountsservice.so.*
%{_libdir}/girepository-1.0/AccountsService-1.0.typelib

%files devel
%defattr(-,root,root,-)
%{_includedir}/accountsservice-1.0
%{_libdir}/libaccountsservice.so
%{_libdir}/pkgconfig/accountsservice.pc
%{_datadir}/gir-1.0/AccountsService-1.0.gir

%files doc
%defattr(-,root,root,-)
%{_datadir}/gtk-doc/html/libaccountsservice/

%changelog
* Mon Aug 03 2020 Tomohiro "Tomo-p" KATO <tomop@teamgedoh.net> 0.6.55-1
- new upstream release.
- added systemd support (disabled as default).
- dropped Patch1 and 2: fixed in upstream.
- dropped Patch1000: got a same effect by sed.

* Fri Dec 28 2018 Tomohiro "Tomo-p" KATO <tomop@teamgedoh.net> 0.6.54-1
- new upstream release.
- added elogind support.
- updated Patch1000.

* Mon Apr 13 2015 Yoji TOYODA <bsyamato@sea.plala.or.jp> 0.6.40-1
- new upstream release

* Mon Nov 03 2014 Yoji TOYODA <bsyamato@sea.plala.or.jp> 0.6.39-1
- new upstream release

* Sat Nov  1 2014 Ryoichi INAGAKI <ryo1@toki.waseda.jp> 0.6.37-2
- moved libs package to System Environment/Libraries
- added %%post, %%postun and %%clean section
- added Japanese summary

* Sun Apr 13 2014 Yoji TOYODA <bsyamato@sea.plala.or.jp> 0.6.37-1
- new upstream release
- add Patch1000 (accountsservice-0.6.37-vine-environment.patch)

* Sat Jan 04 2014 Yoji TOYODA <bsyamato@sea.plala.or.jp> 0.6.31-2
- rebuild with VineSeed environment

* Wed Apr 24 2013 Yoji TOYODA <bsyamato@sea.plala.or.jp> 0.6.31-1
- new upstream release

* Sun Jan 13 2013 Yoji TOYODA <bsyamato@sea.plala.or.jp> 0.6.30-1
- new upstream release
- create subpackage (%{name}-doc)

* Sun Sep 30 2012 Yoji TOYODA <bsyamato@sea.plala.or.jp> 0.6.25-1
- new upstream release

* Sun Apr 22 2012 Yoji TOYODA <bsyamato@sea.plala.or.jp> 0.6.18-1
- new upstream release

* Fri Sep 23 2011 Yoji TOYODA <bsyamato@sea.plala.or.jp> 0.6.14-1
- new upstream release

* Wed Aug 17 2011 Yoji TOYODA <bsyamato@sea.plala.or.jp> 0.6.13-1
- initial build for Vine Linux


* Mon Jun 06 2011 Ray Strode <rstrode@redhat.com> 0.6.12-1
- Update to latest release

* Wed May 18 2011 Matthias Clasen <mclasen@redhat.com> 0.6.11-1
- Update to 0.6.11

* Mon Feb 07 2011 Fedora Release Engineering <rel-eng@lists.fedoraproject.org> - 0.6.3-2
- Rebuilt for https://fedoraproject.org/wiki/Fedora_15_Mass_Rebuild

* Wed Feb 02 2011 Ray Strode <rstrode@redhat.com> 0.6.3-1
- Update to 0.6.3

* Thu Jan 27 2011 Matthias Clasen <mclasen@redhat.com> 0.6.2-1
- Update to 0.6.2

* Wed Jul 21 2010 Matthias Clasen <mclasen@redhat.com> 0.6.1-1
- Update to 0.6.1
- Install systemd unit file

* Mon Apr  5 2010 Matthias Clasen <mclasen@redhat.com> 0.6-2
- Always emit changed signal on icon change

* Tue Mar 30 2010 Matthias Clasen <mclasen@redhat.com> 0.6-1
- Update to 0.6

* Mon Mar 22 2010 Matthias Clasen <mclasen@redhat.com> 0.5-1
- Update to 0.5

* Mon Feb 22 2010 Bastien Nocera <bnocera@redhat.com> 0.4-3
- Fix directory ownership

* Mon Feb 22 2010 Bastien Nocera <bnocera@redhat.com> 0.4-2
- Add missing directories to the filelist

* Fri Jan 29 2010 Matthias Clasen <mclasen@redhat.com> 0.4-1
- Initial packaging, based on work by Richard Hughes
