git.iko.soy/typeable/nixpkgs
on master help sign in
Merge pull request #32415 from clefru/k2pdf-master

k2pdfopt: Patch openjpeg version into mupdf as in #31852.

commit08b7cbdbedcd69e1dc04d11d57f1fc20c53ab6a3 authorJörg Thalheim <Mic92@users.noreply.github.com> dateThu 7 Dec 2017, 16:46 (9 years ago) parenta02691abbb5cee
2 files changed+39−6
pkgs/applications/misc/k2pdfopt/default.nix+10−6 pkgs/applications/misc/k2pdfopt/load-jpx.patch+29
pkgs/applications/misc/k2pdfopt/default.nix+10−6
@@ -1,5 +1,5 @@
11{ stdenv, fetchzip, fetchurl, fetchpatch, cmake, pkgconfig
2−, zlib, libpng
2+, zlib, libpng, openjpeg
33, enableGSL ? true, gsl
44, enableGhostScript ? true, ghostscript
55, enableMuPDF ? true, mupdf
@@ -40,11 +40,7 @@ stdenv.mkDerivation rec {
4040 # Patches from previous 1.10a version in nixpkgs
4141 patches = [
4242 # 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− })
43+ ./load-jpx.patch
4844
4945 (fetchurl {
5046 name = "CVE-2017-5896.patch";
@@ -64,6 +60,14 @@ stdenv.mkDerivation rec {
6460 # Don't remove mujs because upstream version is incompatible
6561 rm -rf thirdparty/{curl,freetype,glfw,harfbuzz,jbig2dec,jpeg,openjpeg,zlib}
6662 '';
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+ '';
6771 });
6872 leptonica_modded = leptonica.overrideAttrs (attrs: {
6973 prePatch = ''
pkgs/applications/misc/k2pdfopt/load-jpx.patchnew file+29
@@ -0,0 +1,29 @@
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 */