File mupdf.spec of Package mupdf

#
# spec file for package mupdf
#
# Copyright (c) 2018 SUSE LINUX GmbH, Nuernberg, Germany.
# Copyright (c) 2011 Guido Berhoerster.
#
# All modifications and additions to the file contributed by third parties
# remain the property of their copyright owners, unless otherwise agreed
# upon. The license for this file, and modifications and additions to the
# file, is the same license as for the pristine package itself (unless the
# license for the pristine package is not an Open Source License, in which
# case the license is the MIT License). An "Open Source License" is a
# license that conforms to the Open Source Definition (Version 1.9)
# published by the Open Source Initiative.

# Please submit bugfixes or comments via http://bugs.opensuse.org/
#


Name:           mupdf
Version:        1.12.0
Release:        0
Summary:        Lightweight PDF and XPS Viewer and Parser and Rendering Library
License:        AGPL-3.0+
Group:          Productivity/Office/Other
Url:            https://mupdf.com/
Source0:        https://mupdf.com/downloads/mupdf-%{version}-source.tar.xz#/%{name}-%{version}.tar.xz
Source1:        mupdf.desktop
Source2:        mupdf.png
Patch1:         fix-openjpeg-flags.patch
Patch2:         CVE-2018-5686.patch
Patch3:         CVE-2017-17858.patch
Patch4:         CVE-2018-6187.patch
Patch5:         CVE-2018-6192.patch
Patch6:         CVE-2018-6544.patch
BuildRequires:  freetype2-devel
BuildRequires:  gcc-c++
BuildRequires:  jbig2dec-devel
BuildRequires:  libcurl-devel
BuildRequires:  libjpeg-devel
BuildRequires:  openjpeg2-devel
BuildRequires:  pkgconfig
BuildRequires:  update-desktop-files
BuildRequires:  xorg-x11-devel
BuildRequires:  zlib-devel
BuildRequires:  pkgconfig(harfbuzz)
Requires:       xdg-utils

%description
MuPDF is a lightweight PDF and XPS viewer and parser/rendering library.

The renderer in MuPDF is tailored for high quality anti-aliased graphics. It
renders text with metrics and spacing accurate to within fractions of a pixel
for the highest fidelity in reproducing the look of a printed page on screen.

MuPDF is also small, fast, and yet complete. It supports PDF 1.7 with
transparency, encryption, hyperlinks, annotations, search and many other bells
and whistles. MuPDF can also read XPS documents (OpenXPS/ECMA-388).

%package devel-static
Summary:        Development Files for mupdf
Group:          Development/Libraries/C and C++
Requires:       %{name} = %{version}

%description devel-static
This package contains development files needed for developing applications
based on mupdf.

%prep
%setup -q -n %{name}-%{version}-source
%patch1 -p1
%patch2 -p1
%patch3 -p1
%patch4 -p1
%patch5 -p1
%patch6 -p1

# do not use the inlined copies of build dpendencies except for mujs
rm -rf $(ls -d thirdparty/*/ | grep -v mujs)

for src in docs/*.c; do
    if [ -r "$src" ]; then
        ln -s "$src" "docs/examples/${src##*/}"
    fi
done

sed -e s,'INSTALL_APPS := .*','INSTALL_APPS := $(MUTOOL_EXE) $(MUVIEW_X11_CURL_EXE)', \
    -e '/^INSTALL_APPS +=/d' -i Makefile

%build
# do no set CFLAGS which is used by the build system itself!
export XCFLAGS="%{optflags} -fPIC -lpthread"
make %{?_smp_mflags} \
    build=release \
    verbose=yes \
    NOCURL= \
    CURL_CFLAGS="$(pkg-config --libs libcurl)" \
    CURL_LIBS=" -pthread $(pkg-config --libs libcurl)" \
    HAVE_GLFW=no

%install
%make_install build=release prefix=%{_prefix} libdir=%{_libdir}

mv %{buildroot}%{_bindir}/mupdf-x11-curl %{buildroot}%{_bindir}/mupdf

rm -rf %{buildroot}%{_datadir}/doc/

chmod 0644 %{buildroot}%{_includedir}/mupdf/*.h \
    %{buildroot}%{_includedir}/mupdf/*/*.h \
    %{buildroot}%{_libdir}/*.a \
    %{buildroot}%{_mandir}/man1/*

install -D -p -m 644 %{SOURCE1} \
    %{buildroot}%{_datadir}/applications/%{name}.desktop
install -D -p -m 644 %{SOURCE2} \
    %{buildroot}%{_datadir}/pixmaps/%{name}.png

%suse_update_desktop_file mupdf

%if 0%{?suse_version} <= 1320
%post
%desktop_database_post

%postun
%desktop_database_postun
%endif

%files
%doc CHANGES COPYING README 
%doc docs/examples/
%{_bindir}/mupdf
%{_bindir}/mutool
%{_datadir}/applications/mupdf.desktop
%{_datadir}/pixmaps/mupdf.png
%{_mandir}/man1/mupdf.1%{ext_man}
%{_mandir}/man1/mutool.1%{ext_man}

%files devel-static
%{_includedir}/mupdf/
%{_libdir}/libmupdf.a
%{_libdir}/libmupdfthird.a

%changelog
openSUSE Build Service is sponsored by