From 9a579e14dd7536bf4cf554c065615810defd72d8 Mon Sep 17 00:00:00 2001 From: Florian Brandes Date: Tue, 21 Nov 2023 01:10:25 +0100 Subject: [PATCH 1/4] gscan2pdf: fix build failures Due to the removal of tools like `tiff2pdf` from `libtiff` many tests fail or cause a timeout. This commit fixes the dependency to `libtiff_4_5`. fixes #268406 Signed-off-by: Florian Brandes --- pkgs/applications/graphics/gscan2pdf/default.nix | 9 ++++++--- 1 file changed, 6 insertions(+), 3 deletions(-) diff --git a/pkgs/applications/graphics/gscan2pdf/default.nix b/pkgs/applications/graphics/gscan2pdf/default.nix index 78f25a0df3ad..7726f9e3e36a 100644 --- a/pkgs/applications/graphics/gscan2pdf/default.nix +++ b/pkgs/applications/graphics/gscan2pdf/default.nix @@ -2,7 +2,7 @@ # libs librsvg, sane-backends, sane-frontends, # runtime dependencies - imagemagick, libtiff, djvulibre, poppler_utils, ghostscript, unpaper, pdftk, + imagemagick, libtiff_4_5, djvulibre, poppler_utils, ghostscript, unpaper, pdftk, # test dependencies xvfb-run, liberation_ttf, file, tesseract }: @@ -71,7 +71,7 @@ perlPackages.buildPerlPackage rec { wrapProgram "$out/bin/gscan2pdf" \ --prefix PATH : "${sane-backends}/bin" \ --prefix PATH : "${imagemagick}/bin" \ - --prefix PATH : "${libtiff}/bin" \ + --prefix PATH : "${libtiff_4_5}/bin" \ --prefix PATH : "${djvulibre}/bin" \ --prefix PATH : "${poppler_utils}/bin" \ --prefix PATH : "${ghostscript}/bin" \ @@ -87,7 +87,10 @@ perlPackages.buildPerlPackage rec { nativeCheckInputs = [ imagemagick - libtiff + # Needs older libtiff version, because it stopped packageing tools like + # tiff2pdf and others in version 4.6. These tools are necessary for gscan2pdf. + # See commit f57a4b0ac1b954eec0c8def2a99e2a464ac6ff7a for in-depth explanation. + libtiff_4_5 djvulibre poppler_utils ghostscript From fe3094b0dcc167494891090d49f367c59ea4c6e9 Mon Sep 17 00:00:00 2001 From: Florian Brandes Date: Thu, 23 Nov 2023 12:00:28 +0100 Subject: [PATCH 2/4] gscan2pdf: re-add previously removed test Signed-off-by: Florian Brandes --- pkgs/applications/graphics/gscan2pdf/default.nix | 6 ------ 1 file changed, 6 deletions(-) diff --git a/pkgs/applications/graphics/gscan2pdf/default.nix b/pkgs/applications/graphics/gscan2pdf/default.nix index 7726f9e3e36a..98713a4fa4d2 100644 --- a/pkgs/applications/graphics/gscan2pdf/default.nix +++ b/pkgs/applications/graphics/gscan2pdf/default.nix @@ -133,12 +133,6 @@ perlPackages.buildPerlPackage rec { # Non-zero wait status: 139 rm t/0601_Dialog_Scan.t - # Disable a test which failed due to convert returning an exit value of 1 - # convert: negative or zero image size `/build/KL5kTVnNCi/YfgegFM53e.pnm' @ error/resize.c/ResizeImage/3743. - # *** unhandled exception in callback: - # *** "convert" unexpectedly returned exit value 1 at t/357_unpaper_rtl.t line 63. - rm t/357_unpaper_rtl.t - xvfb-run -s '-screen 0 800x600x24' \ make test ''; From 1e2704927aeb052ede5cedde4b6eb20d424af5d2 Mon Sep 17 00:00:00 2001 From: Florian Brandes Date: Wed, 22 Nov 2023 10:48:04 +0100 Subject: [PATCH 3/4] gscan2pdf: add patch to remove warnings during test see https://sourceforge.net/p/gscan2pdf/bugs/421 Signed-off-by: Florian Brandes --- pkgs/applications/graphics/gscan2pdf/default.nix | 11 ++++++++++- 1 file changed, 10 insertions(+), 1 deletion(-) diff --git a/pkgs/applications/graphics/gscan2pdf/default.nix b/pkgs/applications/graphics/gscan2pdf/default.nix index 98713a4fa4d2..296d63cd6785 100644 --- a/pkgs/applications/graphics/gscan2pdf/default.nix +++ b/pkgs/applications/graphics/gscan2pdf/default.nix @@ -1,4 +1,4 @@ -{ lib, fetchurl, perlPackages, wrapGAppsHook, +{ lib, fetchurl, perlPackages, wrapGAppsHook, fetchpatch, # libs librsvg, sane-backends, sane-frontends, # runtime dependencies @@ -17,6 +17,15 @@ perlPackages.buildPerlPackage rec { hash = "sha256-NGz6DUa7TdChpgwmD9pcGdvYr3R+Ft3jPPSJpybCW4Q="; }; + patches = [ + # fixes warnings during tests. See https://sourceforge.net/p/gscan2pdf/bugs/421 + (fetchpatch { + name = "0001-Remove-given-and-when-keywords-and-operator.patch"; + url = "https://sourceforge.net/p/gscan2pdf/bugs/_discuss/thread/602a7cedfd/1ea4/attachment/0001-Remove-given-and-when-keywords-and-operator.patch"; + hash = "sha256-JtrHUkfEKnDhWfEVdIdYVlr5b/xChTzsrrPmruLaJ5M="; + }) + ]; + nativeBuildInputs = [ wrapGAppsHook ]; buildInputs = From d54a7a6019d30ecee3cbd363a99297b7f2bd00d7 Mon Sep 17 00:00:00 2001 From: Florian Brandes Date: Thu, 23 Nov 2023 11:54:10 +0100 Subject: [PATCH 4/4] gscan2pdf: patch from upstream with utf8 filenames see: https://sourceforge.net/p/gscan2pdf/bugs/400 Signed-off-by: Florian Brandes --- .../graphics/gscan2pdf/default.nix | 2 ++ .../graphics/gscan2pdf/image-utf8-fix.patch | 32 +++++++++++++++++++ 2 files changed, 34 insertions(+) create mode 100644 pkgs/applications/graphics/gscan2pdf/image-utf8-fix.patch diff --git a/pkgs/applications/graphics/gscan2pdf/default.nix b/pkgs/applications/graphics/gscan2pdf/default.nix index 296d63cd6785..0acc934a7fd9 100644 --- a/pkgs/applications/graphics/gscan2pdf/default.nix +++ b/pkgs/applications/graphics/gscan2pdf/default.nix @@ -24,6 +24,8 @@ perlPackages.buildPerlPackage rec { url = "https://sourceforge.net/p/gscan2pdf/bugs/_discuss/thread/602a7cedfd/1ea4/attachment/0001-Remove-given-and-when-keywords-and-operator.patch"; hash = "sha256-JtrHUkfEKnDhWfEVdIdYVlr5b/xChTzsrrPmruLaJ5M="; }) + # fixes an error with utf8 file names. See https://sourceforge.net/p/gscan2pdf/bugs/400 + ./image-utf8-fix.patch ]; nativeBuildInputs = [ wrapGAppsHook ]; diff --git a/pkgs/applications/graphics/gscan2pdf/image-utf8-fix.patch b/pkgs/applications/graphics/gscan2pdf/image-utf8-fix.patch new file mode 100644 index 000000000000..fa1d03e0309a --- /dev/null +++ b/pkgs/applications/graphics/gscan2pdf/image-utf8-fix.patch @@ -0,0 +1,32 @@ +diff --git a/bin/gscan2pdf b/bin/gscan2pdf +index e075b0f2..ff124522 100755 +--- a/bin/gscan2pdf ++++ b/bin/gscan2pdf +@@ -3434,9 +3434,11 @@ sub save_image { + if ( @{$list_of_pages} > 1 ) { + my $w = length scalar @{$list_of_pages}; + for ( 1 .. @{$list_of_pages} ) { ++ _utf8_on($filename); + my $current_filename = + sprintf "${filename}_%0${w}d.$SETTING{'image type'}", + $_; ++ _utf8_off($filename); + if ( -f $current_filename ) { + my $text = sprintf __('This operation would overwrite %s'), + $current_filename; +@@ -3450,11 +3452,15 @@ sub save_image { + return; + } + } ++ _utf8_on($filename); + $filename = "${filename}_%0${w}d.$SETTING{'image type'}"; ++ _utf8_off($filename); + } + else { + if ( $filename !~ /[.]$SETTING{'image type'}$/ixsm ) { ++ _utf8_on($filename); + $filename = "$filename.$SETTING{'image type'}"; ++ _utf8_off($filename); + return if ( file_exists( $file_chooser, $filename ) ); + } + return if ( file_writable( $file_chooser, $filename ) );