|
4 | 4 | runCommand, |
5 | 5 | fetchzip, |
6 | 6 | fetchurl, |
| 7 | + fetchpatch, |
7 | 8 | fetchFromGitHub, |
8 | 9 | cmake, |
9 | 10 | jbig2dec, |
@@ -117,13 +118,43 @@ stdenv.mkDerivation rec { |
117 | 118 | cp ${k2pdfopt_src}/mupdf_mod/pdf-* ./source/pdf/ |
118 | 119 | ''; |
119 | 120 | }; |
| 121 | + # mupdf_patch no longer applies cleanly against mupdf 1.25.0 or later, due to a conflicting |
| 122 | + # hunk (mupdf_conflict) introduced in commit bd8d337939f36f55b96cb6984f5c7bbf2f488ce0 of mupdf. |
| 123 | + # This merge conflict can be resolved as desired by reverting mupdf_conflict, applying mupdf_patch, |
| 124 | + # and finally reapplying mupdf_conflict, with an increased fuzz factor (see mupdf_modded below). |
| 125 | + # TODO: remove workaround with conflicting hunk when mupdf in k2pdfopt is updated to 1.25.0 or later |
| 126 | + mupdf_conflict = |
| 127 | + hash: revert: |
| 128 | + fetchpatch { |
| 129 | + name = "mupdf-conflicting-hunk" + (lib.optionalString revert "-reverted") + ".patch"; |
| 130 | + url = "https://github.com/ArtifexSoftware/mupdf/commit/bd8d337939f36f55b96cb6984f5c7bbf2f488ce0.patch"; |
| 131 | + inherit hash revert; |
| 132 | + includes = [ "source/fitz/stext-device.c" ]; |
| 133 | + postFetch = '' |
| 134 | + filterdiff -#6 "$out" > "$tmpfile" |
| 135 | + mv "$tmpfile" "$out" |
| 136 | + ''; |
| 137 | + }; |
120 | 138 | mupdf_modded = mupdf.overrideAttrs ( |
121 | 139 | { |
122 | 140 | patches ? [ ], |
123 | 141 | ... |
124 | 142 | }: |
125 | 143 | { |
126 | | - patches = patches ++ [ mupdf_patch ]; |
| 144 | + # The fuzz factor is increased to automatically resolve the merge conflict. |
| 145 | + patchFlags = [ |
| 146 | + "-p1" |
| 147 | + "-F3" |
| 148 | + ]; |
| 149 | + # Reverting and reapplying the conflicting hunk is necessary, otherwise the result will be faulty. |
| 150 | + patches = patches ++ [ |
| 151 | + # revert conflicting hunk |
| 152 | + (mupdf_conflict "sha256-24tl9YBuZBYhb12yY3T0lKsA7NswfK0QcMYhb2IpepA=" true) |
| 153 | + # apply modifications |
| 154 | + mupdf_patch |
| 155 | + # reapply conflicting hunk |
| 156 | + (mupdf_conflict "sha256-bnBV7LyX1w/BXxBFF1bkA8x+/0I9Am33o8GiAeEKHYQ=" false) |
| 157 | + ]; |
127 | 158 | # This function is missing in font.c, see font-win32.c |
128 | 159 | postPatch = '' |
129 | 160 | echo "void pdf_install_load_system_font_funcs(fz_context *ctx) {}" >> source/fitz/font.c |
|
0 commit comments