diff --git a/sane-backends.spec b/sane-backends.spec index efac70a..1e0f3f2 100644 --- a/sane-backends.spec +++ b/sane-backends.spec @@ -41,6 +41,8 @@ License: GPLv2+ and GPLv2+ with exceptions and Public Domain # Alioth Download URLs are amazing. Source0: https://alioth.debian.org/frs/download.php/latestfile/176/sane-backends-%{version}.tar.gz Source1: sane.png +Source2: saned.socket +Source3: saned@.service.in # Fedora-specific, probably not generally applicable: Patch0: sane-backends-1.0.25-udev.patch @@ -64,6 +66,8 @@ BuildRequires: libtiff-devel BuildRequires: libv4l-devel BuildRequires: gettext BuildRequires: gphoto2-devel +BuildRequires: systemd-devel +BuildRequires: systemd Requires: systemd >= 196 Requires: sane-backends-libs%{?_isa} = %{?epoch:%{epoch}:}%{version}-%{release} # 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 Requires: sane-backends = %{?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 %if ! (0%{?fedora} >= 27 || 0%{?rhel} >= 8) Obsoletes: sane-backends < 1.0.25-3 @@ -183,6 +189,7 @@ LDFLAGS="-pie" %configure \ --with-gphoto2=%{_prefix} \ --with-docdir=%{_maindocdir} \ + --with-systemd \ --disable-locking --disable-rpath \ %if %libusb1 --enable-libusb_1_0 \ @@ -236,6 +243,11 @@ for f in *; do done 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 %post @@ -247,6 +259,18 @@ udevadm hwdb --update >/dev/null 2>&1 || : %post 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 %docdir %{_maindocdir} %doc %{_maindocdir}/AUTHORS @@ -294,12 +318,15 @@ udevadm hwdb --update >/dev/null 2>&1 || : %files daemon %{_sbindir}/saned +%{_unitdir}/saned.socket +%{_unitdir}/saned@.service %changelog * Fri Oct 07 2016 Nils Philippsen - use %%license for license files - remove some obsolete cruft from the spec file - split off saned into daemon subpackage +- add socket activation support for saned (#1091566) * Thu Feb 04 2016 Fedora Release Engineering - 1.0.25-2 - Rebuilt for https://fedoraproject.org/wiki/Fedora_24_Mass_Rebuild diff --git a/saned.socket b/saned.socket new file mode 100644 index 0000000..1aa19e7 --- /dev/null +++ b/saned.socket @@ -0,0 +1,10 @@ +[Unit] +Description=saned incoming socket + +[Socket] +ListenStream=6566 +Accept=yes +MaxConnections=1 + +[Install] +WantedBy=sockets.target diff --git a/saned@.service.in b/saned@.service.in new file mode 100644 index 0000000..d2c0a26 --- /dev/null +++ b/saned@.service.in @@ -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