%global __os_install_post %(echo '%{__os_install_post}' | sed -e 's!/usr/lib[^[:space:]]*/brp-python-bytecompile[[:space:]].*$!!g')

Name:           system-config-printer
Summary:        a graphical tool for CUPS administration
Version:        1.5.11
Release:        18
License:        GPLv2+
URL:            https://github.com/zdohnal/system-config-printer
Source0:        https://github.com/zdohnal/system-config-printer/archive/%{version}.tar.gz
BuildRequires:  libusb1-devel gcc gettext-devel systemd xmlto systemd-devel
BuildRequires:  intltool cups-devel >= 1.2 desktop-file-utils >= 0.2.92 pkgconfig(glib-2.0)
Requires:       desktop-file-utils >= 0.2.92 python3-dbus%{?_isa} gtk3%{?_isa} python3-gobject%{?_isa}
Requires:       libnotify%{?_isa} python3-cairo%{?_isa} python3-cups >= 1.9.60 libcanberra-gtk3
Requires:       python3-firewall PackageKit-gtk3-module desktop-notification-daemon dbus-x11
Requires:       python3-pycurl gobject-introspection python3-gobject  python3-dbus python3-requests
Requires(post): systemd
Requires(preun): systemd
Requires(postun): systemd
Obsoletes:      %{name}-libs = %{version}-%{release} %{name}-applet = %{version}-%{release}
Obsoletes:      %{name}-udev = %{version}-%{release} hal-cups-utils < 0.6.20
Provides:       %{name}-libs = %{version}-%{release} %{name}-applet = %{version}-%{release}
Provides:       %{name}-udev = %{version}-%{release} hal-cups-utils = 0.6.20

Patch1:         Fix-constructing-the-auth-dialog.patch

%description
%{name} is a graphical tool for CUPS administration. It
uses IPP to configure a CUPS server.

%package_help

%prep
%autosetup -p1

%build
./bootstrap
%configure --with-udev-rules
%make_build

%install
%make_install DESTDIR=%buildroot

install -d %buildroot%{_localstatedir}/run/udev-configure-printer
touch %buildroot%{_localstatedir}/run/udev-configure-printer/usb-uris

%py_byte_compile %{__python3} %{buildroot}%{python3_sitelib}/cupshelpers
%py_byte_compile %{__python3} %{buildroot}%{_datadir}/%{name}

%find_lang %{name}

%files -f  %{name}.lang
%license COPYING
%{_bindir}/%{name}
%{_bindir}/install-printerdriver
%dir %{_datadir}/%{name}
%{_datadir}/%{name}/*
%{_datadir}/applications/%{name}.desktop
%{_datadir}/metainfo/%{name}.appdata.xml
%{_bindir}/%{name}-applet
%{_sysconfdir}/xdg/autostart/print-applet.desktop
%{_prefix}/lib/udev/rules.d/*.rules
%{_prefix}/lib/udev/udev-*-printer
%ghost %dir %{_localstatedir}/run/udev-configure-printer
%ghost %verify(not md5 size mtime) %config(noreplace,missingok) %attr(0644,root,root) %{_localstatedir}/run/udev-configure-printer/usb-uris
%{_unitdir}/configure-printer@.service
%config(noreplace) %{_sysconfdir}/dbus-1/system.d/com.redhat.NewPrinterNotification.conf
%config(noreplace) %{_sysconfdir}/dbus-1/system.d/com.redhat.PrinterDriversInstaller.conf
%{_datadir}/dbus-1/interfaces/*.xml
%{_datadir}/dbus-1/services/*.service
%{_bindir}/scp-dbus-service
%dir %{_sysconfdir}/cupshelpers
%config(noreplace) %{_sysconfdir}/cupshelpers/preferreddrivers.xml
%{python3_sitelib}/cupshelpers
%{python3_sitelib}/*.egg-info

%files help
%doc po/ChangeLog NEWS ABOUT-NLS AUTHORS ChangeLog-OLD
%{_mandir}/man1/%{name}-applet.1*
%{_mandir}/man1/%{name}.1*

%post
rm -rf /var/cache/foomatic/foomatic.pickle
exit 0

%changelog
* Sat Jan 07 2022 xuxinyu <xuxinyu@xfusion.com>  - 1.5.11-18
- Fix constructing the auth dialog

* Thu Jul 21 2022 yaoxin <yaoxin30@h-partners.com> - 1.5.11-17
- Remove unneeded dependdencies python3-devel

* Thu Mar 31 2022 baizhonggui <baizhonggui@huawei.com> - 1.5.11-16
- Modify byte_compile syntax to fix build error

* Tue Sep 08 2020 zhangjiapeng <zhangjiapeng9@huawei.com> - 1.5.11-15
- Resolve installation failure

* Fri Feb 14 2020 Ling Yang <lingyang2@huawei.com> - 1.5.11-14
- Package init
