From a608666d74f156819cecfabaf72290726d7964e6 Mon Sep 17 00:00:00 2001 From: Tobias Geerinckx-Rice Date: Mon, 18 Feb 2019 03:50:22 +0100 Subject: gnu: Add xsane. * gnu/packages/scanner.scm (xsane): New public variable. --- gnu/packages/scanner.scm | 88 ++++++++++++++++++++++++++++++++++++++++++++++++ 1 file changed, 88 insertions(+) (limited to 'gnu/packages/scanner.scm') 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 . (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 + ;; , 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+))) -- cgit v1.2.3 From 99b106022c8db67ee9bde847e1677e2dd0a39923 Mon Sep 17 00:00:00 2001 From: Tobias Geerinckx-Rice Date: Fri, 22 Nov 2019 22:16:32 +0100 Subject: gnu: xsane: Fix snprintf buffer length. * gnu/packages/scanner.scm (xsane)[source]: Add patch. * gnu/packages/patches/xsane-fix-snprintf-buffer-length.patch: New file. * gnu/local.mk (dist_patch_DATA): Add it. --- gnu/local.mk | 1 + .../patches/xsane-fix-snprintf-buffer-length.patch | 72 ++++++++++++++++++++++ gnu/packages/scanner.scm | 1 + 3 files changed, 74 insertions(+) create mode 100644 gnu/packages/patches/xsane-fix-snprintf-buffer-length.patch (limited to 'gnu/packages/scanner.scm') diff --git a/gnu/local.mk b/gnu/local.mk index ebb392494b..e6c6f57c3f 100644 --- a/gnu/local.mk +++ b/gnu/local.mk @@ -1466,6 +1466,7 @@ dist_patch_DATA = \ %D%/packages/patches/xinetd-CVE-2013-4342.patch \ %D%/packages/patches/xsane-fix-memory-leak.patch \ %D%/packages/patches/xsane-fix-pdf-floats.patch \ + %D%/packages/patches/xsane-fix-snprintf-buffer-length.patch \ %D%/packages/patches/xsane-support-ipv6.patch \ %D%/packages/patches/xsane-tighten-default-umask.patch diff --git a/gnu/packages/patches/xsane-fix-snprintf-buffer-length.patch b/gnu/packages/patches/xsane-fix-snprintf-buffer-length.patch new file mode 100644 index 0000000000..412e127f5a --- /dev/null +++ b/gnu/packages/patches/xsane-fix-snprintf-buffer-length.patch @@ -0,0 +1,72 @@ +From 893a5ce1f75e5eea7c8d383038ff92a150819c9c Mon Sep 17 00:00:00 2001 +From: Ralph Little +Date: Thu, 19 Sep 2019 22:02:33 -0700 +Subject: [PATCH] xsane-*-project.c - reduced snprintf format pad to silence + warning about too long constrant string for buffer. + +--- + src/xsane-email-project.c | 4 ++-- + src/xsane-fax-project.c | 4 ++-- + src/xsane-multipage-project.c | 2 +- + 3 files changed, 5 insertions(+), 5 deletions(-) + +diff --git a/src/xsane-email-project.c b/src/xsane-email-project.c +index f20cb12..ac93fc2 100644 +--- a/src/xsane-email-project.c ++++ b/src/xsane-email-project.c +@@ -896,7 +896,7 @@ static void xsane_email_project_update_project_status() + snprintf(filename, sizeof(filename), "%s/xsane-mail-list", preferences.email_project); + projectfile = fopen(filename, "r+b"); /* r+ = read and write, position = start of file */ + +- snprintf(buf, 32, "%s@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@", xsane.email_status); /* fill 32 characters status line */ ++ snprintf(buf, 33, "%s@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@", xsane.email_status); /* fill 32 characters status line */ + fprintf(projectfile, "%s\n", buf); /* first line is status of email */ + + fclose(projectfile); +@@ -936,7 +936,7 @@ void xsane_email_project_save() + { + char buf[TEXTBUFSIZE]; + +- snprintf(buf, 32, "%s@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@", xsane.email_status); /* fill 32 characters status line */ ++ snprintf(buf, 33, "%s@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@", xsane.email_status); /* fill 32 characters status line */ + fprintf(projectfile, "%s\n", buf); /* first line is status of email */ + gtk_progress_set_format_string(GTK_PROGRESS(xsane.project_progress_bar), _(xsane.email_status)); + xsane_progress_bar_set_fraction(GTK_PROGRESS_BAR(xsane.project_progress_bar), 0.0); +diff --git a/src/xsane-fax-project.c b/src/xsane-fax-project.c +index f263313..0c60a97 100644 +--- a/src/xsane-fax-project.c ++++ b/src/xsane-fax-project.c +@@ -452,7 +452,7 @@ static void xsane_fax_project_update_project_status() + snprintf(filename, sizeof(filename), "%s/xsane-fax-list", preferences.fax_project); + projectfile = fopen(filename, "r+b"); /* r+ = read and write, position = start of file */ + +- snprintf(buf, 32, "%s@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@", xsane.fax_status); /* fill 32 characters status line */ ++ snprintf(buf, 33, "%s@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@", xsane.fax_status); /* fill 32 characters status line */ + fprintf(projectfile, "%s\n", buf); /* first line is status of mail */ + + fclose(projectfile); +@@ -498,7 +498,7 @@ void xsane_fax_project_save() + { + char buf[TEXTBUFSIZE]; + +- snprintf(buf, 32, "%s@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@", xsane.fax_status); /* fill 32 characters status line */ ++ snprintf(buf, 33, "%s@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@", xsane.fax_status); /* fill 32 characters status line */ + fprintf(projectfile, "%s\n", buf); /* first line is status of mail */ + gtk_progress_set_format_string(GTK_PROGRESS(xsane.project_progress_bar), _(xsane.fax_status)); + xsane_progress_bar_set_fraction(GTK_PROGRESS_BAR(xsane.project_progress_bar), 0.0); +diff --git a/src/xsane-multipage-project.c b/src/xsane-multipage-project.c +index f23e5f8..9392e00 100644 +--- a/src/xsane-multipage-project.c ++++ b/src/xsane-multipage-project.c +@@ -522,7 +522,7 @@ void xsane_multipage_project_save() + { + char buf[TEXTBUFSIZE]; + +- snprintf(buf, 32, "%s@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@", xsane.multipage_status); /* fill 32 characters status line */ ++ snprintf(buf, 33, "%s@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@", xsane.multipage_status); /* fill 32 characters status line */ + fprintf(projectfile, "%s\n", buf); /* first line is status of multipage */ + gtk_progress_set_format_string(GTK_PROGRESS(xsane.project_progress_bar), _(xsane.multipage_status)); + xsane_progress_bar_set_fraction(GTK_PROGRESS_BAR(xsane.project_progress_bar), 0.0); +-- +2.23.0 + diff --git a/gnu/packages/scanner.scm b/gnu/packages/scanner.scm index aa58b5aa50..98f7fd203a 100644 --- a/gnu/packages/scanner.scm +++ b/gnu/packages/scanner.scm @@ -171,6 +171,7 @@ package contains the library and drivers."))) ;; commits upstream. A 1.0 release is planned. (patches (search-patches "xsane-fix-memory-leak.patch" "xsane-fix-pdf-floats.patch" + "xsane-fix-snprintf-buffer-length.patch" "xsane-support-ipv6.patch" "xsane-tighten-default-umask.patch")) (modules '((guix build utils))) -- cgit v1.2.3