summaryrefslogtreecommitdiff
path: root/gnu
diff options
context:
space:
mode:
authorTobias Geerinckx-Rice <me@tobias.gr>2019-02-18 03:50:22 +0100
committerTobias Geerinckx-Rice <me@tobias.gr>2019-11-22 22:01:40 +0100
commita608666d74f156819cecfabaf72290726d7964e6 (patch)
treee316155a19e26e83846478c1aab920341a5b5dcd /gnu
parentee4db149c29b6d0fe6bcab552f163bbbe5b09738 (diff)
downloadguix-patches-a608666d74f156819cecfabaf72290726d7964e6.tar
guix-patches-a608666d74f156819cecfabaf72290726d7964e6.tar.gz
gnu: Add xsane.
* gnu/packages/scanner.scm (xsane): New public variable.
Diffstat (limited to 'gnu')
-rw-r--r--gnu/packages/patches/xsane-fix-memory-leak.patch34
-rw-r--r--gnu/packages/patches/xsane-fix-pdf-floats.patch85
-rw-r--r--gnu/packages/patches/xsane-support-ipv6.patch153
-rw-r--r--gnu/packages/patches/xsane-tighten-default-umask.patch36
-rw-r--r--gnu/packages/scanner.scm88
5 files changed, 396 insertions, 0 deletions
diff --git a/gnu/packages/patches/xsane-fix-memory-leak.patch b/gnu/packages/patches/xsane-fix-memory-leak.patch
new file mode 100644
index 0000000000..4e03e57e13
--- /dev/null
+++ b/gnu/packages/patches/xsane-fix-memory-leak.patch
@@ -0,0 +1,34 @@
+From bbd54510f0297afa2d1a81927db060cb0b791f14 Mon Sep 17 00:00:00 2001
+From: Ralph Little <littlesincanada@yahoo.co.uk>
+Date: Sun, 1 Sep 2019 17:34:19 -0700
+Subject: [PATCH] Apply opensuse upstream patch xsane_memory_leak
+
+Removes completely redundant memory allocation.
+---
+ src/xsane-batch-scan.c | 3 ---
+ 1 file changed, 3 deletions(-)
+
+diff --git a/src/xsane-batch-scan.c b/src/xsane-batch-scan.c
+index 90cc0e0..e77caca 100644
+--- a/src/xsane-batch-scan.c
++++ b/src/xsane-batch-scan.c
+@@ -680,7 +680,6 @@ static GtkWidget *xsane_batch_scan_create_list_entry(Batch_Scan_Parameters *para
+ GtkWidget *list_item;
+ GtkWidget *hbox;
+ int size = 120;
+- char *data;
+
+ list_item = gtk_list_item_new();
+
+@@ -688,8 +687,6 @@ static GtkWidget *xsane_batch_scan_create_list_entry(Batch_Scan_Parameters *para
+ gtk_container_add(GTK_CONTAINER(list_item), hbox);
+ gtk_widget_show(hbox);
+
+- data = calloc(size, size);
+-
+ parameters->gtk_preview = gtk_preview_new(GTK_PREVIEW_COLOR);
+ gtk_preview_size(GTK_PREVIEW(parameters->gtk_preview), size, size);
+ gtk_box_pack_start(GTK_BOX(hbox), parameters->gtk_preview, FALSE, FALSE, 0);
+--
+2.22.0
+
diff --git a/gnu/packages/patches/xsane-fix-pdf-floats.patch b/gnu/packages/patches/xsane-fix-pdf-floats.patch
new file mode 100644
index 0000000000..5f26fa140b
--- /dev/null
+++ b/gnu/packages/patches/xsane-fix-pdf-floats.patch
@@ -0,0 +1,85 @@
+From c126eea11c4ee39cbe9c0c76f920626b618b6ee9 Mon Sep 17 00:00:00 2001
+From: Ralph Little <littlesincanada@yahoo.co.uk>
+Date: Sun, 1 Sep 2019 17:03:44 -0700
+Subject: [PATCH] Apply debian upstream patch 0135-fix_pdf_floats
+
+Original patch commentary:
+
+Description: Fix floats in PDF and PostScript
+ Set LC_NUMERIC to POSIX before printing floats when building
+ PostScript or PDF output.
+Author: Julien BLACHE <jblache@debian.org>
+Forwarded: yes
+
+------------
+Looks like float printing format is affected by the current locale.
+Ensures that we always get POSIX formatting of floats.
+---
+ src/xsane-save.c | 19 +++++++++++++++++++
+ 1 file changed, 19 insertions(+)
+
+diff --git a/src/xsane-save.c b/src/xsane-save.c
+index f14df05..63550cc 100644
+--- a/src/xsane-save.c
++++ b/src/xsane-save.c
+@@ -26,6 +26,8 @@
+ #include "xsane-back-gtk.h"
+ #include "xsane-front-gtk.h"
+ #include "xsane-save.h"
++#include <locale.h>
++#include <string.h>
+ #include <time.h>
+ #include <sys/wait.h>
+
+@@ -2425,6 +2427,7 @@ static void xsane_save_ps_create_image_header(FILE *outfile,
+ int flatedecode)
+ {
+ int depth;
++ char *save_locale;
+
+ depth = image_info->depth;
+
+@@ -2442,8 +2445,15 @@ static void xsane_save_ps_create_image_header(FILE *outfile,
+
+ fprintf(outfile, "%d rotate\n", degree);
+ fprintf(outfile, "%d %d translate\n", position_left, position_bottom);
++
++ save_locale = strdup(setlocale(LC_NUMERIC, NULL));
++ setlocale(LC_NUMERIC, "POSIX");
++
+ fprintf(outfile, "%f %f scale\n", width, height);
+
++ setlocale(LC_NUMERIC, save_locale);
++ free(save_locale);
++
+ fprintf(outfile, "<<\n");
+ fprintf(outfile, " /ImageType 1\n");
+ fprintf(outfile, " /Width %d\n", image_info->image_width);
+@@ -3921,6 +3931,7 @@ static void xsane_save_pdf_create_page_header(FILE *outfile, struct pdf_xref *xr
+ int position_left, position_bottom, box_left, box_bottom, box_right, box_top, depth;
+ int left, bottom;
+ float rad;
++ char *save_locale;
+
+ DBG(DBG_proc, "xsane_save_pdf_create_page_header\n");
+
+@@ -4035,8 +4046,16 @@ static void xsane_save_pdf_create_page_header(FILE *outfile, struct pdf_xref *xr
+
+ fprintf(outfile, "q\n");
+ fprintf(outfile, "1 0 0 1 %d %d cm\n", position_left, position_bottom); /* translate */
++
++ save_locale = strdup(setlocale(LC_NUMERIC, NULL));
++ setlocale(LC_NUMERIC, "POSIX");
++
+ fprintf(outfile, "%f %f -%f %f 0 0 cm\n", cos(rad), sin(rad), sin(rad), cos(rad)); /* rotate */
+ fprintf(outfile, "%f 0 0 %f 0 0 cm\n", width, height); /* scale */
++
++ setlocale(LC_NUMERIC, save_locale);
++ free(save_locale);
++
+ fprintf(outfile, "BI\n");
+ fprintf(outfile, " /W %d\n", image_info->image_width);
+ fprintf(outfile, " /H %d\n", image_info->image_height);
+--
+2.22.0
+
diff --git a/gnu/packages/patches/xsane-support-ipv6.patch b/gnu/packages/patches/xsane-support-ipv6.patch
new file mode 100644
index 0000000000..4e3bb87a1a
--- /dev/null
+++ b/gnu/packages/patches/xsane-support-ipv6.patch
@@ -0,0 +1,153 @@
+From 62d9c172f258769e3a7540fe710e013bb39a704f Mon Sep 17 00:00:00 2001
+From: Ralph Little <littlesincanada@yahoo.co.uk>
+Date: Sat, 7 Sep 2019 12:39:45 -0700
+Subject: [PATCH] Apply opensuse upstream patch 004-ipv6-support
+
+Appears to be related to this:
+https://bugzilla.redhat.com/show_bug.cgi?id=198422
+
+-----
+Changes email socket connection code to use more IP version agnostic
+calls. It appears to only be used by the scan email option and
+originally comes from the RedHat IPv6 awareness program mentioned
+in the bug report.
+
+In practice, I'm not sure how practical the implementation for emailing
+scans in xsane is as it does not look to support encryption, pretty
+much a given in today's world.
+---
+ src/xsane-save.c | 96 +++++++++++++++++++++++++++++++-----------------
+ 1 file changed, 62 insertions(+), 34 deletions(-)
+
+diff --git a/src/xsane-save.c b/src/xsane-save.c
+index 63550cc..ff3c459 100644
+--- a/src/xsane-save.c
++++ b/src/xsane-save.c
+@@ -31,6 +31,8 @@
+ #include <time.h>
+ #include <sys/wait.h>
+
++#include <glib.h>
++
+ /* the following test is always false */
+ #ifdef _native_WIN32
+ # include <winsock.h>
+@@ -7540,55 +7542,81 @@ void write_email_attach_file(int fd_socket, char *boundary, FILE *infile, char *
+ /* returns fd_socket if sucessfull, < 0 when error occured */
+ int open_socket(char *server, int port)
+ {
+- int fd_socket;
+- struct sockaddr_in sin;
+- struct hostent *he;
++ int fd_socket, e;
++
++ struct addrinfo *ai_list, *ai;
++ struct addrinfo hints;
++ gchar *port_s;
++ gint connected;
++
++ memset(&hints, '\0', sizeof(hints));
++ hints.ai_flags = AI_ADDRCONFIG;
++ hints.ai_socktype = SOCK_STREAM;
++
++ port_s = g_strdup_printf("%d", port);
++ e = getaddrinfo(server, port_s, &hints, &ai_list);
++ g_free(port_s);
+
+- he = gethostbyname(server);
+- if (!he)
++ if (e != 0)
+ {
+- DBG(DBG_error, "open_socket: Could not get hostname of \"%s\"\n", server);
++ DBG(DBG_error, "open_socket: Could not lookup \"%s\"\n", server);
+ return -1;
+ }
+- else
++
++ connected = 0;
++ for (ai = ai_list; ai != NULL && !connected; ai = ai->ai_next)
+ {
+- DBG(DBG_info, "open_socket: connecting to \"%s\" = %d.%d.%d.%d\n",
+- he->h_name,
+- (unsigned char) he->h_addr_list[0][0],
+- (unsigned char) he->h_addr_list[0][1],
+- (unsigned char) he->h_addr_list[0][2],
+- (unsigned char) he->h_addr_list[0][3]);
+- }
++ gchar hostname[NI_MAXHOST];
++ gchar hostaddr[NI_MAXHOST];
++
++ /* If all else fails */
++ strncpy(hostname, "(unknown name)", NI_MAXHOST-1);
++ strncpy(hostaddr, "(unknown address)", NI_MAXHOST-1);
++
++ /* Determine canonical name and IPv4/IPv6 address */
++ (void) getnameinfo(ai->ai_addr, ai->ai_addrlen, hostname, sizeof(hostname),
++ NULL, 0, 0);
++ (void) getnameinfo(ai->ai_addr, ai->ai_addrlen, hostaddr, sizeof(hostaddr),
++ NULL, 0, NI_NUMERICHOST);
++
++ DBG(DBG_info, "open_socket: connecting to \"%s\" (\"%s\"): %s\n",
++ server, hostname, hostaddr);
+
+- if (he->h_addrtype != AF_INET)
+- {
+- DBG(DBG_error, "open_socket: Unknown address family: %d\n", he->h_addrtype);
+- return -1;
+- }
++ if ((ai->ai_family != AF_INET) && (ai->ai_family != AF_INET6))
++ {
++ DBG(DBG_error, "open_socket: Unknown address family: %d\n", ai->ai_family);
++ continue;
++ }
+
+- fd_socket = socket(AF_INET, SOCK_STREAM, 0);
++ fd_socket = socket(ai->ai_family, ai->ai_socktype, ai->ai_protocol);
+
+- if (fd_socket < 0)
+- {
+- DBG(DBG_error, "open_socket: Could not create socket: %s\n", strerror(errno));
+- return -1;
+- }
++ if (fd_socket < 0)
++ {
++ DBG(DBG_error, "open_socket: Could not create socket: %s\n", strerror(errno));
++ continue;
++ }
+
+-/* setsockopt (dev->ctl, level, TCP_NODELAY, &on, sizeof (on)); */
++ /* setsockopt (dev->ctl, level, TCP_NODELAY, &on, sizeof (on)); */
+
+- sin.sin_port = htons(port);
+- sin.sin_family = AF_INET;
+- memcpy(&sin.sin_addr, he->h_addr_list[0], he->h_length);
++ if (connect(fd_socket, ai->ai_addr, ai->ai_addrlen) != 0)
++ {
++ DBG(DBG_error, "open_socket: Could not connect with port %d of socket: %s\n", port, strerror(errno));
++ continue;
++ }
++
++ /* All went well */
++ connected = 1;
++ }
+
+- if (connect(fd_socket, &sin, sizeof(sin)))
++ if (!connected)
+ {
+- DBG(DBG_error, "open_socket: Could not connect with port %d of socket: %s\n", ntohs(sin.sin_port), strerror(errno));
+- return -1;
++ DBG(DBG_info, "open_socket: Could not connect to any address");
++ return -1;
+ }
+
+- DBG(DBG_info, "open_socket: Connected with port %d\n", ntohs(sin.sin_port));
++ DBG(DBG_info, "open_socket: Connected with port %d\n", port);
+
+- return fd_socket;
++ return fd_socket;
+ }
+
+ /* ---------------------------------------------------------------------------------------------------------------------- */
+--
+2.22.0
+
diff --git a/gnu/packages/patches/xsane-tighten-default-umask.patch b/gnu/packages/patches/xsane-tighten-default-umask.patch
new file mode 100644
index 0000000000..5ee5fdfd37
--- /dev/null
+++ b/gnu/packages/patches/xsane-tighten-default-umask.patch
@@ -0,0 +1,36 @@
+From 5dc1e301a165709c60c435f00ec9bb6d7d5f21f3 Mon Sep 17 00:00:00 2001
+From: Ralph Little <littlesincanada@yahoo.co.uk>
+Date: Tue, 27 Aug 2019 21:40:02 -0700
+Subject: [PATCH] Apply debian upstream patch 0160-fix_tighten_default_umask
+
+Original patch commentary:
+
+Description: Change default XSane umask from 0007 to 0077
+ A default umask of 0007 can be mildly insecure in a multiuser environment,
+ so tighten things up a bit and go with 0077 instead.
+Author: Adrien Thebo
+Bug-Debian: http://bugs.debian.org/592972
+Bug-Ubuntu: https://bugs.launchpad.net/ubuntu/+source/xsane/+bug/611950
+
+----
+As above.
+---
+ src/xsane.h | 2 +-
+ 1 file changed, 1 insertion(+), 1 deletion(-)
+
+diff --git a/src/xsane.h b/src/xsane.h
+index 67f06d4..fa04418 100644
+--- a/src/xsane.h
++++ b/src/xsane.h
+@@ -104,7 +104,7 @@
+ #define XSANE_DEBUG_ENVIRONMENT "XSANE_DEBUG"
+
+ #define XSANE_PROGRESS_BAR_MIN_DELTA_PERCENT 0.025
+-#define XSANE_DEFAULT_UMASK 0007
++#define XSANE_DEFAULT_UMASK 0077
+ #define XSANE_HOLD_TIME 200
+ #define XSANE_CONTINUOUS_HOLD_TIME 10
+ #define XSANE_DEFAULT_DEVICE "SANE_DEFAULT_DEVICE"
+--
+2.22.0
+
diff --git a/gnu/packages/scanner.scm b/gnu/packages/scanner.scm
index b371cf3105..aa58b5aa50 100644
--- a/gnu/packages/scanner.scm
+++ b/gnu/packages/scanner.scm
@@ -21,11 +21,16 @@
;;; along with GNU Guix. If not, see <http://www.gnu.org/licenses/>.
(define-module (gnu packages scanner)
+ #:use-module (gnu packages)
+ #:use-module (gnu packages freedesktop)
+ #:use-module (gnu packages ghostscript)
+ #:use-module (gnu packages gtk)
#:use-module (gnu packages image)
#:use-module (gnu packages libusb)
#:use-module (gnu packages pkg-config)
#:use-module (guix build-system gnu)
#:use-module (guix download)
+ #:use-module (guix git-download)
#:use-module ((guix licenses)
#:prefix licence:)
#:use-module (guix packages)
@@ -148,3 +153,86 @@ package contains the library, but no drivers.")
proving access to any raster image scanner hardware (flatbed scanner,
hand-held scanner, video- and still-cameras, frame-grabbers, etc.). The
package contains the library and drivers.")))
+
+(define-public xsane
+ (package
+ (name "xsane")
+ (version "0.999")
+ (source
+ (origin
+ (method git-fetch)
+ (uri (git-reference
+ (url "https://gitlab.com/sane-project/frontend/xsane.git")
+ (commit version)))
+ (file-name (git-file-name name version))
+ (sha256
+ (base32 "08zvxj7i1s88ckrsqldmsrikc3g62a6p3s3i5b5x4krcfpi3vs50"))
+ ;; Apply some important-looking fixes. There are many more unreleased
+ ;; commits upstream. A 1.0 release is planned.
+ (patches (search-patches "xsane-fix-memory-leak.patch"
+ "xsane-fix-pdf-floats.patch"
+ "xsane-support-ipv6.patch"
+ "xsane-tighten-default-umask.patch"))
+ (modules '((guix build utils)))
+ (snippet
+ '(begin
+ ;; Remove ancient bundled lprng code under a non-free licence. See
+ ;; <https://trisquel.info/en/issues/10713>, which solves the problem
+ ;; by replacing it with a newer (free) copy. We let the build fall
+ ;; back to the system version instead, which appears to work fine.
+ (delete-file "lib/snprintf.c")
+ (substitute* "lib/Makefile.in"
+ (("snprintf\\.o ") ""))
+ #t))))
+ (build-system gnu-build-system)
+ (arguments
+ `(#:make-flags
+ (list (string-append "xsanedocdir=" (assoc-ref %outputs "out")
+ "/share/doc/" ,name "-" ,version))
+ #:tests? #f ; no test suite
+ #:phases
+ (modify-phases %standard-phases
+ (add-after 'unpack 'patch-invalid-dereference
+ ;; Fix the following compilation error with libpng:
+ ;; xsane-save.c: In function ‘xsane_save_png’:
+ ;; xsane-save.c:4913:21: error: dereferencing pointer to
+ ;; incomplete type ‘png_struct {aka struct png_struct_def}’
+ ;; if (setjmp(png_ptr->jmpbuf))
+ ;; ^
+ (lambda _
+ (substitute* "src/xsane-save.c"
+ (("png_ptr->jmpbuf") "png_jmpbuf(png_ptr)"))
+ #t))
+ (add-after 'unpack 'use-sane-help-browser
+ (lambda _
+ (substitute* "src/xsane.h"
+ (("netscape") (which "xdg-open")))
+ #t))
+ (add-after 'install 'delete-empty-/sbin
+ (lambda* (#:key outputs #:allow-other-keys)
+ (let ((out (assoc-ref outputs "out")))
+ (rmdir (string-append out "/sbin"))
+ #t))))))
+ (native-inputs
+ `(("pkg-config" ,pkg-config)))
+ (inputs
+ `(("gtk+" ,gtk+-2)
+ ("lcms" ,lcms)
+ ("libjpeg" ,libjpeg)
+ ("libtiff" ,libtiff)
+ ("sane-backends" ,sane-backends)
+
+ ;; To open the manual from the Help menu.
+ ("xdg-utils" ,xdg-utils)))
+ (home-page "https://gitlab.com/sane-project/frontend/xsane")
+ (synopsis "Featureful graphical interface for document and image scanners")
+ (description
+ "XSane is a graphical interface for controlling a scanner and acquiring
+images from it. You can photocopy multi-page documents and save, fax, print,
+or e-mail your scanned images. It is highly configurable and exposes all
+device settings, letting you fine-tune the final result. It can also be used
+as a GIMP plugin to acquire images directly from a scanner.
+
+XSane talks to scanners through the @acronym{SANE, Scanner Access Now Easy}
+back-end library, which supports almost all existing scanners.")
+ (license licence:gpl2+)))