%global test_sha 45f55f1e03b9bf3fbd334c31776b6f5e472889ec
%global test_date 2018-12-18

Summary:        PDF rendering library
Name:           poppler
Version:        0.90.0
Release:        5
License:        (GPLv2 or GPLv3) and GPLv2+ and LGPLv2+ and MIT
URL:            http://poppler.freedesktop.org/
Source0:        http://poppler.freedesktop.org/poppler-%{version}.tar.xz
Source1:        %{name}-test-%{test_date}-%{test_sha}.tar.xz
Patch0:         poppler-0.30.0-rotated-words-selection.patch
Patch4:         poppler-0.73.0-PSOutputDev-buffer-read.patch
Patch5:         poppler-0.84.0-MacroPushRequiredVars.patch
Patch7:         poppler-0.90.0-position-independent-code.patch
Patch8:         %{name}-gcc11.patch

Patch6001:	backport-CVE-2022-38784.patch
Patch6002:	backport-CVE-2022-27337.patch
Patch6003:	backport-CVE-2020-23804.patch
Patch6004:	backport-CVE-2022-37050.patch
Patch6005:	backport-CVE-2022-37051.patch
Patch6006:	backport-CVE-2022-37052.patch
Patch6007:	backport-CVE-2022-38349.patch

BuildRequires:  cmake
BuildRequires:  gcc-c++
BuildRequires:  gettext-devel
BuildRequires:  pkgconfig(cairo)
BuildRequires:  pkgconfig(cairo-ft)
BuildRequires:  pkgconfig(cairo-pdf)
BuildRequires:  pkgconfig(cairo-ps)
BuildRequires:  pkgconfig(cairo-svg)
BuildRequires:  pkgconfig(fontconfig)
BuildRequires:  pkgconfig(freetype2)
BuildRequires:  pkgconfig(gdk-pixbuf-2.0)
BuildRequires:  pkgconfig(gio-2.0)
BuildRequires:  pkgconfig(gobject-2.0)
BuildRequires:  pkgconfig(gobject-introspection-1.0) 
BuildRequires:  pkgconfig(gtk+-3.0)
BuildRequires:  pkgconfig(gtk-doc)
BuildRequires:  pkgconfig(lcms2)
BuildRequires:  pkgconfig(libjpeg)
BuildRequires:  pkgconfig(libopenjp2)
BuildRequires:  pkgconfig(libpng)
BuildRequires:  pkgconfig(libtiff-4)
BuildRequires:  pkgconfig(nss)
BuildRequires:  pkgconfig(poppler-data)
BuildRequires:  pkgconfig(Qt5Core)
BuildRequires:  pkgconfig(Qt5Gui)
BuildRequires:  pkgconfig(Qt5Test)
BuildRequires:  pkgconfig(Qt5Widgets)
BuildRequires:  pkgconfig(Qt5Xml)
BuildRequires:  openjpeg2-tools
Requires:       poppler-data
Obsoletes:      poppler-glib-demos < 0.60.1-1

%description
Poppler is a free software utility library for rendering Portable Document Form at (PDF) documents. \
Its development is supported by freedesktop.org. It is commonly used on Linux systems,and is used by \
the PDF viewers of the open source GNOME and KDE desktop environments.

%package devel
Summary:        Provide header files and libraries for poppler
Requires:       %{name} = %{version}-%{release}

%description devel
You should install the poppler-devel package if you would like to
compile applications based on poppler.

%package glib
Summary:       Provide glib wrapper for poppler
Requires:      %{name} = %{version}-%{release}

%description glib
This package provides glib wrapper for poppler

%package glib-devel
Summary:       Provide development files for glib wrapper
Requires:      %{name}-glib = %{version}-%{release}
Requires:      %{name}-devel = %{version}-%{release}
Suggests:      %{name}-doc = %{version}-%{release}

%description glib-devel
This package provides development files for glib wrapper

%package glib-doc
Summary:       Documentation for glib wrapper
BuildArch:     noarch

%description glib-doc
This package provides documentation files for glib wrapper

%package qt5
Summary:       Provides Qt5 wrapper for poppler
Obsoletes:     %{name}-qt <= 0.67.0
Requires:      %{name} = %{version}-%{release}

%description qt5
This package provides Qt5 wrapper for poppler.

%package qt5-devel
Summary:       Provides development files for Qt5 wrapper
Obsoletes:     %{name}-qt-devel <= 0.67.0
Requires:      %{name}-qt5 = %{version}-%{release}
Requires:      %{name}-devel = %{version}-%{release}
Requires:      qt5-qtbase-devel

%description qt5-devel
This package provides development files for Qt5 wrapper.

%package cpp
Summary:       Provide pure C++ wrapper for poppler
Requires:      %{name} = %{version}-%{release}

%description cpp
This package provides pure C++ wrapper for poppler

%package cpp-devel
Summary:       Provide development files for C++ wrapper
Requires:      %{name}-cpp = %{version}-%{release}
Requires:      %{name}-devel = %{version}-%{release}

%description cpp-devel
This package provides development files for C++ wrapper

%package utils
Summary:       Command line utilities for converting PDF files
Requires:      %{name} = %{version}-%{release}
%description utils
Command line tools for manipulating PDF files and converting them to
other formats.

%package_help

%prep
%autosetup -p1 -b 1

%build
mkdir build
cd build
%cmake \
  -DENABLE_CMS=lcms2 \
  -DENABLE_DCTDECODER=libjpeg \
  -DENABLE_GTK_DOC=ON \
  -DENABLE_LIBOPENJPEG=openjpeg2 \
  -DENABLE_UNSTABLE_API_ABI_HEADERS=ON \
  -DENABLE_ZLIB=OFF \
  ..
%make_build

%install
%make_install -C build

%check
%make_build test
export PKG_CONFIG_PATH=%{buildroot}%{_datadir}/pkgconfig:%{buildroot}%{_libdir}/pkgconfig
#test "$(pkg-config --modversion poppler)" = "%{version}"
test "$(pkg-config --modversion poppler-cairo)" = "%{version}"
test "$(pkg-config --modversion poppler-cpp)" = "%{version}"
test "$(pkg-config --modversion poppler-glib)" = "%{version}"
test "$(pkg-config --modversion poppler-qt5)" = "%{version}"
test "$(pkg-config --modversion poppler-splash)" = "%{version}"
%ldconfig_scriptlets
%ldconfig_scriptlets glib

%ldconfig_scriptlets qt5
%ldconfig_scriptlets cpp

%files
%license COPYING
%{_libdir}/libpoppler.so.101*

%files devel
%{_libdir}/pkgconfig/poppler.pc
%{_libdir}/pkgconfig/poppler-splash.pc
%{_libdir}/libpoppler.so
%dir %{_includedir}/poppler/
# xpdf headers
%{_includedir}/poppler/*.h
%{_includedir}/poppler/fofi/
%{_includedir}/poppler/goo/
%{_includedir}/poppler/splash/

%files glib
%{_libdir}/libpoppler-glib.so.8*
%{_libdir}/girepository-1.0/Poppler-0.18.typelib

%files glib-devel
%{_libdir}/pkgconfig/poppler-glib.pc
%{_libdir}/pkgconfig/poppler-cairo.pc
%{_libdir}/libpoppler-glib.so
%{_datadir}/gir-1.0/Poppler-0.18.gir
%{_includedir}/poppler/glib/

%files glib-doc
%license COPYING
%{_datadir}/gtk-doc/

%files qt5
%{_libdir}/libpoppler-qt5.so.1*

%files qt5-devel
%{_libdir}/libpoppler-qt5.so
%{_libdir}/pkgconfig/poppler-qt5.pc
%{_includedir}/poppler/qt5/

%files cpp
%{_libdir}/libpoppler-cpp.so.0*

%files cpp-devel
%{_libdir}/pkgconfig/poppler-cpp.pc
%{_libdir}/libpoppler-cpp.so
%{_includedir}/poppler/cpp

%files utils
%{_bindir}/pdf*

%files help
%doc README.md
%{_mandir}/man1/*

%changelog
* Tue Sep 05 2023 zhouwenpei <zhouwenpei1@h-partners.com> - 0.90.0-5
- avoid using the --allowerasing parameter

* Wed Aug 30 2023 zhouwenpei <zhouwenpei1@h-partners.com> - 0.90.0-4
- fix CVE-2022-37050,CVE-2022-37051,CVE-2022-37052,CVE-2022-38349,CVE-2020-23804
- fix install error

* Thu May 25 2023 zhangpan <zhangpan103@h-partners.com> - 0.90.0-3
- fix changelog error

* Tue Mar 14 2023 zhangpan <zhangpan103@h-partners.com> - 0.90.0-2
- fix CVE-2022-27337

* Tue Mar 14 2023 zhangpan <zhangpan103@h-partners.com> - 0.90.0-1
- update to 0.90.0

* Wed Sep 07 2022 zhouwenpei <zhouwenpei1@h-partners.com> - 0.67.0-8
- fix CVE-2022-38784

* Wed Sep 29 2021 yangcheng <yangcheng87@huawei.com> - 0.67.0-7
- Type:CVE
- Id:CVE-2019-12293 CVE-2020-27778
- SUG:NA
- DESC:fix CVE-2019-12293 CVE-2020-27778

* Sat Jan 30 2021 wangye <wangye70@huawei.com> - 0.67.0-6
- Type:cves
- Id:NA
- SUG:NA
- DESC:fix CVE-2018-16646 CVE-2018-18897 CVE-2018-19060 CVE-2018-20481 CVE-2019-14494 CVE-2019-7310

* Mon Jan 20 2020 openEuler Buildteam <buildteam@openeuler.org> - 0.67.0-5
- Type:bugfix
- Id:NA
- SUG:NA
- DESC:fix cves

* Mon Jan 20 2020 openEuler Buildteam <buildteam@openeuler.org> - 0.67.0-4
- Type:cve
- Id:NA
- SUG:NA
- DESC:fix cves

* Mon Oct 14 2019 openEuler Buildteam <buildteam@openeuler.org> - 0.67.0-3
- Type:enhancement
- Id:NA
- SUG:NA
- DESC:Adjust sub-package relationship

* Fri Sep 20 2019 openEuler Buildteam <buildteam@openeuler.org> - 0.67.0-2
- Package init
 
