Gentoo Archives: gentoo-commits

From: Pacho Ramos <pacho@g.o>
To: gentoo-commits@l.g.o
Subject: [gentoo-commits] repo/gentoo:master commit in: media-gfx/sane-backends/files/, media-gfx/sane-backends/
Date: Sat, 20 Oct 2018 16:37:05
Message-Id: 1540053331.b4a4aa9c04d755547aa82b881499fd7a6172bfc9.pacho@gentoo
1 commit: b4a4aa9c04d755547aa82b881499fd7a6172bfc9
2 Author: Pacho Ramos <pacho <AT> gentoo <DOT> org>
3 AuthorDate: Sat Oct 20 15:11:29 2018 +0000
4 Commit: Pacho Ramos <pacho <AT> gentoo <DOT> org>
5 CommitDate: Sat Oct 20 16:35:31 2018 +0000
6 URL: https://gitweb.gentoo.org/repo/gentoo.git/commit/?id=b4a4aa9c
7
8 media-gfx/sane-backends: Fixes from Fedora and Debian...
9
10 They fix an important bug with Samsung devices not being properly recognized
11 and noises in some devices.
12
13 We also start disabling locking as all the other distributions and stop
14 trying to randomly generate extra documentation files that are not really
15 needed and add a lot of hidden dependencies tend to break in several ways.
16
17 Closes: https://bugs.gentoo.org/636202
18 Closes: https://bugs.gentoo.org/653300
19 Closes: https://bugs.gentoo.org/668232
20 Closes: https://bugs.gentoo.org/668350
21 Signed-off-by: Pacho Ramos <pacho <AT> gentoo.org>
22 Package-Manager: Portage-2.3.51, Repoman-2.3.11
23
24 .../sane-backends-1.0.27-revert-samsung.patch | 406 +++++++++++++++++++++
25 ...ne-backends-1.0.27-uninitialized-variable.patch | 25 ++
26 .../sane-backends/sane-backends-1.0.27-r2.ebuild | 344 +++++++++++++++++
27 3 files changed, 775 insertions(+)
28
29 diff --git a/media-gfx/sane-backends/files/sane-backends-1.0.27-revert-samsung.patch b/media-gfx/sane-backends/files/sane-backends-1.0.27-revert-samsung.patch
30 new file mode 100644
31 index 00000000000..af3e141a010
32 --- /dev/null
33 +++ b/media-gfx/sane-backends/files/sane-backends-1.0.27-revert-samsung.patch
34 @@ -0,0 +1,406 @@
35 +From 9b13d4c18b2424eaed02b72a928e9607921ec265 Mon Sep 17 00:00:00 2001
36 +From: Bernard Cafarelli <bernard.cafarelli@×××××.com>
37 +Date: Tue, 17 Apr 2018 22:43:15 +0200
38 +Subject: [PATCH] Revert "Color scanning for Samsung models, which support JPEG
39 + Lossy compression."
40 +
41 +This reverts commit 926bfade544de4a4fd5f1a8082b85a97e2443770, leaving
42 +the new IDs in.
43 +As tracked in #315876, this breaks scanning with multiple Samsung scanners
44 +
45 +Conflicts:
46 + backend/xerox_mfp.c
47 + backend/xerox_mfp.h
48 + doc/descriptions/xerox_mfp.desc
49 +---
50 + backend/Makefile.am | 2 +-
51 + backend/Makefile.in | 7 +-
52 + backend/xerox_mfp.c | 193 +-------------------------------
53 + backend/xerox_mfp.h | 5 -
54 + doc/descriptions/xerox_mfp.desc | 10 +-
55 + 5 files changed, 14 insertions(+), 203 deletions(-)
56 +
57 +diff --git a/backend/Makefile.am b/backend/Makefile.am
58 +index 18695a4a..3225b133 100644
59 +--- a/backend/Makefile.am
60 ++++ b/backend/Makefile.am
61 +@@ -1086,7 +1086,7 @@ libxerox_mfp_la_CPPFLAGS = $(AM_CPPFLAGS) -DBACKEND_NAME=xerox_mfp
62 + nodist_libsane_xerox_mfp_la_SOURCES = xerox_mfp-s.c
63 + libsane_xerox_mfp_la_CPPFLAGS = $(AM_CPPFLAGS) -DBACKEND_NAME=xerox_mfp
64 + libsane_xerox_mfp_la_LDFLAGS = $(DIST_SANELIBS_LDFLAGS)
65 +-libsane_xerox_mfp_la_LIBADD = $(COMMON_LIBS) libxerox_mfp.la ../sanei/sanei_init_debug.lo ../sanei/sanei_constrain_value.lo ../sanei/sanei_config.lo sane_strstatus.lo @SANEI_SANEI_JPEG_LO@ $(JPEG_LIBS) ../sanei/sanei_usb.lo ../sanei/sanei_tcp.lo $(MATH_LIB) $(SOCKET_LIBS) $(USB_LIBS) $(RESMGR_LIBS)
66 ++libsane_xerox_mfp_la_LIBADD = $(COMMON_LIBS) libxerox_mfp.la ../sanei/sanei_init_debug.lo ../sanei/sanei_constrain_value.lo ../sanei/sanei_config.lo sane_strstatus.lo ../sanei/sanei_usb.lo ../sanei/sanei_tcp.lo $(MATH_LIB) $(SOCKET_LIBS) $(USB_LIBS) $(RESMGR_LIBS)
67 + EXTRA_DIST += xerox_mfp.conf.in
68 +
69 + libdll_preload_la_SOURCES = dll.c
70 +diff --git a/backend/Makefile.in b/backend/Makefile.in
71 +index d1dca4a2..2643bb77 100644
72 +--- a/backend/Makefile.in
73 ++++ b/backend/Makefile.in
74 +@@ -1430,10 +1430,9 @@ libsane_v4l_la_LINK = $(LIBTOOL) $(AM_V_lt) --tag=CC \
75 + libsane_xerox_mfp_la_DEPENDENCIES = $(COMMON_LIBS) libxerox_mfp.la \
76 + ../sanei/sanei_init_debug.lo ../sanei/sanei_constrain_value.lo \
77 + ../sanei/sanei_config.lo sane_strstatus.lo \
78 +- $(am__DEPENDENCIES_1) ../sanei/sanei_usb.lo \
79 +- ../sanei/sanei_tcp.lo $(am__DEPENDENCIES_1) \
80 ++ ../sanei/sanei_usb.lo ../sanei/sanei_tcp.lo \
81 + $(am__DEPENDENCIES_1) $(am__DEPENDENCIES_1) \
82 +- $(am__DEPENDENCIES_1)
83 ++ $(am__DEPENDENCIES_1) $(am__DEPENDENCIES_1)
84 + nodist_libsane_xerox_mfp_la_OBJECTS = \
85 + libsane_xerox_mfp_la-xerox_mfp-s.lo
86 + libsane_xerox_mfp_la_OBJECTS = $(nodist_libsane_xerox_mfp_la_OBJECTS)
87 +@@ -2754,7 +2753,7 @@ libxerox_mfp_la_CPPFLAGS = $(AM_CPPFLAGS) -DBACKEND_NAME=xerox_mfp
88 + nodist_libsane_xerox_mfp_la_SOURCES = xerox_mfp-s.c
89 + libsane_xerox_mfp_la_CPPFLAGS = $(AM_CPPFLAGS) -DBACKEND_NAME=xerox_mfp
90 + libsane_xerox_mfp_la_LDFLAGS = $(DIST_SANELIBS_LDFLAGS)
91 +-libsane_xerox_mfp_la_LIBADD = $(COMMON_LIBS) libxerox_mfp.la ../sanei/sanei_init_debug.lo ../sanei/sanei_constrain_value.lo ../sanei/sanei_config.lo sane_strstatus.lo @SANEI_SANEI_JPEG_LO@ $(JPEG_LIBS) ../sanei/sanei_usb.lo ../sanei/sanei_tcp.lo $(MATH_LIB) $(SOCKET_LIBS) $(USB_LIBS) $(RESMGR_LIBS)
92 ++libsane_xerox_mfp_la_LIBADD = $(COMMON_LIBS) libxerox_mfp.la ../sanei/sanei_init_debug.lo ../sanei/sanei_constrain_value.lo ../sanei/sanei_config.lo sane_strstatus.lo ../sanei/sanei_usb.lo ../sanei/sanei_tcp.lo $(MATH_LIB) $(SOCKET_LIBS) $(USB_LIBS) $(RESMGR_LIBS)
93 + libdll_preload_la_SOURCES = dll.c
94 + libdll_preload_la_CPPFLAGS = $(AM_CPPFLAGS) -DBACKEND_NAME=dll -DENABLE_PRELOAD
95 + libdll_la_SOURCES = dll.c
96 +diff --git a/backend/xerox_mfp.c b/backend/xerox_mfp.c
97 +index 8b8c8956..d37a6237 100644
98 +--- a/backend/xerox_mfp.c
99 ++++ b/backend/xerox_mfp.c
100 +@@ -33,9 +33,6 @@
101 + #include "../include/sane/sanei_usb.h"
102 + #include "../include/sane/sanei_config.h"
103 + #include "../include/sane/sanei_backend.h"
104 +-#ifdef HAVE_LIBJPEG
105 +-#include <jpeglib.h>
106 +-#endif
107 + #include "xerox_mfp.h"
108 +
109 + #define BACKEND_BUILD 13
110 +@@ -93,128 +90,6 @@ static char *str_cmd(int cmd)
111 + }
112 +
113 + #define MAX_DUMP 70
114 +-const char *encTmpFileName = "/tmp/stmp_enc.tmp";
115 +-
116 +-static int decompress(struct device __sane_unused__ *dev,
117 +- const char __sane_unused__ *infilename)
118 +-{
119 +-#ifdef HAVE_LIBJPEG
120 +- int rc;
121 +- int row_stride, width, height, pixel_size;
122 +- struct jpeg_decompress_struct cinfo;
123 +- struct jpeg_error_mgr jerr;
124 +- unsigned long bmp_size = 0;
125 +- FILE *pInfile = NULL;
126 +- JSAMPARRAY buffer;
127 +-
128 +- if ((pInfile = fopen(infilename, "rb")) == NULL) {
129 +- fprintf(stderr, "can't open %s\n", infilename);
130 +- return -1;
131 +- }
132 +-
133 +- cinfo.err = jpeg_std_error(&jerr);
134 +-
135 +- jpeg_create_decompress(&cinfo);
136 +-
137 +- jpeg_stdio_src(&cinfo, pInfile);
138 +-
139 +- rc = jpeg_read_header(&cinfo, TRUE);
140 +- if (rc != 1) {
141 +- jpeg_destroy_decompress(&cinfo);
142 +- fclose(pInfile);
143 +- return -1;
144 +- }
145 +-
146 +- jpeg_start_decompress(&cinfo);
147 +-
148 +- width = cinfo.output_width;
149 +- height = cinfo.output_height;
150 +- pixel_size = cinfo.output_components;
151 +- bmp_size = width * height * pixel_size;
152 +- dev->decDataSize = bmp_size;
153 +-
154 +- row_stride = width * pixel_size;
155 +-
156 +- buffer = (*cinfo.mem->alloc_sarray)
157 +- ((j_common_ptr) &cinfo, JPOOL_IMAGE, row_stride, 1);
158 +-
159 +- while (cinfo.output_scanline < cinfo.output_height) {
160 +- buffer[0] = dev->decData + \
161 +- (cinfo.output_scanline) * row_stride;
162 +- jpeg_read_scanlines(&cinfo, buffer, 1);
163 +- }
164 +- jpeg_finish_decompress(&cinfo);
165 +- jpeg_destroy_decompress(&cinfo);
166 +- fclose(pInfile);
167 +- return 0;
168 +-#else
169 +- return -1;
170 +-#endif
171 +-}
172 +-
173 +-static int copy_decompress_data(struct device *dev, unsigned char *pDest, int maxlen, int *destLen)
174 +-{
175 +- int data_size = 0;
176 +- size_t result = 0, retVal = 0;
177 +-
178 +-
179 +- if (0 == dev->decDataSize) {
180 +- *destLen = 0;
181 +- return retVal;
182 +- }
183 +- data_size = dev->decDataSize - dev->currentDecDataIndex;
184 +- if (data_size > maxlen) {
185 +- data_size = maxlen;
186 +- }
187 +- memcpy(pDest, dev->decData+dev->currentDecDataIndex, data_size);
188 +- result = data_size;
189 +- *destLen = result;
190 +- dev->currentDecDataIndex += result;
191 +- retVal = result;
192 +-
193 +- if (dev->decDataSize == dev->currentDecDataIndex) {
194 +- dev->currentDecDataIndex = 0;
195 +- dev->decDataSize = 0;
196 +- }
197 +-
198 +- return retVal;
199 +-}
200 +-
201 +-static int decompress_tempfile(struct device *dev)
202 +-{
203 +- decompress(dev, encTmpFileName);
204 +- remove(encTmpFileName);
205 +- return 0;
206 +-}
207 +-
208 +-static int dump_to_tmp_file(struct device *dev)
209 +-{
210 +- unsigned char *pSrc = dev->data;
211 +- int srcLen = dev->datalen;
212 +- FILE *pInfile;
213 +- if ((pInfile = fopen(encTmpFileName, "a")) == NULL) {
214 +- fprintf(stderr, "can't open %s\n", encTmpFileName);
215 +- return 0;
216 +- }
217 +-
218 +- fwrite(pSrc, 1, srcLen, pInfile);
219 +- fclose(pInfile);
220 +- return srcLen;
221 +-}
222 +-
223 +-static int isSupportedDevice(struct device __sane_unused__ *dev)
224 +-{
225 +-#ifdef HAVE_LIBJPEG
226 +- /* Checking device which supports JPEG Lossy compression for color scanning*/
227 +- if (dev->compressionTypes & (1 << 6))
228 +- return 1;
229 +- else
230 +- return 0;
231 +-#else
232 +- return 0;
233 +-#endif
234 +-}
235 +-
236 + static void dbg_dump(struct device *dev)
237 + {
238 + int i;
239 +@@ -639,11 +514,9 @@ static void set_parameters(struct device *dev)
240 + dev->para.pixels_per_line = dev->win_width / px_to_len;
241 + dev->para.bytes_per_line = dev->para.pixels_per_line;
242 +
243 +- if (!isSupportedDevice(dev)) {
244 + #if BETTER_BASEDPI
245 +- px_to_len = 1213.9 / dev->val[OPT_RESOLUTION].w;
246 ++ px_to_len = 1213.9 / dev->val[OPT_RESOLUTION].w;
247 + #endif
248 +- }
249 + dev->para.lines = dev->win_len / px_to_len;
250 + if (dev->composition == MODE_LINEART ||
251 + dev->composition == MODE_HALFTONE) {
252 +@@ -765,13 +638,6 @@ static int dev_set_window(struct device *dev)
253 + cmd[0x11] = (SANE_Byte)floor(dev->win_off_y);
254 + cmd[0x12] = (SANE_Byte)((dev->win_off_y - floor(dev->win_off_y)) * 100);
255 + cmd[0x13] = dev->composition;
256 +- /* Set to JPEG Lossy Compression, if mode is color (only for supported model)...
257 +- * else go with Uncompressed (For backard compatibility with old models )*/
258 +- if (dev->composition == MODE_RGB24) {
259 +- if (isSupportedDevice(dev)) {
260 +- cmd[0x14] = 0x6;
261 +- }
262 +- }
263 + cmd[0x16] = dev->threshold;
264 + cmd[0x17] = dev->doc_source;
265 +
266 +@@ -843,7 +709,6 @@ dev_inquiry(struct device *dev)
267 + dev->res[0x3e] << 8 |
268 + dev->res[0x3f];
269 + dev->line_order = dev->res[0x31];
270 +- dev->compressionTypes = dev->res[0x32];
271 + dev->doc_loaded = (dev->res[0x35] == 0x02) &&
272 + (dev->res[0x26] & 0x03);
273 +
274 +@@ -942,10 +807,6 @@ dev_free(struct device *dev)
275 + free(UNCONST(dev->sane.type));
276 + if (dev->data)
277 + free(dev->data);
278 +- if (dev->decData) {
279 +- free(dev->decData);
280 +- dev->decData = NULL;
281 +- }
282 + memset(dev, 0, sizeof(*dev));
283 + free(dev);
284 + }
285 +@@ -1283,19 +1144,6 @@ sane_read(SANE_Handle h, SANE_Byte *buf, SANE_Int maxlen, SANE_Int *lenp)
286 + /* if there is no data to read or output from buffer */
287 + if (!dev->blocklen && dev->datalen <= PADDING_SIZE) {
288 +
289 +- /* copying uncompressed data */
290 +- if (dev->composition == MODE_RGB24 &&
291 +- isSupportedDevice(dev) &&
292 +- dev->decDataSize > 0) {
293 +- int diff = dev->total_img_size - dev->total_out_size;
294 +- int bufLen = (diff < maxlen) ? diff : maxlen;
295 +- if (0 < diff &&
296 +- 0 < copy_decompress_data(dev, buf, bufLen, lenp)) {
297 +- dev->total_out_size += *lenp;
298 +- return SANE_STATUS_GOOD;
299 +- }
300 +- }
301 +-
302 + /* and we don't need to acquire next block */
303 + if (dev->final_block) {
304 + int slack = dev->total_img_size - dev->total_out_size;
305 +@@ -1311,10 +1159,7 @@ sane_read(SANE_Handle h, SANE_Byte *buf, SANE_Int maxlen, SANE_Int *lenp)
306 + /* this will never happen */
307 + DBG(1, "image overflow %d bytes\n", dev->total_img_size - dev->total_out_size);
308 + }
309 +- if (isSupportedDevice(dev) &&
310 +- dev->composition == MODE_RGB24) {
311 +- remove(encTmpFileName);
312 +- }
313 ++
314 + /* that's all */
315 + dev_stop(dev);
316 + return SANE_STATUS_EOF;
317 +@@ -1365,18 +1210,9 @@ sane_read(SANE_Handle h, SANE_Byte *buf, SANE_Int maxlen, SANE_Int *lenp)
318 +
319 + if (buf && lenp) { /* read mode */
320 + /* copy will do minimal of valid data */
321 +- if (dev->para.format == SANE_FRAME_RGB && dev->line_order) {
322 +- if (isSupportedDevice(dev)) {
323 +- clrlen = dump_to_tmp_file(dev);
324 +- /* decompress after reading entire block data*/
325 +- if (0 == dev->blocklen) {
326 +- decompress_tempfile(dev);
327 +- }
328 +- copy_decompress_data(dev, buf, maxlen, &olen);
329 +- } else {
330 +- clrlen = copy_mix_bands_trim(dev, buf, maxlen, &olen);
331 +- }
332 +- } else
333 ++ if (dev->para.format == SANE_FRAME_RGB && dev->line_order)
334 ++ clrlen = copy_mix_bands_trim(dev, buf, maxlen, &olen);
335 ++ else
336 + clrlen = copy_plain_trim(dev, buf, maxlen, &olen);
337 +
338 + dev->datalen -= clrlen;
339 +@@ -1455,9 +1291,6 @@ sane_start(SANE_Handle h)
340 + if (!dev->data && !(dev->data = malloc(DATASIZE)))
341 + return ret_cancel(dev, SANE_STATUS_NO_MEM);
342 +
343 +- if (!dev->decData && !(dev->decData = malloc(POST_DATASIZE)))
344 +- return ret_cancel(dev, SANE_STATUS_NO_MEM);
345 +-
346 + if (!dev_acquire(dev))
347 + return dev->state;
348 +
349 +@@ -1479,22 +1312,6 @@ sane_start(SANE_Handle h)
350 +
351 + dev->total_img_size = dev->para.bytes_per_line * dev->para.lines;
352 +
353 +- if (isSupportedDevice(dev) &&
354 +- dev->composition == MODE_RGB24) {
355 +- int fd;
356 +- remove(encTmpFileName);
357 +-
358 +- /* Precreate temporary file in exclusive mode. */
359 +- fd = open(encTmpFileName, O_CREAT|O_EXCL, 0600);
360 +- if (fd == -1) {
361 +- DBG(3, "%s: %p, can't create temporary file %s: %s\n", __func__,
362 +- (void *)dev, encTmpFileName, strerror(errno));
363 +- return ret_cancel(dev, SANE_STATUS_ACCESS_DENIED);
364 +- }
365 +- close(fd);
366 +- }
367 +- dev->currentDecDataIndex = 0;
368 +-
369 + return SANE_STATUS_GOOD;
370 + }
371 +
372 +diff --git a/backend/xerox_mfp.h b/backend/xerox_mfp.h
373 +index 3d93f06d..ea89dda2 100644
374 +--- a/backend/xerox_mfp.h
375 ++++ b/backend/xerox_mfp.h
376 +@@ -74,10 +74,6 @@ struct device {
377 + #define DATATAIL(dev) ((dev->dataoff + dev->datalen) & DATAMASK)
378 + #define DATAROOM(dev) dataroom(dev)
379 +
380 +-#define POST_DATASIZE 0xFFFFFF
381 +- SANE_Byte *decData;
382 +- int decDataSize;
383 +- int currentDecDataIndex;
384 + /* data from CMD_INQUIRY: */
385 + int resolutions; /* supported resolution bitmask */
386 + int compositions; /* supported image compositions bitmask */
387 +@@ -102,7 +98,6 @@ struct device {
388 + int composition; /* MODE_ */
389 + int doc_source; /* document source */
390 + int threshold; /* brightness */
391 +- int compressionTypes;
392 +
393 + /* CMD_READ data. It is per block only, image could be in many blocks */
394 + int blocklen; /* image data block len (padding incl.) */
395 +diff --git a/doc/descriptions/xerox_mfp.desc b/doc/descriptions/xerox_mfp.desc
396 +index d21a6be6..67253b38 100644
397 +--- a/doc/descriptions/xerox_mfp.desc
398 ++++ b/doc/descriptions/xerox_mfp.desc
399 +@@ -320,7 +320,7 @@
400 +
401 + :model "SCX-3405W"
402 + :interface "Ethernet"
403 +-:status :good
404 ++:status :basic
405 +
406 + :model "SCX-3400"
407 + :interface "USB"
408 +@@ -335,17 +335,17 @@
409 + :model "SCX-4729FD"
410 + :interface "USB"
411 + :usbid "0x04e8" "0x3453"
412 +-:status :good
413 ++:status :basic
414 +
415 + :model "CLX-6260"
416 + :interface "USB"
417 + :usbid "0x04e8" "0x3455"
418 +-:status :good
419 ++:status :minimal
420 +
421 + :model "CLX-3300 Series"
422 + :interface "USB"
423 + :usbid "0x04e8" "0x3456"
424 +-:status :good
425 ++:status :basic
426 +
427 + :model "SCX-470x"
428 + :interface "USB"
429 +@@ -355,7 +355,7 @@
430 + :model "CLX-4190"
431 + :interface "USB"
432 + :usbid "0x04e8" "0x345a"
433 +-:status :good
434 ++:status :minimal
435 +
436 + :model "SCX-4650 4x21S Series"
437 + :interface "USB"
438 +--
439 +2.17.0
440 +
441
442 diff --git a/media-gfx/sane-backends/files/sane-backends-1.0.27-uninitialized-variable.patch b/media-gfx/sane-backends/files/sane-backends-1.0.27-uninitialized-variable.patch
443 new file mode 100644
444 index 00000000000..0311975c0ce
445 --- /dev/null
446 +++ b/media-gfx/sane-backends/files/sane-backends-1.0.27-uninitialized-variable.patch
447 @@ -0,0 +1,25 @@
448 +From dd61ef1cc84299781e382b9258d97102cee192b4 Mon Sep 17 00:00:00 2001
449 +From: Olaf Meeuwissen <paddy-hack@××××××××××.org>
450 +Date: Thu, 3 Aug 2017 18:50:05 +0900
451 +Subject: [PATCH] genesys: Fix use of uninitialized variable
452 +
453 +See https://bugs.debian.org/cgi-bin/bugreport.cgi?bug=869673
454 +---
455 + backend/genesys.c | 1 +
456 + 1 file changed, 1 insertion(+)
457 +
458 +diff --git a/backend/genesys.c b/backend/genesys.c
459 +index 1c1bbf4..0b644c4 100644
460 +--- a/backend/genesys.c
461 ++++ b/backend/genesys.c
462 +@@ -6237,6 +6237,7 @@ attach (SANE_String_Const devname, Genesys_Device ** devp, SANE_Bool may_wait)
463 + dev->model = genesys_usb_device_list[i].model;
464 + dev->vendorId = genesys_usb_device_list[i].vendor;
465 + dev->productId = genesys_usb_device_list[i].product;
466 ++ dev->usb_mode = 0; /* i.e. unset */
467 + dev->already_initialized = SANE_FALSE;
468 +
469 + DBG (DBG_info, "attach: found %s flatbed scanner %s at %s\n",
470 +--
471 +2.1.4
472 +
473
474 diff --git a/media-gfx/sane-backends/sane-backends-1.0.27-r2.ebuild b/media-gfx/sane-backends/sane-backends-1.0.27-r2.ebuild
475 new file mode 100644
476 index 00000000000..4ce3733007d
477 --- /dev/null
478 +++ b/media-gfx/sane-backends/sane-backends-1.0.27-r2.ebuild
479 @@ -0,0 +1,344 @@
480 +# Copyright 1999-2018 Gentoo Authors
481 +# Distributed under the terms of the GNU General Public License v2
482 +
483 +EAPI=7
484 +inherit flag-o-matic multilib-minimal systemd toolchain-funcs udev user
485 +
486 +# gphoto and v4l are handled by their usual USE flags.
487 +# The pint backend was disabled because I could not get it to compile.
488 +IUSE_SANE_BACKENDS="
489 + abaton
490 + agfafocus
491 + apple
492 + artec
493 + artec_eplus48u
494 + as6e
495 + avision
496 + bh
497 + canon
498 + canon630u
499 + canon_dr
500 + canon_pp
501 + cardscan
502 + coolscan
503 + coolscan2
504 + coolscan3
505 + dc210
506 + dc240
507 + dc25
508 + dell1600n_net
509 + dmc
510 + epjitsu
511 + epson
512 + epson2
513 + fujitsu
514 + genesys
515 + gt68xx
516 + hp
517 + hp3500
518 + hp3900
519 + hp4200
520 + hp5400
521 + hp5590
522 + hpljm1005
523 + hpsj5s
524 + hs2p
525 + ibm
526 + kodak
527 + kodakaio
528 + kvs1025
529 + kvs20xx
530 + kvs40xx
531 + leo
532 + lexmark
533 + ma1509
534 + magicolor
535 + matsushita
536 + microtek
537 + microtek2
538 + mustek
539 + mustek_pp
540 + mustek_usb
541 + mustek_usb2
542 + nec
543 + net
544 + niash
545 + p5
546 + pie
547 + pixma
548 + plustek
549 + plustek_pp
550 + pnm
551 + qcam
552 + ricoh
553 + rts8891
554 + s9036
555 + sceptre
556 + sharp
557 + sm3600
558 + sm3840
559 + snapscan
560 + sp15c
561 + st400
562 + stv680
563 + tamarack
564 + teco1
565 + teco2
566 + teco3
567 + test
568 + u12
569 + umax
570 + umax1220u
571 + umax_pp
572 + xerox_mfp"
573 +
574 +IUSE="gphoto2 ipv6 snmp systemd threads usb v4l xinetd zeroconf"
575 +
576 +for backend in ${IUSE_SANE_BACKENDS}; do
577 + case ${backend} in
578 + # Disable backends that require parallel ports as no one has those anymore.
579 + canon_pp|hpsj5s|mustek_pp|\
580 + pnm)
581 + IUSE+=" -sane_backends_${backend}"
582 + ;;
583 + mustek_usb2|kvs40xx)
584 + IUSE+=" sane_backends_${backend}"
585 + ;;
586 + *)
587 + IUSE+=" +sane_backends_${backend}"
588 + esac
589 +done
590 +
591 +REQUIRED_USE="
592 + sane_backends_mustek_usb2? ( threads )
593 + sane_backends_kvs40xx? ( threads )
594 +"
595 +
596 +DESCRIPTION="Scanner Access Now Easy - Backends"
597 +HOMEPAGE="http://www.sane-project.org/"
598 +MY_P="${P}"
599 +FRS_ID="4224"
600 +SRC_URI="https://alioth.debian.org/frs/download.php/file/${FRS_ID}/${P}.tar.gz"
601 +
602 +LICENSE="GPL-2 public-domain"
603 +SLOT="0"
604 +KEYWORDS="~alpha ~amd64 ~arm ~arm64 ~hppa ~ia64 ~m68k ~mips ~ppc ~ppc64 ~s390 ~sh ~sparc ~x86 ~x86-fbsd ~amd64-linux ~x86-linux"
605 +
606 +RDEPEND="
607 + sane_backends_dc210? ( >=virtual/jpeg-0-r2:0=[${MULTILIB_USEDEP}] )
608 + sane_backends_dc240? ( >=virtual/jpeg-0-r2:0=[${MULTILIB_USEDEP}] )
609 + sane_backends_dell1600n_net? (
610 + >=virtual/jpeg-0-r2:0=[${MULTILIB_USEDEP}]
611 + >=media-libs/tiff-3.9.7-r1:0=[${MULTILIB_USEDEP}]
612 + )
613 + sane_backends_canon_pp? ( >=sys-libs/libieee1284-0.2.11-r3[${MULTILIB_USEDEP}] )
614 + sane_backends_hpsj5s? ( >=sys-libs/libieee1284-0.2.11-r3[${MULTILIB_USEDEP}] )
615 + sane_backends_mustek_pp? ( >=sys-libs/libieee1284-0.2.11-r3[${MULTILIB_USEDEP}] )
616 + usb? ( >=virtual/libusb-1-r1:1=[${MULTILIB_USEDEP}] )
617 + gphoto2? (
618 + >=media-libs/libgphoto2-2.5.3.1:=[${MULTILIB_USEDEP}]
619 + >=virtual/jpeg-0-r2:0=[${MULTILIB_USEDEP}]
620 + )
621 + v4l? ( >=media-libs/libv4l-0.9.5[${MULTILIB_USEDEP}] )
622 + xinetd? ( sys-apps/xinetd )
623 + snmp? ( net-analyzer/net-snmp )
624 + systemd? ( sys-apps/systemd:0= )
625 + zeroconf? ( >=net-dns/avahi-0.6.31-r2[${MULTILIB_USEDEP}] )
626 +"
627 +
628 +DEPEND="${RDEPEND}
629 + v4l? ( sys-kernel/linux-headers )
630 + >=sys-devel/gettext-0.18.1
631 + >=virtual/pkgconfig-0-r1[${MULTILIB_USEDEP}]
632 +"
633 +
634 +MULTILIB_CHOST_TOOLS=(
635 + /usr/bin/sane-config
636 +)
637 +
638 +pkg_setup() {
639 + enewgroup scanner
640 + enewuser saned -1 -1 -1 scanner
641 +}
642 +
643 +src_prepare() {
644 + default
645 +
646 + cat >> backend/dll.conf.in <<-EOF
647 + # Add support for the HP-specific backend. Needs net-print/hplip installed.
648 + hpaio
649 + # Add support for the Epson-specific backend. Needs media-gfx/iscan installed.
650 + epkowa
651 + EOF
652 +
653 + eapply "${FILESDIR}"/${PN}-1.0.24-saned_pidfile_location.patch
654 + eapply "${FILESDIR}"/${PN}-1.0.27-disable-usb-tests.patch
655 +
656 + # From Arch
657 + eapply "${FILESDIR}"/${PN}-1.0.27-network.patch
658 +
659 + # From Fedora
660 + # Fix https://bugs.gentoo.org/635348
661 + eapply "${FILESDIR}"/${PN}-1.0.27-canon-lide-100.patch
662 + # Fix https://bugs.gentoo.org/653300
663 + eapply "${FILESDIR}"/${PN}-1.0.27-revert-samsung.patch
664 +
665 + # From Debian
666 + eapply "${FILESDIR}"/${PN}-1.0.27-uninitialized-variable.patch
667 +
668 + # Fix for "make check". Upstream sometimes forgets to update this.
669 + local ver=$(./configure --version | awk '{print $NF; exit 0}')
670 + sed -i \
671 + -e "/by sane-desc 3.5 from sane-backends/s:sane-backends .*:sane-backends ${ver}:" \
672 + testsuite/tools/data/html* || die
673 +}
674 +
675 +src_configure() {
676 + append-flags -fno-strict-aliasing # From Fedora
677 +
678 + # if LINGUAS is set, just use the listed and supported localizations.
679 + if [[ ${LINGUAS+set} == "set" ]]; then
680 + mkdir -p po || die
681 + strip-linguas -u po
682 + printf '%s\n' ${LINGUAS} > po/LINGUAS
683 + fi
684 +
685 + multilib-minimal_src_configure
686 +}
687 +
688 +multilib_src_configure() {
689 + # the blank is intended - an empty string would result in building ALL backends.
690 + local BACKENDS=" "
691 +
692 + use gphoto2 && BACKENDS="gphoto2"
693 + use v4l && BACKENDS="${BACKENDS} v4l"
694 + for backend in ${IUSE_SANE_BACKENDS}; do
695 + if use "sane_backends_${backend}" && [ ${backend} != pnm ]; then
696 + BACKENDS="${BACKENDS} ${backend}"
697 + fi
698 + done
699 +
700 + local myconf=(
701 + $(use_with usb)
702 + $(multilib_native_use_with snmp)
703 + )
704 +
705 + # you can only enable this backend, not disable it...
706 + if use sane_backends_pnm; then
707 + myconf+=( --enable-pnm-backend )
708 + fi
709 + if use sane_backends_mustek_pp; then
710 + myconf+=( --enable-parport-directio )
711 + fi
712 + if ! { use sane_backends_canon_pp || use sane_backends_hpsj5s || use sane_backends_mustek_pp; }; then
713 + myconf+=( sane_cv_use_libieee1284=no )
714 + fi
715 +
716 + # relative path must be used for tests to work properly
717 + ECONF_SOURCE=${S} \
718 + SANEI_JPEG="sanei_jpeg.o" SANEI_JPEG_LO="sanei_jpeg.lo" \
719 + BACKENDS="${BACKENDS}" \
720 + # All distributions pass --disable-locking because /var/lock/sane/ would be a world-writable directory
721 + # --without-api-spec to not automagically depend on tons of stuff
722 + # that break in many ways, bug #636202, #668232, #668350
723 + # People can refer to the "Programmer's Documentation" at http://www.sane-project.org/docs.html
724 + econf \
725 + --disable-locking \
726 + --without-api-spec \
727 + $(use_with gphoto2) \
728 + $(multilib_native_use_with systemd) \
729 + $(use_with v4l) \
730 + $(use_enable ipv6) \
731 + $(use_enable threads pthread) \
732 + $(use_enable zeroconf avahi) \
733 + "${myconf[@]}"
734 +}
735 +
736 +multilib_src_compile() {
737 + emake VARTEXFONTS="${T}/fonts"
738 +
739 + if tc-is-cross-compiler; then
740 + pushd "${BUILD_DIR}"/tools >/dev/null || die
741 +
742 + # The build system sucks and doesn't handle this properly.
743 + # https://alioth.debian.org/tracker/index.php?func=detail&aid=314236&group_id=30186&atid=410366
744 + tc-export_build_env BUILD_CC
745 + ${BUILD_CC} ${BUILD_CPPFLAGS} ${BUILD_CFLAGS} ${BUILD_LDFLAGS} \
746 + -I. -I../include -I"${S}"/include \
747 + "${S}"/sanei/sanei_config.c "${S}"/sanei/sanei_constrain_value.c \
748 + "${S}"/sanei/sanei_init_debug.c "${S}"/tools/sane-desc.c -o sane-desc || die
749 + local dirs=( hal hotplug hotplug-ng udev )
750 + local targets=(
751 + hal/libsane.fdi
752 + hotplug/libsane.usermap
753 + hotplug-ng/libsane.db
754 + udev/libsane.rules
755 + )
756 + mkdir -p "${dirs[@]}" || die
757 + emake "${targets[@]}"
758 +
759 + popd >/dev/null
760 + fi
761 +
762 + if use usb; then
763 + sed -i -e '/^$/d' \
764 + tools/hotplug/libsane.usermap || die
765 + fi
766 +}
767 +
768 +multilib_src_install() {
769 + emake INSTALL_LOCKPATH="" DESTDIR="${D}" install \
770 + docdir="${EPREFIX}"/usr/share/doc/${PF}
771 +
772 + if multilib_is_native_abi; then
773 + if use usb; then
774 + insinto /etc/hotplug/usb
775 + doins tools/hotplug/libsane.usermap
776 + fi
777 +
778 + udev_newrules tools/udev/libsane.rules 41-libsane.rules
779 + insinto "/usr/share/pkgconfig"
780 + doins tools/sane-backends.pc
781 + fi
782 +}
783 +
784 +multilib_src_install_all() {
785 + keepdir /var/lib/lock/sane
786 + fowners root:scanner /var/lib/lock/sane
787 + fperms g+w /var/lib/lock/sane
788 + dodir /etc/env.d
789 +
790 + if use systemd; then
791 + systemd_newunit "${FILESDIR}"/saned_at.service "saned@.service"
792 + systemd_newunit "${FILESDIR}"/saned.socket saned.socket
793 + fi
794 +
795 + if use usb; then
796 + exeinto /etc/hotplug/usb
797 + doexe tools/hotplug/libusbscanner
798 + newdoc tools/hotplug/README README.hotplug
799 + fi
800 +
801 + dodoc NEWS AUTHORS ChangeLog* PROBLEMS README README.linux
802 + find "${D}" -name '*.la' -delete || die
803 +
804 + if use xinetd; then
805 + insinto /etc/xinetd.d
806 + doins "${FILESDIR}"/saned
807 + fi
808 +
809 + newinitd "${FILESDIR}"/saned.initd saned
810 + newconfd "${FILESDIR}"/saned.confd saned
811 +}
812 +
813 +pkg_postinst() {
814 + if use xinetd; then
815 + elog "If you want remote clients to connect, edit"
816 + elog "/etc/sane.d/saned.conf and /etc/hosts.allow"
817 + fi
818 +
819 + if ! use systemd; then
820 + elog "If you are using a USB scanner, add all users who want"
821 + elog "to access your scanner to the \"scanner\" group."
822 + fi
823 +}