# for pypdfium2-4.30.1 %global pdfium_build 7049 # https://github.com/pypdfium2-team/ctypesgen %bcond_without ctypesgen %global ctypesgen_commit ebd495b1733b60132151154d6358fd1eb336a36a # https://pdfium.googlesource.com/pdfium/+/refs/heads/chromium/7049 %global pdfium_commit 9afffebfa895ea6cdcc05516908c50bd7fe72797 %global pdfium_commitdate 20230301 %global pdfium_shortcommit %(c=%{pdfium_commit}; echo ${c:0:8}) # git ls-remote --sort -version:refname --tags https://chromium.googlesource.com/chromium/src '*.*.7049.0' # ... refs/tags/135.0.7062.0 %global pdfium_major 135 %global pdfium_minor 0 %global pdfium_patch 0 # from https://pdfium.googlesource.com/pdfium/+/refs/heads/chromium/7049/DEPS # local Chromium, PDFium wants specific commits of abseil-cpp and fast_float # gtest for unit tests %global build_revision 3dd73ffc3708962da298795d99f35fc06ed0defc %global abseil_revision 221ee3ed3b032d5a82736613440664f9fbe4d3db %global fast_float_revision cb1d42aaa1e14b09e1452cfdef373d051b8c02a4 %global gtest_revision e235eb34c6c4fed790ccdad4b16394301360dcd4 Name: libpdfium Version: %{pdfium_build} Release: 1%{?dist} Summary: Library for PDF rendering, inspection, manipulation and creation License: Apache 2.0 URL: https://pdfium.googlesource.com/pdfium # Source0: https://pdfium.googlesource.com/pdfium/+archive/refs/heads/chromium/%%{pdfium_build}.tar.gz#/pdfium-%%{pdfium_build}.tar.gz Source0: pdfium-%{pdfium_build}-clean.tar.gz Source1: args.gn Source2: passflags-BUILD.gn Source3: https://github.com/pypdfium2-team/ctypesgen/archive/%{ctypesgen_commit}.tar.gz#/ctypesgen-%{ctypesgen_commit}.tar.gz Source5: https://chromium.googlesource.com/chromium/src/build.git/+archive/%{build_revision}.tar.gz#/build-%{build_revision}.tar.gz Source6: https://chromium.googlesource.com/chromium/src/third_party/abseil-cpp/+archive/%{abseil_revision}.tar.gz#/abseil-cpp-%{abseil_revision}.tar.gz Source7: https://chromium.googlesource.com/chromium/src/+archive/refs/tags/%{pdfium_major}.%{pdfium_minor}.%{pdfium_build}.%{pdfium_patch}/tools/generate_shim_headers.tar.gz#/generate_shim_headers-%{pdfium_build}.tar.gz Source8: https://chromium.googlesource.com/external/github.com/fastfloat/fast_float.git/+archive/%{fast_float_revision}.tar.gz#/fast_float-%{fast_float_revision}.tar.gz Source9: https://chromium.googlesource.com/external/github.com/google/googletest.git/+archive/%{gtest_revision}.tar.gz#/gtest-%{gtest_revision}.tar.gz # fix for big endian bugs in CFX_SeekableStreamProxy code and BinaryBuffer tests # https://issues.chromium.org/issues/402354437 Patch1: bigendian.patch Patch2: openjpeg-2.4.patch BuildRequires: gcc-c++ BuildRequires: glibc-devel BuildRequires: pkgconfig BuildRequires: redhat-rpm-config BuildRequires: libatomic BuildRequires: chrpath BuildRequires: gn BuildRequires: ninja-build %if %{with ctypesgen} BuildRequires: python3 %endif # unbundled dependencies BuildRequires: pkgconfig(glib-2.0) BuildRequires: pkgconfig(freetype2) BuildRequires: pkgconfig(icu-uc) BuildRequires: pkgconfig(lcms2) BuildRequires: pkgconfig(libjpeg) BuildRequires: pkgconfig(libopenjp2) >= 2.4 BuildRequires: pkgconfig(libpng) BuildRequires: pkgconfig(libtiff-4) BuildRequires: pkgconfig(zlib) # https://sourceforge.net/projects/agg/ 2.3 + security patches Provides: bundled(agg) = 2.3 Provides: bundled(abseil-cpp) Provides: bundled(fast_float) Provides: %{name}(build) = %{pdfium_build} Provides: %{name}(version) = %{pdfium_major}.%{pdfium_minor}.%{pdfium_build}.%{pdfium_patch} %description Library for PDF rendering, inspection, manipulation and creation %package devel Summary: Development files for %{name} Requires: %{name}%{?_isa} = %{version}-%{release} %description devel The %{name}-devel package contains libraries and header files for developing applications that use %{name}. %if %{with ctypesgen} %package ctypesgen Summary: ctypes bindings for %{name} Requires: %{name}%{?_isa} = %{version}-%{release} Provides: %{name}(ctypesgen) = %{ctypesgen_commit} %description ctypesgen The %{name}-ctypesgen package contains ctypes bindings for %{name}. The bindings were generated with https://github.com/pypdfium2-team/ctypesgen from commit %{ctypesgen_commit}. %endif %prep %setup -qTD -c -a 5 -n libpdfium-%{pdfium_build}/build %setup -qTD -c -a 6 -n libpdfium-%{pdfium_build}/third_party/abseil-cpp %setup -qTD -c -a 7 -n libpdfium-%{pdfium_build}/tools/generate_shim_headers %setup -qTD -c -a 8 -n libpdfium-%{pdfium_build}/third_party/fast_float/src %setup -qTD -c -a 9 -n libpdfium-%{pdfium_build}/third_party/googletest/src %if %{with ctypesgen} %setup -T -D -q -a 3 -n libpdfium-%{pdfium_build} %endif %setup -qTD -c -a 0 -n libpdfium-%{pdfium_build} %patch -P 1 -p1 %if 0%{?rhel} == 9 # RHEL 9 has OpenJPEG 2.4 without opj_decoder_set_strict_mode() %patch -P 2 -p1 %endif # unbundle ICU mkdir -p third_party/icu cp build/linux/unbundle/icu.gn third_party/icu/BUILD.gn # Build static abseil-cpp sed -i 's/component("absl")/static_library("absl")/' third_party/abseil-cpp/BUILD.gn # empty gclient config touch build/config/gclient_args.gni # don't build test fonts sed -i '/third_party\/test_fonts/d' testing/BUILD.gn # build configuration mkdir -p out/release cp %{SOURCE1} out/release/args.gn # custom flavor of GCC toolchain that passes CFLAGS, CXXFLAGS, etc. mkdir -p build/toolchain/linux/passflags cp %{SOURCE2} build/toolchain/linux/passflags/BUILD.gn # generate Ninja files with build flags %set_build_flags # -DUSE_SYSTEM_LCMS2=1: build system does not define macro for some dependencies # disable floating-point expression contraction, needed for CFX_Matrix::GetInverse() # fixes: CFXMatrixTest.GetInverseCR702041, CPDFDocRenderDataTest.TransferFunctionOne, CPDFDocRenderDataTest.TransferFunctionArray # https://issues.chromium.org/issues/402282789 export CPPFLAGS="-DUSE_SYSTEM_LCMS2=1 -ffp-contract=off $CPPFLAGS" gn gen out/release %build # build libpdfium.so %ninja_build -C out/release pdfium pdfium_unittests # remove rpath chrpath --delete out/release/libpdfium.so # generate libpdfium pkgconfig file cat > libpdfium.pc < "out/ctypesgen/version.json" << EOF { "major": %{pdfium_major}, "minor": %{pdfium_minor}, "build": %{pdfium_build}, "patch": %{pdfium_patch}, "n_commits": 0, "hash": "%{pdfium_commit}", "origin": "system", "flags": [] } EOF %endif %check %if 0%{?rhel} == 9 # RHEL 9: FlateModule.Encode fails due to older zlib GTEST_FILTER="*-FlateModule.Encode" %else # run all tests GTEST_FILTER="*" %endif GTEST_FILTER="$GTEST_FILTER" out/release/pdfium_unittests %install mkdir -p %{buildroot}%{_libdir} cp out/release/libpdfium.so %{buildroot}%{_libdir} mkdir -p %{buildroot}%{_includedir}/pdfium/cpp cp public/*.h %{buildroot}%{_includedir}/pdfium cp public/cpp/*.h %{buildroot}%{_includedir}/pdfium/cpp mkdir -p %{buildroot}%{_libdir}/pkgconfig cp libpdfium.pc %{buildroot}%{_libdir}/pkgconfig %if %{with ctypesgen} mkdir -p %{buildroot}%_datarootdir/%{name}/ctypesgen/ cp out/ctypesgen/* %{buildroot}%_datarootdir/%{name}/ctypesgen/ %endif %files %license LICENSE %doc AUTHORS out/release/args.gn # pypdfium2 needs "libpdfium.so" %{_libdir}/*.so %files devel %doc README.md %{_includedir}/pdfium %{_libdir}/pkgconfig/libpdfium.pc %if %{with ctypesgen} %files ctypesgen %_datarootdir/%{name}/ctypesgen/ %endif %changelog * Tue Mar 11 2025 Christian Heimes - 7049-1 - Update to PDFium 7049 - Rework build system * Wed Oct 23 2024 Christian Heimes - 6462^20240502git7b7c83fb-4 - Rebuild SRPM without bug_867501.pdf. The test file is flagged as malicious content. * Tue Oct 22 2024 Christian Heimes - 6462^20240502git7b7c83fb-3 - Build ctypes bindings with ctypesgen * Fri Oct 11 2024 Christian Heimes - 6462^20240502git7b7c83fb-2 - Rebuild for RHELAI 1.3 * Fri Sep 27 2024 Christian Heimes - 6462^20240502git7b7c83fb-1 - Build tag 6462 for pypdfium2-4.30.0 - Resolves RHELAI-1562