k2pdfopt: fix build against mupdf >= 1.25.0 (#397905)
This commit is contained in:
@@ -4,6 +4,7 @@
|
||||
runCommand,
|
||||
fetchzip,
|
||||
fetchurl,
|
||||
fetchpatch,
|
||||
fetchFromGitHub,
|
||||
cmake,
|
||||
jbig2dec,
|
||||
@@ -117,13 +118,43 @@ stdenv.mkDerivation rec {
|
||||
cp ${k2pdfopt_src}/mupdf_mod/pdf-* ./source/pdf/
|
||||
'';
|
||||
};
|
||||
# mupdf_patch no longer applies cleanly against mupdf 1.25.0 or later, due to a conflicting
|
||||
# hunk (mupdf_conflict) introduced in commit bd8d337939f36f55b96cb6984f5c7bbf2f488ce0 of mupdf.
|
||||
# This merge conflict can be resolved as desired by reverting mupdf_conflict, applying mupdf_patch,
|
||||
# and finally reapplying mupdf_conflict, with an increased fuzz factor (see mupdf_modded below).
|
||||
# TODO: remove workaround with conflicting hunk when mupdf in k2pdfopt is updated to 1.25.0 or later
|
||||
mupdf_conflict =
|
||||
hash: revert:
|
||||
fetchpatch {
|
||||
name = "mupdf-conflicting-hunk" + (lib.optionalString revert "-reverted") + ".patch";
|
||||
url = "https://github.com/ArtifexSoftware/mupdf/commit/bd8d337939f36f55b96cb6984f5c7bbf2f488ce0.patch";
|
||||
inherit hash revert;
|
||||
includes = [ "source/fitz/stext-device.c" ];
|
||||
postFetch = ''
|
||||
filterdiff -#6 "$out" > "$tmpfile"
|
||||
mv "$tmpfile" "$out"
|
||||
'';
|
||||
};
|
||||
mupdf_modded = mupdf.overrideAttrs (
|
||||
{
|
||||
patches ? [ ],
|
||||
...
|
||||
}:
|
||||
{
|
||||
patches = patches ++ [ mupdf_patch ];
|
||||
# The fuzz factor is increased to automatically resolve the merge conflict.
|
||||
patchFlags = [
|
||||
"-p1"
|
||||
"-F3"
|
||||
];
|
||||
# Reverting and reapplying the conflicting hunk is necessary, otherwise the result will be faulty.
|
||||
patches = patches ++ [
|
||||
# revert conflicting hunk
|
||||
(mupdf_conflict "sha256-24tl9YBuZBYhb12yY3T0lKsA7NswfK0QcMYhb2IpepA=" true)
|
||||
# apply modifications
|
||||
mupdf_patch
|
||||
# reapply conflicting hunk
|
||||
(mupdf_conflict "sha256-bnBV7LyX1w/BXxBFF1bkA8x+/0I9Am33o8GiAeEKHYQ=" false)
|
||||
];
|
||||
# This function is missing in font.c, see font-win32.c
|
||||
postPatch = ''
|
||||
echo "void pdf_install_load_system_font_funcs(fz_context *ctx) {}" >> source/fitz/font.c
|
||||
|
||||
Reference in New Issue
Block a user