%bcond_with systemd
%bcond_with firstbuild
%define build_compat32 %{?_with_compat32:1}%{!?_with_compat32:0}

Summary:	Color daemon
Name:		colord
Version:	1.4.6
Release:	1%{?_dist_release}%{?with_systemd:.systemd}
Group:		system
Vendor:		Project Vine
Distribution:	Vine Linux

License:	GPLv2+ and LGPLv2+
URL:		https://github.com/hughsie/colord
Source0:	https://github.com/hughsie/colord/archive/refs/tags/%{version}.tar.gz#/%{name}-%{version}.tar.gz
Patch0:		colord-1.4.3-elogind.patch

BuildRoot:     %{_tmppath}/%{name}-%{version}-root
BuildRequires: bash-completion
BuildRequires: dbus-devel
BuildRequires: docbook-utils
BuildRequires: docbook5-style-xsl
BuildRequires: gettext
BuildRequires: glib2-devel
BuildRequires: lcms2-devel
BuildRequires: libgudev1-devel
BuildRequires: libgusb-devel
BuildRequires: libxslt
BuildRequires: meson
BuildRequires: polkit-devel
BuildRequires: sqlite3-devel
BuildRequires: vala
%{!?with_firstbuild:BuildRequires: colord-devel, gobject-introspection-devel}
%if %{with systemd}
BuildRequires: systemd-devel
%{?systemd_requires}
%else
BuildRequires: eudev-libudev-devel
BuildRequires: elogind-devel
%endif
Requires: shared-color-profiles

%description
colord is a low level system activated daemon that maps color devices
to color profiles in the system context.


%package devel
Summary: Development package for %{name}
Group:   programming
Requires: %{name} = %{version}-%{release}
Requires: glib2-devel
Requires: dbus-devel
Requires: lcms2-devel

%description devel
Files for development with %{name}.


# compat32
%package -n compat32-%{name}
Summary:  Color daemon
Group:    system,legacy
Requires: %{name} = %{version}-%{release}

%description -n compat32-%{name}
colord is a low level system activated daemon that maps color devices
to color profiles in the system context.


%package -n compat32-%{name}-devel
Summary: Development package for %{name}
Group:   programming,legacy
Requires: compat32-%{name} = %{version}-%{release}

%description -n compat32-%{name}-devel
Files for development with %{name}.


%debug_package


%prep
%setup
%if !%{with systemd}
%patch0 -p1
%endif


%build
%meson \
  -Ddaemon_user=colord \
%if %{with systemd}
  -Dsystemd=true \
%else
  -Dsystemd=false \
  -Delogind=true \
%endif
  -Dargyllcms_sensor=false \
  -Dvapi=true \
  -Ddocs=false

%meson_build


%install
rm -rf %{buildroot}
%meson_install

# databases
touch $RPM_BUILD_ROOT%{_localstatedir}/lib/colord/mapping.db
touch $RPM_BUILD_ROOT%{_localstatedir}/lib/colord/storage.db

%find_lang %{name}


%triggerin -- colord < 1.4.4
if [ -d %{_localstatedir}/lib/colord ]; then
  chown -R colord:colord %{_localstatedir}/lib/colord
fi

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

%post
%if %{with systemd}
%systemd_post colord.service
%endif

%if %{with systemd}
%preun
%systemd_preun colord.service
%endif

%postun
%if %{with systemd}
%systemd_postun colord.service
%endif


%files -f %{name}.lang
%defattr(-,root,root,-)
%license COPYING
%doc AUTHORS NEWS README.md 
%{_libexecdir}/colord
%{_libexecdir}/colord-session
%attr(755,colord,colord) %dir %{_localstatedir}/lib/colord
%attr(755,colord,colord) %dir %{_localstatedir}/lib/colord/icc
%{_bindir}/*
%{_datadir}/dbus-1/system.d/org.freedesktop.ColorManager.conf
%dir %{_datadir}/bash-completion
%dir %{_datadir}/bash-completion/completions
%{_datadir}/bash-completion/completions/colormgr
%{_datadir}/color
%{_datadir}/colord
%{_datadir}/dbus-1/interfaces/org.freedesktop.ColorHelper.xml
%{_datadir}/dbus-1/interfaces/org.freedesktop.ColorManager*.xml
%{_datadir}/dbus-1/services/org.freedesktop.ColorHelper.service
%{_datadir}/dbus-1/system-services/org.freedesktop.ColorManager.service
%{_datadir}/glib-2.0/schemas/org.freedesktop.ColorHelper.gschema.xml
%{_datadir}/polkit-1/actions/org.freedesktop.color.policy
%{_datadir}/man/man1/*.1.gz
%{_libdir}/libcolord.so.*
%{_libdir}/libcolordprivate.so.*
%{_libdir}/libcolorhug.so.*
%{_libdir}/colord-plugins/libcolord_sensor_camera.so
%{_libdir}/colord-plugins/libcolord_sensor_scanner.so
%{!?with_firstbuild:%{_libdir}/girepository-1.0/Colord-1.0.typelib}
%{!?with_firstbuild:%{_libdir}/girepository-1.0/Colorhug-1.0.typelib}
/lib/udev/rules.d/*.rules
%{_libdir}/colord-sensors
%ghost %{_localstatedir}/lib/colord/*.db
%if %{with systemd}
%{_unitdir}/*.service
%{_userunitdir}/*.service
%{_tmpfilesdir}/colord.conf
%endif

%files devel
%defattr(-,root,root,-)
%{_includedir}/colord-1
%{_libdir}/libcolord.so
%{_libdir}/libcolordprivate.so
%{_libdir}/libcolorhug.so
%{_libdir}/pkgconfig/colord.pc
%{_libdir}/pkgconfig/colorhug.pc
%{!?with_firstbuild:%{_datadir}/gir-1.0/Colord-1.0.gir}
%{!?with_firstbuild:%{_datadir}/gir-1.0/Colorhug-1.0.gir}
%dir %{_datadir}/vala
%dir %{_datadir}/vala/vapi
%{_datadir}/vala/vapi/*

# compat32
%if %{build_compat32}
%files -n compat32-%{name}
%defattr(-,root,root,-)
%{_libdir}/libcolord.so.*
%{_libdir}/libcolordprivate.so.*
%{_libdir}/libcolorhug.so.*

%files -n compat32-%{name}-devel
%defattr(-,root,root,-)
%{_libdir}/libcolord.so
%{_libdir}/libcolordprivate.so
%{_libdir}/libcolorhug.so
%endif


%changelog
* Thu Sep 01 2022 Tomohiro "Tomo-p" KATO <tomop@teamgedoh.net> 1.4.6-1
- new upstream release.

* Tue Mar 30 2021 Tomohiro "Tomo-p" KATO <tomop@teamgedoh.net> 1.4.5-1
- new upstream release.

* Mon Aug 03 2020 Tomohiro "Tomo-p" KATO <tomop@teamgedoh.net> 1.4.4-1
- new upstream release.
- added systemd support (disabled as default).
- changed daemon-user to "colord".

* Sat Dec 29 2018 Tomohiro "Tomo-p" KATO <tomop@teamgedoh.net> 1.4.3-1
- new upstream release.

* Fri Dec 12 2014 Ryoichi INAGAKI <ryo1@toki.waseda.jp> 1.1.8-2
- added libcolordprivate and libcolorhug to compat32-* subpackages

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

* Sun Oct 26 2014 Yoji TOYODA <bsyamato@sea.plala.or.jp> 1.1.7-1
- update to 1.1.7

* Sat Jun 28 2014 Yoji TOYODA <bsyamato@sea.plala.or.jp> 1.0.7-1
- new upstream release

* Fri Mar 28 2014 Yoji TOYODA <bsyamato@sea.plala.or.jp> 1.0.6-1
- new upstream release

* Thu Dec 26 2013 Yoji TOYODA <bsyamato@sea.plala.or.jp> 1.0.5-1
- new upstream release

* Fri Sep 06 2013 Yoji TOYODA <bsyamato@sea.plala.or.jp> 1.0.3-1
- new upstream release

* Sat May 18 2013 Yoji TOYODA <bsyamato@sea.plala.or.jp> 1.0.0-1
- new upstream release
- add BuildRequires: bash-completion

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

* Wed Jan 02 2013 Yoji TOYODA <bsyamato@sea.plala.or.jp> 0.1.26-1
- new upstream release

* Sun Nov 11 2012 Yoji TOYODA <bsyamato@sea.plala.or.jp> 0.1.24-1
- new upstream release
- remove BuildRequires: sane-devel

* Wed Sep 26 2012 Yoji TOYODA <bsyamato@sea.plala.or.jp> 0.1.23-1
- new upstream release
- change BuildRequires: libgusb-devel instead of libusb1-devel
- add BuildRequires: gobject-introspection-devel

* Tue Jun 26 2012 Yoji TOYODA <bsyamato@sea.plala.or.jp> 0.1.21-1
- new upstream release

* Mon Apr 30 2012 Yoji TOYODA <bsyamato@sea.plala.or.jp> 0.1.19-1
- new upstream release

* Sat Mar 31 2012 Yoji TOYODA <bsyamato@sea.plala.or.jp> 0.1.18-1
- new upstream release

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

* Wed Nov 16 2011 Yoji TOYODA <bsyamato@sea.plala.or.jp> 0.1.14-1
- new upstream release

* Sat Oct 08 2011 Yoji TOYODA <bsyamato@sea.plala.or.jp> 0.1.13-1
- new upstream release

* Sat Sep 03 2011 Yoji TOYODA <bsyamato@sea.plala.or.jp> 0.1.12-1
- new upstream release

* Sun Aug 21 2011 Yoji TOYODA <bsyamato@sea.plala.or.jp> 0.1.11-1
- new upstream release
- create compat32 sub packages

* Sun Aug 14 2011 Yoji TOYODA <bsyamato@sea.plala.or.jp> 0.1.10-1
- initial build for Vine Linux


* Wed Jul 06 2011 Richard Hughes <richard@hughsie.com> 0.1.10-1
- New upstream version

* Mon Jun 13 2011 Richard Hughes <richard@hughsie.com> 0.1.9-1
- New upstream version

* Thu Jun 02 2011 Richard Hughes <richard@hughsie.com> 0.1.8-1
- New upstream version
- Add a webcam device kind
- Add a timestamp when making profiles default
- Add support for reading and writing ICC profile metadata
- Allow the client to pass file descriptors out of band to CreateProfile
- Prettify the device vendor and model names
- Split out the sensors into runtime-loadable shared objects
- Provide some GIO async variants for the methods in CdClient
- Ensure GPhoto2 devices get added to the device list

* Fri May 06 2011 Richard Hughes <richard@hughsie.com> 0.1.7-1
- New upstream version.
- Create /var/lib/colord at buildtime not runtime for SELinux
- Ensure profiles with embedded profile checksums are parsed correctly
- Move the colorimeter rules to be run before 70-acl.rules
- Stop watching the client when the sensor is finalized
- Ensure the source is destroyed when we unref CdUsb to prevent a crash
- Only enable the volume mount tracking when searching volumes

* Tue Apr 26 2011 Richard Hughes <rhughes@redhat.com> 0.1.6-2
- Own /var/lib/colord and /var/lib/colord/*.db

* Sun Apr 24 2011 Richard Hughes <richard@hughsie.com> 0.1.6-1
- New upstream version.

* Thu Mar 31 2011 Richard Hughes <richard@hughsie.com> 0.1.5-1
- New upstream version.

* Wed Mar 09 2011 Richard Hughes <richard@hughsie.com> 0.1.4-1
- New upstream version.

* Mon Feb 28 2011 Richard Hughes <richard@hughsie.com> 0.1.3-1
- New upstream version.

* Tue Feb 08 2011 Fedora Release Engineering <rel-eng@lists.fedoraproject.org> - 0.1.1-3
- Rebuilt for https://fedoraproject.org/wiki/Fedora_15_Mass_Rebuild

* Fri Jan 28 2011 Richard Hughes <richard@hughsie.com> 0.1.1-2
- Rebuild in the vain hope koji isn't broken today.

* Wed Jan 26 2011 Richard Hughes <richard@hughsie.com> 0.1.1-1
- New upstream version.

* Thu Jan 13 2011 Richard Hughes <richard@hughsie.com> 0.1.0-1
- Initial version for Fedora package review.
