Gentoo Archives: gentoo-commits

From: Sam James <sam@g.o>
To: gentoo-commits@l.g.o
Subject: [gentoo-commits] repo/gentoo:master commit in: media-gfx/sane-backends/, media-gfx/sane-backends/files/
Date: Fri, 04 Nov 2022 04:19:28
Message-Id: 1667535538.3865b4531959596959b487d84fd862e2aac4999f.sam@gentoo
1 commit: 3865b4531959596959b487d84fd862e2aac4999f
2 Author: Sam James <sam <AT> gentoo <DOT> org>
3 AuthorDate: Fri Nov 4 04:17:27 2022 +0000
4 Commit: Sam James <sam <AT> gentoo <DOT> org>
5 CommitDate: Fri Nov 4 04:18:58 2022 +0000
6 URL: https://gitweb.gentoo.org/repo/gentoo.git/commit/?id=3865b453
7
8 media-gfx/sane-backends: fix configure w/ clang 16; fix service file & udev
9
10 - Fix configure with Clang 16
11 - Fix saned_at.service user name (scanner->saned, as scanner is the group)
12 - Fix path to setfacl in udev rule (previous one assumed /usr merge)
13 - Fix group name in udev rule (saned->scanner)
14 - Call udev_reload in pkg_post{rm,inst}
15
16 Closes: https://bugs.gentoo.org/876772
17 Closes: https://bugs.gentoo.org/859619
18 Closes: https://bugs.gentoo.org/849590
19 Signed-off-by: Sam James <sam <AT> gentoo.org>
20
21 media-gfx/sane-backends/files/66-saned.rules-r1 | 2 +
22 .../sane-backends-1.1.1-configure-clang16.patch | 43 +++
23 .../files/sane-backends-1.1.1-musl.patch | 34 ++
24 media-gfx/sane-backends/files/saned_at.service-r1 | 18 +
25 .../sane-backends/sane-backends-1.1.1-r5.ebuild | 376 +++++++++++++++++++++
26 5 files changed, 473 insertions(+)
27
28 diff --git a/media-gfx/sane-backends/files/66-saned.rules-r1 b/media-gfx/sane-backends/files/66-saned.rules-r1
29 new file mode 100644
30 index 000000000000..4e1fe9507eae
31 --- /dev/null
32 +++ b/media-gfx/sane-backends/files/66-saned.rules-r1
33 @@ -0,0 +1,2 @@
34 +# udev rule for saned (SANE scanning daemon) to be able to write on usb port
35 +ENV{libsane_matched}=="yes", ENV{DEVNAME}!="", RUN+="/bin/setfacl -m g:scanner:rw $env{DEVNAME}"
36
37 diff --git a/media-gfx/sane-backends/files/sane-backends-1.1.1-configure-clang16.patch b/media-gfx/sane-backends/files/sane-backends-1.1.1-configure-clang16.patch
38 new file mode 100644
39 index 000000000000..cc8a48b18b67
40 --- /dev/null
41 +++ b/media-gfx/sane-backends/files/sane-backends-1.1.1-configure-clang16.patch
42 @@ -0,0 +1,43 @@
43 +https://gitlab.com/sane-project/backends/-/merge_requests/763
44 +
45 +From 300b460970f538ab515835f14650785e88808a8f Mon Sep 17 00:00:00 2001
46 +From: Sam James <sam@g.o>
47 +Date: Fri, 4 Nov 2022 04:04:46 +0000
48 +Subject: [PATCH] acinclude.m4: fix -Wimplicit-function-declaration
49 +
50 +-Wimplicit-function-declaration will become an error by default
51 +in Clang 16.
52 +
53 +Fixes errors like:
54 +```
55 +error: call to undeclared library function 'exit' with type 'void (int) __attribute__((noreturn))'; ISO C99 and later do not support implicit function declarations [-Werror,-Wimplicit-function-declaration]
56 +```
57 +
58 +Signed-off-by: Sam James <sam@g.o>
59 +--- a/acinclude.m4
60 ++++ b/acinclude.m4
61 +@@ -471,6 +471,7 @@ AC_DEFUN([SANE_CHECK_IPV6],
62 + if test "$ipv6" != "no" ; then
63 + AC_COMPILE_IFELSE([AC_LANG_PROGRAM([[
64 + #define INET6
65 ++ #include <stdlib.h>
66 + #include <sys/types.h>
67 + #include <sys/socket.h> ]], [[
68 + /* AF_INET6 available check */
69 +@@ -492,6 +493,7 @@ AC_DEFUN([SANE_CHECK_IPV6],
70 + AC_MSG_CHECKING([whether struct sockaddr_storage has an ss_family member])
71 + AC_COMPILE_IFELSE([AC_LANG_PROGRAM([[
72 + #define INET6
73 ++ #include <stdlib.h>
74 + #include <sys/types.h>
75 + #include <sys/socket.h> ]], [[
76 + /* test if the ss_family member exists in struct sockaddr_storage */
77 +@@ -504,6 +506,7 @@ AC_DEFUN([SANE_CHECK_IPV6],
78 + ], [
79 + AC_COMPILE_IFELSE([AC_LANG_PROGRAM([[
80 + #define INET6
81 ++ #include <stdlib.h>
82 + #include <sys/types.h>
83 + #include <sys/socket.h> ]], [[
84 + /* test if the __ss_family member exists in struct sockaddr_storage */
85 +GitLab
86
87 diff --git a/media-gfx/sane-backends/files/sane-backends-1.1.1-musl.patch b/media-gfx/sane-backends/files/sane-backends-1.1.1-musl.patch
88 new file mode 100644
89 index 000000000000..8aebb50672a1
90 --- /dev/null
91 +++ b/media-gfx/sane-backends/files/sane-backends-1.1.1-musl.patch
92 @@ -0,0 +1,34 @@
93 +https://gitlab.com/sane-project/backends/-/commit/12560890a6e298091bd63b8093a35604416eb92a
94 +
95 +From 12560890a6e298091bd63b8093a35604416eb92a Mon Sep 17 00:00:00 2001
96 +From: David Ward <david.ward@××××××.edu>
97 +Date: Thu, 21 Apr 2022 23:37:33 -0400
98 +Subject: [PATCH] Fix header file used for poll()
99 +
100 +POSIX specifies the header to include is <poll.h>, not <sys/poll.h>.
101 +This results in a compiler warning with musl libc (on Alpine Linux).
102 +--- a/configure.ac
103 ++++ b/configure.ac
104 +@@ -202,7 +202,7 @@ AC_HEADER_STDC
105 + AC_CHECK_HEADERS(fcntl.h unistd.h libc.h sys/dsreq.h sys/select.h \
106 + sys/time.h sys/shm.h sys/ipc.h sys/scanio.h os2.h \
107 + sys/socket.h sys/io.h sys/hw.h sys/types.h linux/ppdev.h \
108 +- dev/ppbus/ppi.h machine/cpufunc.h sys/sem.h sys/poll.h \
109 ++ dev/ppbus/ppi.h machine/cpufunc.h sys/sem.h poll.h \
110 + windows.h be/kernel/OS.h limits.h sys/ioctl.h asm/types.h\
111 + netinet/in.h tiffio.h ifaddrs.h pwd.h getopt.h)
112 + AC_CHECK_HEADERS([asm/io.h],,,[#include <sys/types.h>])
113 +--- a/frontend/saned.c
114 ++++ b/frontend/saned.c
115 +@@ -84,8 +84,8 @@
116 +
117 + #include "lgetopt.h"
118 +
119 +-#if defined(HAVE_SYS_POLL_H) && defined(HAVE_POLL)
120 +-# include <sys/poll.h>
121 ++#if defined(HAVE_POLL_H) && defined(HAVE_POLL)
122 ++# include <poll.h>
123 + #else
124 + /*
125 + * This replacement poll() using select() is only designed to cover
126 +GitLab
127
128 diff --git a/media-gfx/sane-backends/files/saned_at.service-r1 b/media-gfx/sane-backends/files/saned_at.service-r1
129 new file mode 100644
130 index 000000000000..b7d6179bba71
131 --- /dev/null
132 +++ b/media-gfx/sane-backends/files/saned_at.service-r1
133 @@ -0,0 +1,18 @@
134 +[Unit]
135 +Description=Scanner Service
136 +Requires=saned.socket
137 +
138 +[Service]
139 +ExecStart=/usr/sbin/saned
140 +User=saned
141 +Group=scanner
142 +StandardInput=null
143 +StandardOutput=syslog
144 +StandardError=syslog
145 +Environment=SANE_CONFIG_DIR=/etc/sane.d
146 +# If you need to debug your configuration uncomment the next line and
147 +# change it as appropriate to set the desired debug options
148 +# Environment=SANE_DEBUG_DLL=255 SANE_DEBUG_NET=255
149 +
150 +[Install]
151 +Also=saned.socket
152
153 diff --git a/media-gfx/sane-backends/sane-backends-1.1.1-r5.ebuild b/media-gfx/sane-backends/sane-backends-1.1.1-r5.ebuild
154 new file mode 100644
155 index 000000000000..77b5ec95218e
156 --- /dev/null
157 +++ b/media-gfx/sane-backends/sane-backends-1.1.1-r5.ebuild
158 @@ -0,0 +1,376 @@
159 +# Copyright 1999-2022 Gentoo Authors
160 +# Distributed under the terms of the GNU General Public License v2
161 +
162 +EAPI=8
163 +
164 +PYTHON_COMPAT=( python3_{8..10} )
165 +
166 +# python-any-r1 required for a script in
167 +# backends/pixma/scripts/
168 +inherit autotools flag-o-matic multilib-minimal optfeature python-any-r1 systemd toolchain-funcs udev
169 +
170 +# gphoto and v4l are handled by their usual USE flags.
171 +# The pint backend was disabled because I could not get it to compile.
172 +IUSE_SANE_BACKENDS=(
173 + abaton
174 + agfafocus
175 + apple
176 + artec
177 + artec_eplus48u
178 + as6e
179 + avision
180 + bh
181 + canon
182 + canon630u
183 + canon_dr
184 + canon_lide70
185 + canon_pp
186 + cardscan
187 + coolscan
188 + coolscan2
189 + coolscan3
190 + dc210
191 + dc240
192 + dc25
193 + dell1600n_net
194 + dmc
195 + epjitsu
196 + epson
197 + epson2
198 + epsonds
199 + escl
200 + fujitsu
201 + genesys
202 + gt68xx
203 + hp
204 + hp3500
205 + hp3900
206 + hp4200
207 + hp5400
208 + hp5590
209 + hpljm1005
210 + hpsj5s
211 + hs2p
212 + ibm
213 + kodak
214 + kodakaio
215 + kvs1025
216 + kvs20xx
217 + kvs40xx
218 + leo
219 + lexmark
220 + ma1509
221 + magicolor
222 + matsushita
223 + microtek
224 + microtek2
225 + mustek
226 + mustek_pp
227 + mustek_usb
228 + mustek_usb2
229 + nec
230 + net
231 + niash
232 + p5
233 + pie
234 + pieusb
235 + pixma
236 + plustek
237 + plustek_pp
238 + pnm
239 + qcam
240 + ricoh
241 + ricoh2
242 + rts8891
243 + s9036
244 + sceptre
245 + sharp
246 + sm3600
247 + sm3840
248 + snapscan
249 + sp15c
250 + st400
251 + stv680
252 + tamarack
253 + teco1
254 + teco2
255 + teco3
256 + test
257 + u12
258 + umax
259 + umax1220u
260 + umax_pp
261 + xerox_mfp
262 +)
263 +
264 +IUSE="gphoto2 ipv6 snmp systemd threads usb v4l xinetd +zeroconf"
265 +
266 +for GBACKEND in ${IUSE_SANE_BACKENDS[@]}; do
267 + case ${GBACKEND} in
268 + # Disable backends that require parallel ports as no one has those anymore.
269 + canon_pp|hpsj5s|mustek_pp|\
270 + pnm|mustek_usb2|kvs40xx)
271 + IUSE+=" sane_backends_${GBACKEND}"
272 + ;;
273 + *)
274 + IUSE+=" +sane_backends_${GBACKEND}"
275 + esac
276 +done
277 +
278 +REQUIRED_USE="
279 + sane_backends_escl? ( zeroconf )
280 + sane_backends_kvs40xx? ( threads )
281 + sane_backends_mustek_usb2? ( threads )
282 +"
283 +
284 +DESCRIPTION="Scanner Access Now Easy - Backends"
285 +HOMEPAGE="http://www.sane-project.org/"
286 +SRC_URI="https://gitlab.com/sane-project/backends/uploads/7d30fab4e115029d91027b6a58d64b43/${P}.tar.gz"
287 +
288 +LICENSE="GPL-2 public-domain"
289 +SLOT="0"
290 +KEYWORDS="~alpha ~amd64 ~arm ~arm64 ~hppa ~ia64 ~m68k ~mips ~ppc ~ppc64 ~riscv ~s390 ~sparc ~x86 ~amd64-linux ~x86-linux"
291 +
292 +# For pixma: see https://gitlab.com/sane-project/backends/-/releases/1.0.28#build
293 +RDEPEND="
294 + acct-user/saned
295 + acct-group/scanner
296 + gphoto2? (
297 + >=media-libs/libgphoto2-2.5.3.1:=[${MULTILIB_USEDEP}]
298 + media-libs/libjpeg-turbo:=[${MULTILIB_USEDEP}]
299 + )
300 + sane_backends_canon_pp? ( >=sys-libs/libieee1284-0.2.11-r3[${MULTILIB_USEDEP}] )
301 + sane_backends_dc210? ( media-libs/libjpeg-turbo:=[${MULTILIB_USEDEP}] )
302 + sane_backends_dc240? ( media-libs/libjpeg-turbo:=[${MULTILIB_USEDEP}] )
303 + sane_backends_dell1600n_net? (
304 + >=media-libs/tiff-3.9.7-r1:0=[${MULTILIB_USEDEP}]
305 + media-libs/libjpeg-turbo:=[${MULTILIB_USEDEP}]
306 + )
307 + sane_backends_escl? (
308 + app-text/poppler[cairo]
309 + || (
310 + net-dns/avahi[dbus]
311 + net-dns/avahi[gtk]
312 + )
313 + net-dns/avahi[${MULTILIB_USEDEP}]
314 + net-misc/curl[${MULTILIB_USEDEP}]
315 + )
316 + sane_backends_hpsj5s? ( >=sys-libs/libieee1284-0.2.11-r3[${MULTILIB_USEDEP}] )
317 + sane_backends_mustek_pp? ( >=sys-libs/libieee1284-0.2.11-r3[${MULTILIB_USEDEP}] )
318 + sane_backends_pixma? ( media-libs/libjpeg-turbo:=[${MULTILIB_USEDEP}] )
319 + snmp? ( net-analyzer/net-snmp:0= )
320 + systemd? ( sys-apps/systemd:0= )
321 + usb? ( >=virtual/libusb-1-r1:1=[${MULTILIB_USEDEP}] )
322 + v4l? ( >=media-libs/libv4l-0.9.5[${MULTILIB_USEDEP}] )
323 + xinetd? ( sys-apps/xinetd )
324 + zeroconf? ( >=net-dns/avahi-0.6.31-r2[${MULTILIB_USEDEP}] )
325 +"
326 +
327 +DEPEND="${RDEPEND}
328 + dev-libs/libxml2
329 + v4l? ( sys-kernel/linux-headers )
330 +"
331 +BDEPEND="
332 + ${PYTHON_DEPS}
333 + sys-devel/autoconf-archive
334 + sys-devel/gettext
335 + virtual/pkgconfig
336 +"
337 +
338 +PATCHES=(
339 + "${FILESDIR}"/${PN}-1.0.24-saned_pidfile_location.patch
340 + "${FILESDIR}"/${PN}-1.0.27-disable-usb-tests.patch
341 + "${FILESDIR}"/${PN}-1.0.30-add_hpaio_epkowa_dll.conf.patch
342 + # https://gitlab.com/sane-project/backends/-/merge_requests/688
343 + "${FILESDIR}"/${PN}-1.1.1-genesys-gl845-crash.patch
344 + "${FILESDIR}"/${P}-gcc12-tests.patch
345 + "${FILESDIR}"/${PN}-1.1.1-configure-clang16.patch
346 + "${FILESDIR}"/${P}-musl.patch
347 +)
348 +
349 +MULTILIB_CHOST_TOOLS=(
350 + /usr/bin/sane-config
351 +)
352 +
353 +src_prepare() {
354 + default
355 +
356 + # Patch out the git reference so we can run eautoreconf
357 + sed \
358 + -e "s/m4_esyscmd_s(\[git describe --dirty\])/${PV}/" \
359 + -e '/^AM_MAINTAINER_MODE/d' \
360 + -i configure.ac || die
361 + eautoreconf
362 +
363 + # Fix for "make check". Upstream sometimes forgets to update this.
364 + local ver=$(./configure --version | awk '{print $NF; exit 0}')
365 + sed -i \
366 + -e "/by sane-desc 3.5 from sane-backends/s:sane-backends .*:sane-backends ${ver}:" \
367 + testsuite/tools/data/html* || die
368 +
369 + # don't bleed user LDFLAGS into pkgconfig files
370 + sed 's|@LDFLAGS@ ||' -i tools/*.pc.in || die
371 +
372 + # Needed for udev rules generation/installation
373 + multilib_copy_sources
374 +}
375 +
376 +src_configure() {
377 + # From Fedora
378 + append-flags -fno-strict-aliasing
379 + multilib-minimal_src_configure
380 +}
381 +
382 +multilib_src_configure() {
383 + # the blank is intended - an empty string would result in building ALL backends.
384 + local lbackends=" "
385 +
386 + use gphoto2 && lbackends="gphoto2"
387 + use v4l && lbackends+=" v4l"
388 + use sane_backends_escl && multilib_is_native_abi && lbackends+=" escl"
389 + local backend
390 + for backend in ${IUSE_SANE_BACKENDS[@]} ; do
391 + if use "sane_backends_${backend}" && [[ "${backend}" != pnm ]] && [[ "${backend}" != escl ]] ; then
392 + lbackends+=" ${backend}"
393 + fi
394 + done
395 +
396 + local myconf=(
397 + $(use_with usb)
398 + $(multilib_native_use_with snmp)
399 +
400 + $(multilib_native_use_with sane_backends_escl poppler-glib)
401 + # you can only enable this backend, not disable it...
402 + $(usex sane_backends_pnm --enable-pnm-backend '')
403 + $(usex sane_backends_mustek_pp --enable-parport-directio '')
404 + )
405 +
406 + if ! { use sane_backends_canon_pp || use sane_backends_hpsj5s || use sane_backends_mustek_pp ; } ; then
407 + myconf+=( sane_cv_use_libieee1284=no )
408 + fi
409 +
410 + # relative path must be used for tests to work properly
411 + # All distributions pass --disable-locking because /var/lock/sane/ would be a world-writable directory
412 + # that break in many ways, bug #636202, #668232, #668350
413 + # People can refer to the "Programmer's Documentation" at http://www.sane-project.org/docs.html
414 + myconf+=(
415 + --disable-locking
416 + $(use_with gphoto2)
417 + $(multilib_native_use_with systemd)
418 + $(use_with v4l)
419 + $(use_enable ipv6)
420 + $(use_enable threads pthread)
421 + $(use_with zeroconf avahi)
422 + )
423 + ECONF_SOURCE="${S}" \
424 + SANEI_JPEG="sanei_jpeg.o" SANEI_JPEG_LO="sanei_jpeg.lo" \
425 + BACKENDS="${lbackends}" \
426 + econf "${myconf[@]}"
427 +}
428 +
429 +multilib_src_compile() {
430 + emake VARTEXFONTS="${T}/fonts"
431 +
432 + if tc-is-cross-compiler ; then
433 + pushd "${BUILD_DIR}"/tools >/dev/null || die
434 +
435 + # The build system sucks and doesn't handle this properly.
436 + # https://alioth.debian.org/tracker/index.php?func=detail&aid=314236&group_id=30186&atid=410366
437 + tc-export_build_env BUILD_CC
438 + ${BUILD_CC} ${BUILD_CPPFLAGS} ${BUILD_CFLAGS} ${BUILD_LDFLAGS} \
439 + -I. -I../include -I"${S}"/include \
440 + "${S}"/sanei/sanei_config.c "${S}"/sanei/sanei_constrain_value.c \
441 + "${S}"/sanei/sanei_init_debug.c "${S}"/tools/sane-desc.c -o sane-desc || die
442 + local dirs=( hal hotplug hotplug-ng udev )
443 + local targets=(
444 + hal/libsane.fdi
445 + hotplug/libsane.usermap
446 + hotplug-ng/libsane.db
447 + udev/libsane.rules
448 + )
449 + mkdir -p "${dirs[@]}" || die
450 + emake "${targets[@]}"
451 +
452 + popd >/dev/null || die
453 + fi
454 +
455 + if use usb ; then
456 + sed -i -e '/^$/d' \
457 + tools/hotplug/libsane.usermap || die
458 + fi
459 +}
460 +
461 +multilib_src_install() {
462 + emake INSTALL_LOCKPATH="" DESTDIR="${D}" install \
463 + docdir="${EPREFIX}"/usr/share/doc/${PF}
464 +
465 + if multilib_is_native_abi ; then
466 + if use usb ; then
467 + insinto /etc/hotplug/usb
468 + doins tools/hotplug/libsane.usermap
469 + fi
470 +
471 + insinto "/usr/share/pkgconfig"
472 + doins tools/sane-backends.pc
473 +
474 + # From Fedora and Arch, prevent permission conflicts
475 + # https://github.com/OpenPrinting/cups/issues/314
476 + # https://gitlab.com/sane-project/backends/-/issues/546
477 + #
478 + # Generate udev udev+hwdb, not needing scanner group
479 + install -vdm 755 "${ED}/$(get_udevdir)/rules.d/" || die
480 + tools/sane-desc -m udev+hwdb -s doc/descriptions/ > "${ED}/$(get_udevdir)/rules.d/65-${PN}.rules" || die
481 + tools/sane-desc -m udev+hwdb -s doc/descriptions-external/ >> "${ED}/$(get_udevdir)/rules.d/65-${PN}.rules" || die
482 + # generate udev hwdb
483 + install -vdm 755 "${ED}/$(get_udevdir)/hwdb.d/" || die
484 + tools/sane-desc -m hwdb -s doc/descriptions/ > "${ED}/$(get_udevdir)/hwdb.d/20-${PN}.hwdb"
485 + # NOTE: an empty new line is required between the two .desc collections
486 + printf "\n" >> "${ED}/$(get_udevdir)/hwdb.d/20-${PN}.hwdb" || die
487 + tools/sane-desc -m hwdb -s doc/descriptions-external/ >> "${ED}/$(get_udevdir)/hwdb.d/20-${PN}.hwdb" || die
488 + # udev rule for saned (SANE scanning daemon) to be able to write on usb port
489 + udev_newrules "${FILESDIR}/66-saned.rules-r1" 66-saned.rules
490 + fi
491 +}
492 +
493 +multilib_src_install_all() {
494 + dodir /etc/env.d
495 +
496 + if use systemd ; then
497 + systemd_newunit "${FILESDIR}"/saned_at.service-r1 "saned@.service"
498 + systemd_newunit "${FILESDIR}"/saned.socket saned.socket
499 + fi
500 +
501 + if use usb ; then
502 + exeinto /etc/hotplug/usb
503 + doexe tools/hotplug/libusbscanner
504 + newdoc tools/hotplug/README README.hotplug
505 + fi
506 +
507 + dodoc NEWS AUTHORS PROBLEMS README README.linux
508 + find "${ED}" -name '*.la' -delete || die
509 +
510 + if use xinetd ; then
511 + insinto /etc/xinetd.d
512 + doins "${FILESDIR}"/saned
513 + fi
514 +
515 + newinitd "${FILESDIR}"/saned.initd saned
516 + newconfd "${FILESDIR}"/saned.confd saned
517 +}
518 +
519 +pkg_postrm() {
520 + udev_reload
521 +}
522 +
523 +pkg_postinst() {
524 + udev_reload
525 +
526 + optfeature "Network scanner backend" media-gfx/sane-airscan
527 + optfeature "Epson-specific backend" media-gfx/iscan
528 + optfeature "HP-specific backend" net-print/hplip
529 +
530 + if use xinetd ; then
531 + elog "If you want remote clients to connect, edit"
532 + elog "/etc/sane.d/saned.conf and /etc/hosts.allow"
533 + fi
534 +}