File AirSane.spec of Package AirSane

#
# spec file for package AirSane
#
# Copyright (c) 2022 SUSE LLC
#
# All modifications and additions to the file contributed by third parties
# remain the property of their copyright owners, unless otherwise agreed
# upon. The license for this file, and modifications and additions to the
# file, is the same license as for the pristine package itself (unless the
# license for the pristine package is not an Open Source License, in which
# case the license is the MIT License). An "Open Source License" is a
# license that conforms to the Open Source Definition (Version 1.9)
# published by the Open Source Initiative.

# Please submit bugfixes or comments via https://bugs.opensuse.org/
#


%define __builder ninja
Name:           AirSane
Version:        0.4.9
Release:        0
Summary:        Publish SANE scanners to MacOS and Android via Apple AirScan
License:        GPL-3.0-or-later
URL:            https://github.com/SimulPiscator/AirSane
Source0:        %{url}/archive/refs/tags/v%{version}.tar.gz#/%{name}-%{version}.tar.gz
Source1:        airsaned.xml
Patch0:         systemd.patch
BuildRequires:  cmake
BuildRequires:  gcc-c++
BuildRequires:  ninja
BuildRequires:  pkgconfig
BuildRequires:  pkgconfig(systemd)
BuildRequires:  pkgconfig(avahi-core)
BuildRequires:  pkgconfig(gnutls)
BuildRequires:  pkgconfig(libjpeg)
BuildRequires:  pkgconfig(libpng)
BuildRequires:  pkgconfig(libusb-1.0)
BuildRequires:  pkgconfig(libxml-2.0)
BuildRequires:  pkgconfig(sane-backends)
BuildRequires:  firewall-macros
Requires:       sane-airscan
%{?systemd_requires}

%description
A SANE WebScan frontend that supports Apple's AirScan protocol. Scanners are detected automatically, and published through mDNS. Acquired images may be transferred in JPEG, PNG, and PDF/raster format.
AirSane's intended purpose is to be used with AirScan/eSCL clients such as Apple's Image Capture, but a simple web interface is provided as well.
Images are encoded on-the-fly during acquisition, keeping memory/storage demands low. Thus, AirSane will run fine on a Raspberry Pi or similar device.
Authentication and secure communication are supported in conjunction with a proxy server such as nginx (see the https readme file).
If you are looking for a powerful SANE web frontend, AirSane may not be for you. You may be interested in phpSANE instead.
AirSane has been developed by reverse-engineering the communication protocol implemented in Apple's AirScanScanner client (macos 10.12.6, /System/Library/Image Capture/Devices/AirScanScanner.app).
Regarding the mdns announcement, and the basic working of the eSCL protocol, David Poole's blog was very helpful.

%prep
%autosetup -p1

%build
%cmake
%cmake_build

%install
%cmake_install
%__install -D -m 644 %{S:1} %{buildroot}%{_prefix}/lib/firewalld/services/airsaned.xml

%post
%service_add_post airsaned.service
%if 0%{?suse_version} < 1500
%desktop_database_post
%endif
%{firewalld_reload}

%pre
%service_add_pre airsaned.service

%preun
%service_del_preun airsaned.service

%postun
%service_del_postun airsaned.service
%if 0%{?suse_version} < 1500
%desktop_database_postun
%endif

%files
%license LICENSE
%doc README.md
%{_bindir}/airsaned
%dir %{_sysconfdir}/airsane
%config(noreplace) %{_sysconfdir}/airsane/ignore.conf
%config(noreplace) %{_sysconfdir}/airsane/options.conf
%config(noreplace) %{_sysconfdir}/airsane/access.conf
%config %{_sysconfdir}/default/airsane
%{_sysconfdir}/airsane/Gnome-scanner.png
%{_unitdir}/airsaned.service
%dir %{_prefix}/lib/firewalld
%dir %{_prefix}/lib/firewalld/services
%{_prefix}/lib/firewalld/services/airsaned.xml

%changelog
openSUSE Build Service is sponsored by