#
# spec file for package djvulibre
#
# Copyright (c) 2019 SUSE LINUX GmbH, Nuernberg, Germany.
#
# 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 https://bugs.opensuse.org/
#


%define asan_build     0

%define	libname	lib%{name}21
Name:           djvulibre
Version:        3.5.27
Release:        6.2
Summary:        An Implementation of DjVu
License:        GPL-2.0-or-later
Group:          Productivity/Graphics/Other
Url:            http://djvu.sourceforge.net
Source:         http://downloads.sourceforge.net/djvu/%{name}-%{version}.tar.gz
# PATCH-FIX-UPSTREAM -- https://sourceforge.net/p/djvu/djvulibre-git/ci/ff8e5b68f856a7fe17c9aa33d0f2220f4ba6b40c/
Patch0:         reproducible.patch
# CVE-2019-15143 [bsc#1146569]
Patch1:         djvulibre-CVE-2019-15143.patch
# CVE-2019-15144 [bsc#1146571]
Patch2:         djvulibre-CVE-2019-15144.patch
# CVE-2019-15145 [bsc#1146572]
Patch3:         djvulibre-CVE-2019-15145.patch
# CVE-2019-15142 [bsc#1146702]
Patch4:         djvulibre-CVE-2019-15142.patch
# do not segfault when libtiff encounters corrupted TIFF (upstream issue #295)
Patch5:         djvulibre-invalid-tiff.patch
# https://sourceforge.net/p/djvu/bugs/293/
Patch6:         djvulibre-always-assume-that-cpuid-works-on-x86_64.patch
# CVE-2019-18804 [bsc#1156188]
Patch7:         djvulibre-CVE-2019-18804.patch
BuildRequires:  fdupes
BuildRequires:  gcc-c++
BuildRequires:  hicolor-icon-theme
BuildRequires:  libjpeg-devel
BuildRequires:  pkgconf-pkg-config
BuildRequires:  pkgconfig(libtiff-4)
Requires(post):    shared-mime-info
Requires(postun):  shared-mime-info
BuildRoot:      %{_tmppath}/%{name}-%{version}-build

%description
DjVu is a Web-centric format and software platform for distributing
documents and images. DjVuLibre is an implementation of DjVu,
including viewers, browser plug-ins, decoders, encoders, and
utilities. DjVu can replace PDF, PS, TIFF, JPEG, and GIF for
distributing scanned documents, digital documents, or high-resolution
pictures. DjVu content is often smaller and consumes less client
resources than competing formats.

%package -n %{libname}
Summary:        DjVu rendering library
Group:          Productivity/Graphics/Other

%description -n  %{libname}
DjVuLibre is an implementation of DjVu, a Web-centric format and
software platform for distributing documents and images.

This package contains the shared libraries.

%package -n libdjvulibre-devel
Summary:        Headers for djvulibre libraries
Group:          Development/Libraries/Other
Requires:       %{libname} = %{version}

%description -n libdjvulibre-devel
DjVuLibre is an implementation of DjVu, a Web-centric format and
software platform for distributing documents and images.

This package contains the development files.

%package doc
Summary:        Documentation for djvulibre
Group:          Productivity/Graphics/Other
BuildArch:      noarch

%description doc
DjVuLibre is an implementation of DjVu, a Web-centric format and
software platform for distributing documents and images.

This package contains the documentation.

%prep
%setup -q
%patch0 -p1
%patch1 -p1
%patch2 -p1
%patch3 -p1
%patch4 -p1
%patch5 -p1
%patch6 -p1
%patch7 -p1

%build
%configure \
  --disable-silent-rules
%if %{asan_build}
sed -i -e 's/\(^CFLAGS.*\)/\1 -fsanitize=address/' \
       -e 's/\(^CXXFLAGS.*\)/\1 -fsanitize=address/' \
       -e 's/\(^LIBS =.*\)/\1 -lasan/' \
       Makefile */Makefile
%endif
make %{?_smp_mflags}

%install
%make_install

# do not ship these
rm %{buildroot}%{_libdir}/libdjvulibre.la

%fdupes %{buildroot}/%{_prefix}

%post
%mime_database_post
%icon_theme_cache_post

%post  -n  %{libname} -p /sbin/ldconfig

%postun
%mime_database_postun
%icon_theme_cache_postun

%postun -n  %{libname} -p /sbin/ldconfig

%files
%license COPYING COPYRIGHT
%doc NEWS README
%doc %{_mandir}/man1/*
%{_datadir}/djvu
%{_bindir}/*
%{_datadir}/icons/hicolor/*
%{_datadir}/mime/packages/djvulibre-mime.xml

%files -n %{libname}
%{_libdir}/libdjvulibre.so.*

%files -n libdjvulibre-devel
%{_libdir}/libdjvulibre.so
%dir %{_includedir}/libdjvu
%{_includedir}/libdjvu/*.h
%{_libdir}/pkgconfig/ddjvuapi.pc

%files doc
%doc doc/*

%changelog
* Fri Nov  8 2019 pgajdos@suse.com
- security update
- added patches
  CVE-2019-18804 [bsc#1156188]
  + djvulibre-CVE-2019-18804.patch
* Fri Oct 18 2019 pgajdos@suse.com
- do not segfault when mmx enabled [bsc#1154401]
- added patches
  https://sourceforge.net/p/djvu/bugs/293/
  + djvulibre-always-assume-that-cpuid-works-on-x86_64.patch
* Tue Sep  3 2019 Jan Engelhardt <jengelh@inai.de>
- Trim conjecture, bias, and metadata repetitions from description.
- Trim descriptions in subpackages for length. (Main package keeps
  the bigger one.)
- Use some more macros and limit fdupes to the /usr volume.
* Mon Sep  2 2019 pgajdos@suse.com
- security update
- added patches
  CVE-2019-15142 [bsc#1146702]
  + djvulibre-CVE-2019-15142.patch
  CVE-2019-15143 [bsc#1146569]
  + djvulibre-CVE-2019-15143.patch
  CVE-2019-15144 [bsc#1146571]
  + djvulibre-CVE-2019-15144.patch
  CVE-2019-15145 [bsc#1146572]
  + djvulibre-CVE-2019-15145.patch
  do not segfault when libtiff encounters corrupted TIFF (upstream issue #295)
  + djvulibre-invalid-tiff.patch
* Tue Jan  8 2019 Stefan Brüns <stefan.bruens@rwth-aachen.de>
- Remove rsvg-convert BuildRequires, just use the prebuilt pngs
  from the source package.
* Mon May 15 2017 bwiedemann@suse.com
- Add reproducible.patch to make build fully reproducible
* Fri Feb 27 2015 mpluskal@suse.com
- Remove obsolete patches
  * djvulibre-filepath.patch
  * djvulibre-not-existing-icons.patch
- Update to 3.5.27
  * simplified configuration scripts
  * deadlock fixes
  * miniexp under win32 uses tlsalloc instead of _thread vars (pb under xp)
- New in 3.5.26
  * Thread safe miniexp
  * Now using the standard autotools approach (thanks to Vincent Torri).
  * New windows installer (thanks to Konstantin Kravtsov).
  * Fixed Russian code page issues in windows.
  * General speedup thanks to lock-free smart pointers.
  * ddjvu can produce one file per page.
  * djvused can now set the default page orientation.
  * Bug fixes all around.
* Wed Mar 27 2013 pgajdos@suse.com
- updated to 3.5.25.3:
  * minor fixes
  * call autoreconf
  * do not cp not existing prebuilt icons
  * not-existing-icons.patch
* Sun Mar 25 2012 dimstar@opensuse.org
- Add pkg-config BuildRequires.
* Fri Mar 16 2012 pgajdos@suse.com
- updated to 3.5.25:
  * Removed the deprecated djview3 code.
  * Removed the deprecated cothreads code.
  * Removed the unmaintained japanese man pages.
  * Added ddjvu option to skip corrupted pages.
  * Miniexp API is now reentrant.
  * Bug fixes all around.
* Thu Mar 15 2012 dimstar@opensuse.org
- Add djvulibre-gcc47.patch: Fix build with gcc 4.7.
* Tue Mar 13 2012 pgajdos@suse.com
- fix build for factory (define $QTDIR)
* Sun Sep 18 2011 jengelh@medozas.de
- Remove redundant tags/sections from specfile
  (cf. packaging guidelines)
- Use %%_smp_mflags for parallel build
* Thu Jun  9 2011 pgajdos@novell.com
- Fix MMX code when using gcc-4.6 [bnc#696824]
  * adjusted gcc46.patch
* Mon May  2 2011 idoenmez@novell.com
- Add djvulibre-3.5.23-gcc46.patch to fix compilation with gcc 4.6
* Mon Mar  7 2011 pgajdos@suse.cz
- updated to version 3.5.24:
  * Set ddjvuapi_version to 20.
  * Added ddjvuapi support for changing the white point.
  * Added option "-u" in djvused.
  * Added option "-o djvufile" in djvuxmlparser.
  * Added support for <CHARACTER> tag in djvuxmlparser.
  * Added print-xmp, set-xmp, remove-smp in djvused.
* Tue Nov 16 2010 pgajdos@suse.cz
- updated to version 3.5.23:
  * Added ddjvu_document_create_by_filename_utf8
  * Generate icons with rsvg rather than imagemagick.
  * djvused: correctly outputs escape characters.
  * djvumake: added options to generate foreground colors.
  * Various bug fixes.
* Mon Jun  8 2009 mseben@suse.cz
- updated to version 3.5.22
  * backported djview4 version of nsdejavu.so
  * various bug fixes
- splitted to doc package
* Mon Aug 25 2008 lmichnovic@suse.cz
- update to version 3.5.21
  * Speed improvement on multicore platforms
  * Ddjvu now can produce pdf output.
- renamed lib to libdjvulibre21 according to Shared Library
  Packaging Policy
* Mon Dec 10 2007 lmichnovic@suse.cz
- update to version 3.5.20
  obsoletes semicolon.patch, strip.patch
  * Csepdjvu handle gsdjvu hyperlink comments.
  * Djvudigital therefore handles hyperlinks.
* Mon Sep 10 2007 lmichnovic@suse.cz
- moved desktop file to djview3 subpackage [#307485]
* Fri Jul 13 2007 lmichnovic@suse.cz
- added trailing semicolon in desktop file (semicolon.patch)
- splitted off djview3 (Qt3) to make possible have alternative
  djview4 (Qt4) package
* Mon Jun 11 2007 lmichnovic@suse.cz
- fixed djvulibre-devel's Requires with %%{version}; [#282833]
* Wed Jun  6 2007 lmichnovic@suse.cz
- renamed lib to libdjvulibre15 according to Shared Library
  Packaging Policy
- splitted of devel package
- fixed calling ldconfig in post scripts
* Fri Apr 20 2007 lmichnovic@suse.cz
- moved libs into new libdjvulibre package [#264978]
- excluding *.la
* Tue Apr  3 2007 lmichnovic@suse.cz
- installing icons and desktop file in %%install section
* Tue Mar 27 2007 lmichnovic@suse.cz
- update to version 3.5.19
  * DjVuLibre is distributed under either version 2 of the GPL or
    (at your option) any later version.
  since 3.5.18
  * Renamed djview as djview3.
  * Various enhancement of DDJVUAPI.
  * Partial support for page titles instead of page numbers.
  * Clarification of metadata information.
  * Fixed djvumake mask separation feature.
  * Complain when given a so-called "secure" djvu file.
  * Fixed handling of urls with cgi arguments.
  * Fixed bug related to caching and ddjvuapi.
  * Reorganized ${datadir}/djvu.
  * Provide scripts in ${datadir}/djvu/*/desktop to register
    the djvu mime types and the djview menu entries.
  - obsoletes utf8.patch
* Sat Aug  5 2006 lmichnovic@suse.cz
- specifying --x-libraries and --x-include due to new paths in new
  X.org 7.x.
- added qt3-devel-tools and libtiff-devel into BuildRequires which
  enhance functionality
* Wed Jul 12 2006 lmichnovic@suse.cz
- update to version 3.5.17
  - Various enhancement of DDJVUAPI.
  - Compiles with the GCC-4.1.
  - using MSVC using the provided project files.
  - Minor bug fixes in csepdjvu text extraction.
  - Fixed leak in csepdjvu, cpaldjvu and cjb2.
* Wed Jan 25 2006 mls@suse.de
- converted neededforbuild to BuildRequires
* Fri Jan 20 2006 schwab@suse.de
- Don't strip binaries.
* Wed Nov 23 2005 lmichnovic@suse.cz
- added -fno-strict-aliasing into CXXFLAGS
* Tue Nov  1 2005 lmichnovic@suse.cz
- upgrade to version 3.5.16
  upgrade fixes missing binary any2djvu (#131761)
* Wed Oct 19 2005 lmichnovic@suse.cz
- fixed invalid extra qualification for build with new gcc 4.1
* Wed Sep 28 2005 dmueller@suse.de
- add norootforbuild
* Wed May 25 2005 ltinkl@suse.cz
- fix build with gcc41
* Tue Feb 22 2005 meissner@suse.de
- fixed XtVa* lists calls 0 -> NULL.
* Tue Feb  1 2005 meissner@suse.de
- fixed one execl call 0->NULL.
* Wed Sep 29 2004 ke@suse.de
- Recode README in UTF-8 encoding [#46179].
* Mon Aug  9 2004 ro@suse.de
- added directory to filelist
* Fri Aug  6 2004 ltinkl@suse.cz
- update to 3.5.14
* Mon May 17 2004 ltinkl@suse.cz
- updated to latest version 3.5.13
- redone the patch
- simplified and updated list of packaged files
* Tue Sep 30 2003 ltinkl@suse.cz
- updated to 3.5.12
- ported the patch
* Mon Aug 25 2003 ro@suse.de
- fix compile with current gcc
* Wed Jun  4 2003 mjancar@suse.cz
- update to 3.5.11
  * added support for mouse wheel
  * added support for LT toolbar control args
  * improved csepdjvu option -bgwhite
  * Djview and djvups now can print booklets
  * Djview main dialogs have a help button
  * Djview key space does continuous reading now
  * annotation strings now recognize C escape sequences
  * and some fixes
- add URL
- use buildroot
- use $RPM_OPT_FLAGS
* Mon Feb 24 2003 ro@suse.de
- move to libdir/browser-plugins
* Sat Dec 28 2002 prehak@suse.cz
- fixed to build with gcc-3.3
- added %%clean section
* Thu Oct 31 2002 uli@suse.de
- update -> 3.5.9 (gcc-3.2, fix for broken command ddjvu, modified
  IW44 for ARM processors)
- going down to -O1 on x86-64 to avoid segfault in djview
- cutting optimization on Alpha as well
* Wed Aug  7 2002 uli@suse.de
- update -> 3.5.8 (fixed printing of b&w documents,fixes for
  gcc-3.1)
* Tue Jul 23 2002 uli@suse.de
- update -> 3.5.7 (minor fixes)
* Fri Jun 28 2002 uli@suse.de
- build with -O2 on x86-64 to avoid miscompilation
* Fri Jun  7 2002 uli@suse.de
- update -> 3.5.6:
  Added option -bgwhite in cpaldjvu
  Removed annoying flicker with djview/Qt3.
  Fixed show stopper in djvused.
  Fixed bug in djview print dialog.
  Added CGI program djvuserve.
* Tue May 14 2002 uli@suse.de
- find Qt3 in lib64 if applicable
- still doesn't build on x86-64, maybe bin2cpp gets miscompiled
* Thu Apr 18 2002 uli@suse.de
- fixed to build with gcc 3.1
* Fri Feb  1 2002 uli@suse.de
- use %%_libdir
* Thu Jan 31 2002 uli@suse.de
- added plugin to mozilla plugin dir
* Fri Jan 18 2002 uli@suse.de
- update -> 3.5.3 (builds with Qt3, adds djvups tool)
* Wed Dec 12 2001 uli@suse.de
- initial package