···1{ stdenv, fetchzip, fetchurl, fetchpatch, cmake, pkgconfig
2-, zlib, libpng
3, enableGSL ? true, gsl
4, enableGhostScript ? true, ghostscript
5, enableMuPDF ? true, mupdf
···40 # Patches from previous 1.10a version in nixpkgs
41 patches = [
42 # Compatibility with new openjpeg
43- (fetchpatch {
44- name = "mupdf-1.9a-openjpeg-2.1.1.patch";
45- url = "https://git.archlinux.org/svntogit/community.git/plain/mupdf/trunk/0001-mupdf-openjpeg.patch?id=5a28ad0a8999a9234aa7848096041992cc988099";
46- sha256 = "1i24qr4xagyapx4bijjfksj4g3bxz8vs5c2mn61nkm29c63knp75";
47- })
4849 (fetchurl {
50 name = "CVE-2017-5896.patch";
···64 # Don't remove mujs because upstream version is incompatible
65 rm -rf thirdparty/{curl,freetype,glfw,harfbuzz,jbig2dec,jpeg,openjpeg,zlib}
66 '';
0000000067 });
68 leptonica_modded = leptonica.overrideAttrs (attrs: {
69 prePatch = ''
···1{ stdenv, fetchzip, fetchurl, fetchpatch, cmake, pkgconfig
2+, zlib, libpng, openjpeg
3, enableGSL ? true, gsl
4, enableGhostScript ? true, ghostscript
5, enableMuPDF ? true, mupdf
···40 # Patches from previous 1.10a version in nixpkgs
41 patches = [
42 # Compatibility with new openjpeg
43+ ./load-jpx.patch
00004445 (fetchurl {
46 name = "CVE-2017-5896.patch";
···60 # Don't remove mujs because upstream version is incompatible
61 rm -rf thirdparty/{curl,freetype,glfw,harfbuzz,jbig2dec,jpeg,openjpeg,zlib}
62 '';
63+ postPatch = let
64+ # OpenJPEG version is hardcoded in package source
65+ openJpegVersion = with stdenv;
66+ lib.concatStringsSep "." (lib.lists.take 2
67+ (lib.splitString "." (lib.getVersion openjpeg)));
68+ in ''
69+ sed -i "s/__OPENJPEG__VERSION__/${openJpegVersion}/" source/fitz/load-jpx.c
70+ '';
71 });
72 leptonica_modded = leptonica.overrideAttrs (attrs: {
73 prePatch = ''
+29
pkgs/applications/misc/k2pdfopt/load-jpx.patch
···00000000000000000000000000000
···1+--- a/source/fitz/load-jpx.c
2++++ b/source/fitz/load-jpx.c
3+@@ -484,12 +484,16 @@
4+ /* Without the definition of OPJ_STATIC, compilation fails on windows
5+ * due to the use of __stdcall. We believe it is required on some
6+ * linux toolchains too. */
7++#ifdef __cplusplus
8++extern "C"
9++{
10+ #define OPJ_STATIC
11+ #ifndef _MSC_VER
12+ #define OPJ_HAVE_STDINT_H
13+ #endif
14++#endif
15+16+-#include <openjpeg.h>
17++#include <openjpeg-__OPENJPEG__VERSION__/openjpeg.h>
18+19+ /* OpenJPEG does not provide a safe mechanism to intercept
20+ * allocations. In the latest version all allocations go
21+@@ -971,4 +975,8 @@
22+ fz_drop_pixmap(ctx, img);
23+ }
24+25++#ifdef __cplusplus
26++}
27++#endif
28++
29+ #endif /* HAVE_LURATECH */