From c8cf23699feb55f0b754cfe9c14aced1ba4f56c7 Mon Sep 17 00:00:00 2001
From: =?UTF-8?q?J=C3=B6rg=20Frings-F=C3=BCrst?= <debian@jff-webhosting.net>
Date: Sat, 13 Dec 2014 17:46:39 +0100
Subject: Debian bugs#665915, #769196, #772955

---
 debian/changelog                            | 24 ++++++++++++
 debian/control                              |  2 +
 debian/patches/0500-systemd_configure.patch | 60 +++++++++++++++++++++++++++++
 debian/patches/series                       |  1 +
 debian/rules                                |  7 ++--
 debian/sane-utils.lintian-overrides         |  4 ++
 debian/sane-utils.postinst                  |  5 +++
 debian/sane-utils.saned.service             | 12 ------
 debian/sane-utils.saned@.service            | 16 ++++++++
 9 files changed, 116 insertions(+), 15 deletions(-)
 create mode 100644 debian/patches/0500-systemd_configure.patch
 create mode 100644 debian/sane-utils.lintian-overrides
 delete mode 100644 debian/sane-utils.saned.service
 create mode 100644 debian/sane-utils.saned@.service

(limited to 'debian')

diff --git a/debian/changelog b/debian/changelog
index 2e107b7..15fb95e 100644
--- a/debian/changelog
+++ b/debian/changelog
@@ -1,3 +1,27 @@
+sane-backends (1.0.24-6) unstable; urgency=medium
+
+  * Revert changes from 1.0.24-5.
+  * Rename sane-utils.saned.service to sane-utils.saned@.service to
+    install it as template (Closes: #769196).
+  * For test for newer versions of systemd:
+    - New debian/patches/0500-systemd_configure.patch 
+      + Add part into configure.in to find systemd >=209
+    - debian/control:
+      + Add autoconf and libsystemd-dev to Built-Depends.
+    - debian/rules:
+      + Add autoconf before running configure to build the patched
+        configure script.
+    - Thanks to Michael Biebl <biebl@debian.org>.
+  * Change sane-utils.saned@.service and sane-utils.saned.socket 
+    for running as template (Closes: #772955).
+  * debian/sane-utils.postinst:
+    - Add part to move the homedir from /home/saned to /var/lib/saned.
+      (Closes: #665915)
+  * New debian/sane-utils.lintian-overrides:
+    - Override postrm-contains-additional-updaterc.d-calls.
+
+ -- Jörg Frings-Fürst <debian@jff-webhosting.net>  Sat, 13 Dec 2014 11:20:55 +0100
+
 sane-backends (1.0.24-5) unstable; urgency=medium
 
   * debian/rules:
diff --git a/debian/control b/debian/control
index cb1f9c9..e01cd80 100644
--- a/debian/control
+++ b/debian/control
@@ -5,6 +5,7 @@ Maintainer: Jörg Frings-Fürst <debian@jff-webhosting.net>
 Standards-Version: 3.9.6
 Build-Depends:
  autotools-dev,
+ autoconf,
  chrpath,
  debhelper (>= 9),
  dh-systemd,
@@ -15,6 +16,7 @@ Build-Depends:
  libieee1284-3-dev [!hurd-i386],
  libjpeg-dev,
  libltdl3-dev,
+ libsystemd-dev [linux-any],
  libtiff-dev,
  libusb-1.0-0-dev [!hurd-i386],
  libv4l-dev [linux-any],
diff --git a/debian/patches/0500-systemd_configure.patch b/debian/patches/0500-systemd_configure.patch
new file mode 100644
index 0000000..27121e6
--- /dev/null
+++ b/debian/patches/0500-systemd_configure.patch
@@ -0,0 +1,60 @@
+Description: Change test for systemd >= 209
+Author: Jörg Frings-Fürst <debian@jff-webhosting.net>
+Bug-Debian: https://bugs.debian.org/cgi-bin/bugreport.cgi?bug=769196
+Forwarded: https://alioth.debian.org/tracker/index.php?func=detail&aid=314906&group_id=30186&atid=410366
+Last-Update: 2014-12-11
+---
+This patch header follows DEP-3: http://dep.debian.net/deps/dep3/
+Index: trunk/configure.in
+===================================================================
+--- trunk.orig/configure.in
++++ trunk/configure.in
+@@ -344,17 +344,40 @@ else
+ 	with_cups="no"
+ fi
+ 
++dnl
+ dnl added by llagendijk 12/7/2012 to detect systemd for saned
+-$as_echo_n "Checking for systemd..."
+-if test -e /usr/include/systemd/sd-daemon.h ; then
+-    AC_DEFINE(HAVE_SYSTEMD, 1, [Is /usr/include/systemd/sd-daemon.h available?])
+-    with_systemd="yes"
+-    SYSTEMD_LIBS=" -lsystemd-daemon"
+-    AC_SUBST(SYSTEMD_LIBS)
+-    $as_echo "yes"
++dnl changed by jff 2014/12/11 for detect systemd >=209
++dnl
++$as_echo "Begin checking for systemd"
++test_systemd=no
++PKG_CHECK_MODULES([libsystemd],
++    [libsystemd >= 209],
++    [test_systemd=yes],
++    [PKG_CHECK_MODULES([libsystemd],
++        [libsystemd-daemon],
++	[test_systemd=yes],
++	[]
++	)
++    ]
++)
++if test x$test_systemd = xyes; then
++    AC_CHECK_HEADERS(systemd/sd-daemon.h,
++        [
++	    AC_DEFINE(HAVE_SYSTEMD, 1, [Is /usr/include/systemd/sd-daemon.h available?])
++            with_systemd="yes"
++	    SYSTEMD_LIBS=" "${libsystemd_LIBS}
++	    AC_SUBST(SYSTEMD_LIBS)
++	    $as_echo "Checking for systemd...yes"
++	],
++	[
++	    AC_MSG_ERROR([systemd development headers not found.])
++	    with_systemd="no"
++	    $as_echo "Checking for systemd...no"
++	]
++    )
+ else
+     with_systemd="no"
+-    $as_echo "no"
++    $as_echo "Checking for systemd...no"
+ fi
+ 
+ dnl ***********
diff --git a/debian/patches/series b/debian/patches/series
index 5699297..e081d43 100644
--- a/debian/patches/series
+++ b/debian/patches/series
@@ -20,3 +20,4 @@ source-spelling.patch
 ppc64el.patch
 hp5370c.patch
 out_of_bounds.patch
+0500-systemd_configure.patch
diff --git a/debian/rules b/debian/rules
index a32f858..b04da9d 100755
--- a/debian/rules
+++ b/debian/rules
@@ -27,9 +27,10 @@ ifeq (,$(findstring nostrip,$(DEB_BUILD_OPTIONS)))
 endif
 
 %:
-	dh $@ --parallel --with autotools_dev, systemd
+	dh $@ --parallel --with autotools_dev,systemd
 
 override_dh_auto_configure:
+	autoconf
 	./configure --host=$(DEB_HOST_GNU_TYPE) --build=$(DEB_BUILD_GNU_TYPE) \
 		--prefix=/usr \
 		--libdir=\$${prefix}/lib/$(DEB_HOST_MULTIARCH) \
@@ -124,8 +125,8 @@ endif
 	chrpath -d debian/sane-utils/usr/bin/sane-find-scanner
 
 override_dh_installinit:
-	dh_installinit -psane-utils --name=saned --error-handler=saned_eh
-	cp $(CURDIR)/debian/sane-utils.saned.socket $(CURDIR)/debian/sane-utils/lib/systemd/system/saned@.socket
+	dh_installinit -psane-utils --name=saned@ --error-handler=saned_eh
+	cp $(CURDIR)/debian/sane-utils.saned.socket $(CURDIR)/debian/sane-utils/lib/systemd/system/saned.socket
 
 override_dh_strip:
 	dh_strip --dbg-package=libsane-dbg
diff --git a/debian/sane-utils.lintian-overrides b/debian/sane-utils.lintian-overrides
new file mode 100644
index 0000000..32a16bc
--- /dev/null
+++ b/debian/sane-utils.lintian-overrides
@@ -0,0 +1,4 @@
+#
+# User enabled. See sane-utils.README.Debian
+#
+postrm-contains-additional-updaterc.d-calls
diff --git a/debian/sane-utils.postinst b/debian/sane-utils.postinst
index cd2aff3..4f16f0a 100644
--- a/debian/sane-utils.postinst
+++ b/debian/sane-utils.postinst
@@ -29,6 +29,11 @@ if [ "$1" = "configure" ] || [ "$1" = "reconfigure" ]; then
 	adduser --home /var/lib/saned  --quiet --system --no-create-home --group saned || true
     fi
 
+    # Move home from /home/saned to /var/lib/saned
+    if getent passwd | grep "^saned:" | grep "/home/saned"; then
+	echo "Moveing homedir from /home/saned to /var/lib/saned"
+	usermod -d /var/lib/saned saned
+    fi
     if [ "$SANED_IN_SCANNER" = "true" ]; then
 	adduser --quiet saned scanner
     else
diff --git a/debian/sane-utils.saned.service b/debian/sane-utils.saned.service
deleted file mode 100644
index 5116c3d..0000000
--- a/debian/sane-utils.saned.service
+++ /dev/null
@@ -1,12 +0,0 @@
-[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=/etc/sane.d SANE_DEBUG_DLL=255
diff --git a/debian/sane-utils.saned@.service b/debian/sane-utils.saned@.service
new file mode 100644
index 0000000..e9fc879
--- /dev/null
+++ b/debian/sane-utils.saned@.service
@@ -0,0 +1,16 @@
+[Unit]
+Description=Scanner Service
+Requires=saned.socket
+
+[Service]
+ExecStart=/usr/sbin/saned
+User=saned
+Group=saned
+StandardInput=socket
+StandardOutput=syslog
+StandardError=syslog
+Environment=SANE_CONFIG_DIR=/etc/sane.d
+# Environment=SANE_CONFIG_DIR=/etc/sane.d SANE_DEBUG_DLL=255
+
+[Install]
+Also=saned.socket
-- 
cgit v1.2.3