%global forgeurl https://github.com/OpenPrinting/ps-printer-app

%global commit 5dbdece4aa51d9eba85c05151b5dd4de2161d777

%forgemeta

Name:           ps-printer-app
Version:        0
Release:        1%{?dist}
License:        Apache-2.0
Summary:        Printer Application for PostScript printers that uses PAPPL to support IPP printing from multiple operating systems.
URL:	        %{forgeurl}
Source0:        %{forgesource}
Source1:        ps-printer-app.sysusers
#Services which run as root cannot create listener sockets
Patch0:         ps-printer-app_service-user.patch
BuildRequires:	make
BuildRequires:	gcc
BuildRequires:  systemd-rpm-macros
BuildRequires:  cups-devel
BuildRequires:  pkgconfig(libcupsfilters) >= 2.0b1
BuildRequires:  pkgconfig(libpappl-retrofit) >= 1.0b1
BuildRequires:  pkgconfig(libppd) >= 2.0b2
BuildRequires:  pkgconfig(pappl) >= 1.2.1
BuildRequires:  perl

%description
ps-printer-app is a printer Application for PostScript printers that uses PAPPL
to support IPP printing from multiple operating systems. In addition, it uses
the resources of cups-filters 2.x (filter functions in libcupsfilters, libppd)
and pappl-retrofit (encapsulating classic CUPS drivers in Printer Applications).
This work (or now the code of pappl-retrofit) is derived from the hp-printer-app.

%prep
%forgesetup
%autopatch -p1

%build
%make_build

%install
%make_install libdir=%{buildroot}%{_libdir} serverbin=%{buildroot}%{_libdir}/ps-printer-app

install -p -D -m 0644 %{SOURCE1} %{buildroot}%{_sysusersdir}/ps-printer-app.conf

%pre
%sysusers_create_compat %{SOURCE1}

%post
%systemd_post ps-printer-app.service

%preun
%systemd_preun ps-printer-app.service

%postun
%systemd_postun_with_restart ps-printer-app.service

%files
%license
%{_bindir}/ps-printer-app
%{_libdir}/ps-printer-app
%{_unitdir}/ps-printer-app.service
%{_mandir}/man1/ps-printer-app.1.gz
%{_datadir}/ppd/generic-ps-printer.ppd
%dir %{_datadir}/ps-printer-app
%{_datadir}/ps-printer-app/testpage.ps
%attr(-, ps-printer-app, ps-printer-app) %dir %{_sharedstatedir}/ps-printer-app
%{_sysusersdir}/ps-printer-app.conf

%changelog
* Mon Sep 18 2023 Brandon Nielsen <nielsenb@jetfuse.net> 0-1.20230918git5dbdece
- Update to 5dbdece git snapshot
- Change to SPDX license identifier

* Thu Feb 2 2023 Brandon Nielsen <nielsenb@jetfuse.net> 0-1.20230202git4a54b0f
- Update to 4a54b0f git snapshot
- Remove unit install workaround since it seems to work on rawhide

* Thu Aug 25 2022 Brandon Nielsen <nielsenb@jetfuse.net> 0-1.20220825git73bafe8
- Update to 73bafe8 git snapshot

* Sun Feb 27 2022 Brandon Nielsen <nielsenb@jetfuse.net> 0-1.20220227git81d6d64
- Update to 81d6d64 git snapshot

* Tue Nov 16 2021 Brandon Nielsen <nielsenb@jetfuse.net> 0-1.20211116gitf2480e8
- Update to latest git snapshot

* Sun Sep 26 2021 Brandon Nielsen <nielsenb@jetfuse.net> 0-4.20210916git65b53e2
- Run service as user ps-printer-app

* Thu Sep 23 2021 Brandon Nielsen <nielsenb@jetfuse.net> 0-3.20210916git65b53e2
- Correct some path definitions

* Thu Sep 23 2021 Brandon Nielsen <nielsenb@jetfuse.net> 0-2.20210916git65b53e2
- Add shared state folder

* Wed Sep 15 2021 Brandon Nielsen <nielsenb@jetfuse.net> 0-1.20210916git65b53e2
- Initial specfile