add socket activation support for saned (#1091566)

This commit is contained in:
Nils Philippsen 2016-10-07 19:56:52 +02:00
parent 5c9ab2f7d6
commit ed7bc9cb97
3 changed files with 55 additions and 0 deletions

View File

@ -41,6 +41,8 @@ License: GPLv2+ and GPLv2+ with exceptions and Public Domain
# Alioth Download URLs are amazing. # Alioth Download URLs are amazing.
Source0: https://alioth.debian.org/frs/download.php/latestfile/176/sane-backends-%{version}.tar.gz Source0: https://alioth.debian.org/frs/download.php/latestfile/176/sane-backends-%{version}.tar.gz
Source1: sane.png Source1: sane.png
Source2: saned.socket
Source3: saned@.service.in
# Fedora-specific, probably not generally applicable: # Fedora-specific, probably not generally applicable:
Patch0: sane-backends-1.0.25-udev.patch Patch0: sane-backends-1.0.25-udev.patch
@ -64,6 +66,8 @@ BuildRequires: libtiff-devel
BuildRequires: libv4l-devel BuildRequires: libv4l-devel
BuildRequires: gettext BuildRequires: gettext
BuildRequires: gphoto2-devel BuildRequires: gphoto2-devel
BuildRequires: systemd-devel
BuildRequires: systemd
Requires: systemd >= 196 Requires: systemd >= 196
Requires: sane-backends-libs%{?_isa} = %{?epoch:%{epoch}:}%{version}-%{release} Requires: sane-backends-libs%{?_isa} = %{?epoch:%{epoch}:}%{version}-%{release}
# Don't drag around obsoletes forever # Don't drag around obsoletes forever
@ -155,6 +159,8 @@ This package contains backend drivers to access digital cameras through SANE.
Summary: Scanner network daemon Summary: Scanner network daemon
Requires: sane-backends = %{?epoch:%{epoch}:}%{version}-%{release} Requires: sane-backends = %{?epoch:%{epoch}:}%{version}-%{release}
Requires: sane-backends-libs%{?_isa} = %{?epoch:%{epoch}:}%{version}-%{release} Requires: sane-backends-libs%{?_isa} = %{?epoch:%{epoch}:}%{version}-%{release}
Requires(pre): shadow-utils
%{?systemd_requires}
# Split off saned from 1.0.25-3 on, don't drag around obsoletes forever # Split off saned from 1.0.25-3 on, don't drag around obsoletes forever
%if ! (0%{?fedora} >= 27 || 0%{?rhel} >= 8) %if ! (0%{?fedora} >= 27 || 0%{?rhel} >= 8)
Obsoletes: sane-backends < 1.0.25-3 Obsoletes: sane-backends < 1.0.25-3
@ -183,6 +189,7 @@ LDFLAGS="-pie"
%configure \ %configure \
--with-gphoto2=%{_prefix} \ --with-gphoto2=%{_prefix} \
--with-docdir=%{_maindocdir} \ --with-docdir=%{_maindocdir} \
--with-systemd \
--disable-locking --disable-rpath \ --disable-locking --disable-rpath \
%if %libusb1 %if %libusb1
--enable-libusb_1_0 \ --enable-libusb_1_0 \
@ -236,6 +243,11 @@ for f in *; do
done done
popd popd
install -m 755 -d %{buildroot}%{_unitdir}
install -m 644 %{SOURCE2} %{buildroot}%{_unitdir}
sed 's|@CONFIGDIR@|%{_sysconfdir}/sane.d|g' < %{SOURCE3} > saned@.service
install -m 644 saned@.service %{buildroot}%{_unitdir}
%find_lang %name %find_lang %name
%post %post
@ -247,6 +259,18 @@ udevadm hwdb --update >/dev/null 2>&1 || :
%post libs -p /sbin/ldconfig %post libs -p /sbin/ldconfig
%postun libs -p /sbin/ldconfig %postun libs -p /sbin/ldconfig
%pre daemon
getent group GROUPNAME >/dev/null || groupadd -r GROUPNAME
%post daemon
%systemd_post saned.socket
%preun daemon
%systemd_preun saned.socket
%postun daemon
%systemd_postun saned.socket
%files -f %{name}.lang %files -f %{name}.lang
%docdir %{_maindocdir} %docdir %{_maindocdir}
%doc %{_maindocdir}/AUTHORS %doc %{_maindocdir}/AUTHORS
@ -294,12 +318,15 @@ udevadm hwdb --update >/dev/null 2>&1 || :
%files daemon %files daemon
%{_sbindir}/saned %{_sbindir}/saned
%{_unitdir}/saned.socket
%{_unitdir}/saned@.service
%changelog %changelog
* Fri Oct 07 2016 Nils Philippsen <nils@redhat.com> * Fri Oct 07 2016 Nils Philippsen <nils@redhat.com>
- use %%license for license files - use %%license for license files
- remove some obsolete cruft from the spec file - remove some obsolete cruft from the spec file
- split off saned into daemon subpackage - split off saned into daemon subpackage
- add socket activation support for saned (#1091566)
* Thu Feb 04 2016 Fedora Release Engineering <releng@fedoraproject.org> - 1.0.25-2 * Thu Feb 04 2016 Fedora Release Engineering <releng@fedoraproject.org> - 1.0.25-2
- Rebuilt for https://fedoraproject.org/wiki/Fedora_24_Mass_Rebuild - Rebuilt for https://fedoraproject.org/wiki/Fedora_24_Mass_Rebuild

10
saned.socket Normal file
View File

@ -0,0 +1,10 @@
[Unit]
Description=saned incoming socket
[Socket]
ListenStream=6566
Accept=yes
MaxConnections=1
[Install]
WantedBy=sockets.target

18
saned@.service.in Normal file
View File

@ -0,0 +1,18 @@
[Unit]
Description=Scanner Service
Requires=saned.socket
[Service]
ExecStart=/usr/sbin/saned
User=saned
Group=saned
StandardInput=null
StandardOutput=syslog
StandardError=syslog
Environment=SANE_CONFIG_DIR=@CONFIGDIR@
# If you need to debug your configuration uncomment the next line and
# change it as appropriate to set the desired debug options
# Environment=SANE_DEBUG_DLL=255 SANE_DEBUG_NET=255
[Install]
Also=saned.socket