Merge pull request #268836 from gador/gscan2pdf-libtiff-fix

gscan2pdf: fix build failure, add patches
This commit is contained in:
Emily Trau 2023-11-29 17:55:24 +11:00 committed by GitHub
commit 4204f4fa74
No known key found for this signature in database
GPG key ID: 4AEE18F83AFDEB23
2 changed files with 50 additions and 10 deletions

View file

@ -1,8 +1,8 @@
{ lib, fetchurl, perlPackages, wrapGAppsHook,
{ lib, fetchurl, perlPackages, wrapGAppsHook, fetchpatch,
# 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 }:
@ -17,6 +17,17 @@ 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=";
})
# fixes an error with utf8 file names. See https://sourceforge.net/p/gscan2pdf/bugs/400
./image-utf8-fix.patch
];
nativeBuildInputs = [ wrapGAppsHook ];
buildInputs =
@ -71,7 +82,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 +98,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
@ -130,12 +144,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
'';

View file

@ -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 ) );