Subject: [alpine-aports] [PATCH] testing/sane: new aport

From: Valery Kartel <[email-masked]>
Date: Tue, 13 Dec 2016 01:52:53 +0200

http://sane-project.org
SANE (Scanner Access Now Easy) is an universal scanner interface
---
 testing/sane/APKBUILD               | 104 ++++++++++++++++++++++++++++++++++++
 testing/sane/pidfile.patch          |  11 ++++
 testing/sane/sane-saned.pre-install |   5 ++
 testing/sane/sane.pre-install       |   5 ++
 testing/sane/saned.initd            |  14 +++++
 testing/sane/types_h.patch          |  11 ++++
 6 files changed, 150 insertions(+)
 create mode 100644 testing/sane/APKBUILD
 create mode 100644 testing/sane/pidfile.patch
 create mode 100644 testing/sane/sane-saned.pre-install
 create mode 100644 testing/sane/sane.pre-install
 create mode 100644 testing/sane/saned.initd
 create mode 100644 testing/sane/types_h.patch

diff --git a/testing/sane/APKBUILD b/testing/sane/APKBUILD
new file mode 100644
index 0000000000..f8f917c6f5
--- /dev/null
+++ b/testing/sane/APKBUILD
@@ -0,0 +1,104 @@
+# Contributor: Valery Kartel <[email-masked]>
+# Maintainer:
+pkgname=sane
+pkgver=1.0.25
+pkgrel=0
+pkgdesc="SANE (Scanner Access Now Easy) is an universal scanner interface"
+url="http://sane-project.org"
+arch="all"
+license="GPL"
+depends=""
+depends_dev=""
+makedepends="file libtool libieee1284-dev libusb-dev net-snmp-dev libjpeg-turbo-dev tiff-dev libgphoto2-dev"
+install="$pkgname-saned.pre-install $pkgname.pre-install"
+_backends="abaton agfafocus apple artec artec_eplus48u as6e avision bh canon canon630u canon_dr canon_pp
+	cardscan coolscan coolscan2 coolscan3 dc25 dc210 dc240 dell1600n_net dmc epjitsu epson epson2 epsonds
+	fujitsu genesys gphoto2 gt68xx hp hp3500 hp3900 hp4200 hp5400 hp5590 hpsj5s hpljm1005 hs2p ibm kodak
+	kodakaio kvs1025 kvs20xx kvs40xx leo lexmark ma1509 magicolor matsushita microtek microtek2 mustek
+	mustek_pp mustek_usb mustek_usb2 nec net niash pie pieusb pixma plustek plustek_pp qcam ricoh rts8891
+	s9036 sceptre sharp sm3600 sm3840 snapscan sp15c st400 stv680 tamarack teco1 teco2 teco3 test u12 umax
+	umax_pp umax1220u xerox_mfp p5"
+subpackages="$pkgname-doc $pkgname-dev $pkgname-udev::noarch"
+for _backend in $_backends; do
+	subpackages="$subpackages $pkgname-backend-$_backend:_backend"
+done
+subpackages="$subpackages $pkgname-utils $pkgname-saned"
+source="https://alioth.debian.org/frs/download.php/file/4146/$pkgname-backends-$pkgver.tar.gz
+	saned.initd
+	pidfile.patch
+	types_h.patch"
+builddir="$srcdir"/$pkgname-backends-$pkgver
+
+build() {
+	cd "$builddir"
+	./configure \
+	--prefix=/usr \
+	--sysconfdir=/etc \
+	--with-docdir=/usr/share/doc/$pkgname \
+	--enable-libusb_1_0 \
+	|| return 1
+	make || return 1
+}
+
+package() {
+	cd "$builddir"
+	make DESTDIR="$pkgdir" install || return 1
+}
+
+saned() {
+	pkgdesc="SANE network scanner server"
+	mkdir -p "$subpkgdir"/etc/$pkgname.d "$subpkgdir"/usr
+	mv "$pkgdir"/etc/$pkgname.d/saned.conf "$subpkgdir"/etc/$pkgname.d
+	mv "$pkgdir"/usr/sbin "$subpkgdir"/usr/
+	install -Dm755 "$srcdir"/saned.initd "$subpkgdir"/etc/init.d/saned
+}
+
+udev() {
+	pkgdesc="SANE udev rules"
+	install_if="$pkgname=$pkgver-r$pkgrel udev"
+	install -Dm644 "$builddir"/tools/udev/lib$pkgname.rules \
+		"$subpkgdir"/etc/udev/rules.d/41-lib$pkgname.rules
+}
+
+utils() {
+	pkgdesc="SANE utilities"
+	mkdir -p "$subpkgdir"/usr
+	mv "$pkgdir"/usr/bin "$subpkgdir"/usr
+	rmdir "$pkgdir"/usr/share/$pkgname "$pkgdir"/usr/share || return 1
+}
+
+_backend() {
+	depends="$pkgname"
+	pkgdesc="SANE backend: $name"
+	local name=${subpkgname#$pkgname-backend-}
+	mkdir -p "$subpkgdir"/usr/lib/$pkgname
+	mv "$pkgdir"/usr/lib/$pkgname/lib$pkgname-$name.* \
+		"$subpkgdir"/usr/lib/$pkgname || return 1
+	if [ -f "$pkgdir"/etc/$pkgname.d/$name.conf ]; then
+		mkdir -p "$subpkgdir"/etc/$pkgname.d
+		mv "$pkgdir"/etc/$pkgname.d/$name.conf \
+			"$subpkgdir"/etc/$pkgname.d
+	fi
+	if [ -d "$pkgdir"/usr/share/$pkgname/$name ]; then
+		mkdir -p "$subpkgdir"/usr/share/$pkgname
+		mv "$pkgdir"/usr/share/$pkgname/$name \
+			"$subpkgdir"/usr/share/$pkgname
+	fi
+	if [ -f "$pkgdir"/usr/bin/$name ]; then
+		mkdir -p "$subpkgdir"/usr/bin
+		mv "$pkgdir"/usr/bin/$name "$subpkgdir"/usr/bin
+	fi
+}
+
+md5sums="f9ed5405b3c12f07c6ca51ee60225fe7  sane-backends-1.0.25.tar.gz
+042bb035974918365e83568fd3a285df  saned.initd
+f266a1ec6db5461e39531acf509738a4  pidfile.patch
+bc249a3ab2f9cdd12443831b5a999469  types_h.patch"
+sha256sums="a4d7ba8d62b2dea702ce76be85699940992daf3f44823ddc128812da33dc6e2c  sane-backends-1.0.25.tar.gz
+a3885af89b86b827d491ac67a78321e8bb9d9a05cb652c1a046986217b1e28b0  saned.initd
+8d81005e5b350b109e186c8fa267f9938a8c35b8bbf353534e99aadd4261da8f  pidfile.patch
+4112c9d6a9d7b9a3ac836e02c4617a71c0519451faf1138ee1038db8cc3422df  types_h.patch"
+sha512sums="b9548646fff13558a4da4a4e9e8bad730f05121bcc65b72d24ded3bfddc6fe574e08c39c8651544b8fbfeab036fffd76cc14d76ef5d5d47e7513a2ce3afcc9df  sane-backends-1.0.25.tar.gz
+0a06eaa28b345202f2bdf8361e06f843bb7a010b7d8f80132f742672c94249c43f64031cefa161e415e2e2ab3a53b23070fb63854283f9e040f5ff79394ac7d1  saned.initd
+09505943f9441854a6c333f19e2535b4a646a8cc060fe82c6261e7d29c72773ebe98d43a91acc951f4336a3c8b4c84ab7c7b0763426136b4b59d9546bc2fa8c0  pidfile.patch
+1779ff8beb1ba5f9238c25d819a7f0045f7e257c19b511315feb85650e445ca86450a9e1d7ff8650499d3dae808589a6c2e358d5f3f39a3f40ce4999179b86d6  types_h.patch"
diff --git a/testing/sane/pidfile.patch b/testing/sane/pidfile.patch
new file mode 100644
index 0000000000..457755bdb8
--- /dev/null
+++ b/testing/sane/pidfile.patch
@@ -0,0 +1,11 @@
+--- a/frontend/saned.c
++++ b/frontend/saned.c
+@@ -224,7 +224,7 @@
+ int numchildren;
+ 
+ #define SANED_CONFIG_FILE "saned.conf"
+-#define SANED_PID_FILE    "/var/run/saned.pid"
++#define SANED_PID_FILE    "/run/saned/saned.pid"
+ 
+ #define SANED_SERVICE_NAME   "sane-port"
+ #define SANED_SERVICE_PORT   6566
diff --git a/testing/sane/sane-saned.pre-install b/testing/sane/sane-saned.pre-install
new file mode 100644
index 0000000000..caad990d96
--- /dev/null
+++ b/testing/sane/sane-saned.pre-install
@@ -0,0 +1,5 @@
+#!/bin/sh
+
+adduser -SDH -h /run/saned -s /sbin/nologin -G scanner -g saned saned 2>/dev/null
+
+exit 0
diff --git a/testing/sane/sane.pre-install b/testing/sane/sane.pre-install
new file mode 100644
index 0000000000..b75c867de9
--- /dev/null
+++ b/testing/sane/sane.pre-install
@@ -0,0 +1,5 @@
+#!/bin/sh
+
+addgroup -S scanner 2>/dev/null
+
+exit 0
diff --git a/testing/sane/saned.initd b/testing/sane/saned.initd
new file mode 100644
index 0000000000..6482073ef4
--- /dev/null
+++ b/testing/sane/saned.initd
@@ -0,0 +1,14 @@
+#!/sbin/openrc-run
+
+description="SANE network scanner server"
+
+owner=saned
+pidfile=/run/saned/saned.pid
+cfgfile=/etc/sane.d/saned.conf
+command=/usr/sbin/saned
+command_args="-a $owner"
+required_files="$cfgfile"
+
+start_pre() {
+	checkpath -dm755 -o $owner ${pidfile%/*}
+}
diff --git a/testing/sane/types_h.patch b/testing/sane/types_h.patch
new file mode 100644
index 0000000000..518d3b4d5c
--- /dev/null
+++ b/testing/sane/types_h.patch
@@ -0,0 +1,11 @@
+--- a/include/sane/sane.h
++++ b/include/sane/sane.h
+@@ -16,6 +16,8 @@
+ #ifndef sane_h
+ #define sane_h
+ 
++#include <sys/types.h>
++
+ #ifdef __cplusplus
+ extern "C" {
+ #endif
-- 
2.11.0

---
Unsubscribe:  [email-masked]
Help:         [email-masked]
---