#
# spec file for package graphite2
#
# Copyright (c) 2018 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 http://bugs.opensuse.org/
#


%define libname libgraphite2-3
Name:           graphite2
Version:        1.3.11
Release:        1.1
Summary:        Font rendering capabilities for complex non-Roman writing systems
License:        LGPL-2.1-or-later OR MPL-2.0+
Group:          Productivity/Publishing/Word
Url:            http://graphite.sil.org/
Source0:        https://github.com/silnrsi/graphite/archive/%{version}.tar.gz#/%{name}-%{version}.tar.gz
Source1:        baselibs.conf
Patch0:         graphite2-1.2.0-cmakepath.patch
Patch2:         link-gcc-shared.diff
Patch3:         graphite2-CVE-2018-7999.patch
BuildRequires:  cmake
BuildRequires:  fontconfig-devel
BuildRequires:  freetype2-devel
BuildRequires:  gcc-c++
BuildRequires:  glib2-devel
BuildRequires:  pkgconfig
BuildRequires:  python3-base

%description
Graphite2 is a project within SIL's Non-Roman Script Initiative and Language
Software Development groups to provide rendering capabilities for complex
non-Roman writing systems. Graphite can be used to create "smart fonts" capable
of displaying writing systems with various complex behaviors. With respect to
the Text Encoding Model, Graphite handles the "Rendering" aspect of writing
system implementation.

%package -n %{libname}
Summary:        Text categorization library
Group:          System/Libraries

%description -n %{libname}
Graphite2 is a project within SIL's Non-Roman Script Initiative and Language
Software Development groups to provide rendering capabilities for complex
non-Roman writing systems. Graphite can be used to create "smart fonts" capable
of displaying writing systems with various complex behaviors. With respect to
the Text Encoding Model, Graphite handles the "Rendering" aspect of writing
system implementation.

%package devel
Summary:        Files for Developing with %{name}
Group:          Development/Libraries/C and C++
Requires:       %{libname} = %{version}
Requires:       glibc-devel

%description devel
Graphite2 is a project within SIL's Non-Roman Script Initiative and Language
Software Development groups to provide rendering capabilities for complex
non-Roman writing systems. Graphite can be used to create "smart fonts" capable
of displaying writing systems with various complex behaviors. With respect to
the Text Encoding Model, Graphite handles the "Rendering" aspect of writing
system implementation.

This package contains the %{name} development files.

%prep
%setup -q -n graphite-%{version}
%patch0 -p1
%patch2 -p1
%patch3 -p1

# Make sure to use python3 everywhere
find tests -type f -exec sed -i "s|python|python3|g" {} +
find . -name *.cmake -exec sed -i "s|python|python3|g" {} +

%build
%cmake \
	-DGRAPHITE2_COMPARE_RENDERER=OFF \
	-DGRAPHITE2_NTRACING=ON \
	-DCMAKE_SKIP_RPATH=OFF
# Do not use O3, from debian
find . -type f \
	-exec sed -i -e 's/\-O3//g' {} \;

make %{?_smp_mflags}

%install
%cmake_install
find %{buildroot} -type f -name "*.la" -delete -print

%check
# exclude tests based on fonttool
cd build
ctest --output-on-failure --force-new-ctest-process %{?_smp_mflags} \
    -E "padaukcmp1|chariscmp1|chariscmp2|annacmp1|schercmp1|awamicmp1|awamicmp2"

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

%files
%doc LICENSE COPYING
%{_bindir}/gr2fonttest

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

%files devel
%{_libdir}/*.so
%{_libdir}/pkgconfig/%{name}*.pc
%{_includedir}/%{name}*
%{_libdir}/%{name}*

%changelog
* Fri Mar 16 2018 tchvatal@suse.com
- Use python3 everywhere
- Drop fonttools test dep as it pulls TON of py3 packages
* Mon Mar 12 2018 pgajdos@suse.com
- Update to 1.3.11:
- removed patches (upstreamed or not needed)
  * gcc8.patch (code commeted out)
  * graphite-nonvoid-return.patch (code commented out)
  * graphite2-python3_tests.patch (upstreamed)
  * graphite2-python3_tests_cornercases.patch (upstreamed
- refreshed patch
  * link-gcc-shared.diff
- fixes security issue: CVE-2018-7999 [bsc#1084850]
  + graphite2-CVE-2018-7999.patch
* Thu Feb 15 2018 schwab@suse.de
- gcc8.patch: return correct value from stream operator
* Thu Jan 18 2018 tchvatal@suse.com
- Do not BR asciidoc as we do not install the generated html page
* Tue Dec  5 2017 tchvatal@suse.com
- Make sure we switch to python3 only on SLE15+ and not on SLE12
* Mon Nov 20 2017 mpluskal@suse.com
- Add patches to fix tests when using python3:
  * graphite2-python3_tests.patch
  * graphite2-python3_tests_cornercases.patch
- Refresh all other patches
- Use fancy name for downloaded tarball
- Run spec-cleaner
* Wed Jun 21 2017 tchvatal@suse.com
- Use %%ctest macro
- Update license string to lgpl2.1+ and mpl2.0+
- Remove patch graphite2-CVE-2017-5436.patch
- Update to 1.3.10:
  * Upstream marks this as contianing various bugfixes without
    any specific mentions
* Mon Apr 24 2017 pgajdos@suse.com
- security update:
  * CVE-2017-5436 [bsc#1035204]
    + graphite2-CVE-2017-5436.patch
* Mon Nov 21 2016 pgajdos@suse.com
- Version update to 1.3.9: fixes some bugs in the collision
  avoidance and may give slightly improved results in some cases.
* Thu Jun  2 2016 tchvatal@suse.com
- Version update to 1.3.8:
  * Various bugfixes found by fuzzers
* Mon Feb 29 2016 tchvatal@suse.com
- Update to 1.3.6
  * This fixes a number of security related bugs. There are no feature
    improvements or bug fixes in this release.
* Fri Feb 12 2016 pgajdos@suse.com
- updated to 1.3.5 bnc#965803 CVE-2016-1521:
  * Security bug fix
  * Fix ARM misalignment problem
  * Track latest cmake
* Mon Dec 21 2015 tchvatal@suse.com
- Version update to 1.3.4:
  * Fix Collision Kerning ignoring some diacritics
  * Handle pass bits 16-31 to speed up fonts with > 16 passes
  * Various minor fuzz bug fixes
  * Make Coverity happy
  * Add GR_FALLTHROUGH macro for clang c++11
- Upstream moved to github
* Wed Dec 16 2015 pgajdos@suse.com
- updated to 1.3.3
  * Slight speed up in Collision Avoidance
  * Remove dead bidi code
  * Bug fixes
    . Between pass bidi reorderings and at the end
    . Decompressor fuzz bugs
    . Other fuzz bugs
* Thu Sep 10 2015 tchvatal@suse.com
- Version bump top 1.3.2:
  * Remove full bidi. All segments are assumed to be single directioned.
  * Bug fixes:
    + Decompressor corner cases
    + Various fuzz bugs
* Tue Sep  1 2015 tchvatal@suse.com
- Version bump to 1.3.1:
  * Deprecation warning: Full bidi support is about to be deprecated. Make
    contact if this impacts you.
  * Change compression block format slightly to conform to LZ4
  * Handle mono direction text with diacritics consistently. Fonts
    now see the direction they expect consistently and bidi now
    gives expected results.
  * Fixed lots of fuzz bugs
  * Coverity cleanups
  * Build now works for clang and/or asan and/or afl etc.
* Fri Aug  7 2015 tchvatal@suse.com
- Version bump to 1.3.0:
  * Various tweaks for the arabic fonts
- Added patches:
  * graphite-nonvoid-return.patch
  * graphite2-1.2.0-cmakepath.patch
- Removed patches:
  * no-specific-nunit-version.diff
  * soname.diff
* Tue May 19 2015 fstrba@suse.com
- Remove unnecessary utf-8  characters from the spec file
* Tue Oct 21 2014 dmueller@suse.com
- add link-gcc-shared.diff: link -lgcc_s to fix undefined symbols
  on various ARM architectures
* Wed Jan 29 2014 tchvatal@suse.com
- Remove harfbuzz dep. Breaks another buildcycle.
  This effectively means we are not running tests. No functional
  changes otherwise.
* Wed Jan 29 2014 tchvatal@suse.com
- Remove texlive dep to remove dep circle.
* Sun Jan 26 2014 tchvatal@suse.com
- Use rpath so the tests work.
* Sat Jan 25 2014 tchvatal@suse.com
- Enable the tests. They work on 13.1 but fail on Factory...
* Sat Jan 25 2014 tchvatal@suse.com
- Version bump to 1.2.4:
  * Various bugfixes
  * Expanded testsuite
- Remove graphite2-arm.patch - applied upstream
- Add patches from debian:
  * soname.diff
  * no-specific-nunit-version.diff
- Run^Wdocument tests and generate documentation
* Sat Jan 25 2014 tchvatal@suse.com
- Use cmake macros for nice and tidy setup.
* Fri Jun 28 2013 dimstar@opensuse.org
- Add baselibs.conf and provide libgraphite2-3-32bit, which is at
  this moment required by harfbuzz.
* Wed Nov 28 2012 crrodriguez@opensuse.org
- graphite2-arm.patch :Fix build in arm and possible other platforms, we should
  notuse -nodefaultlibs as a linker flag and let the system
  do its job automatically.
- freetype-devel should be freetype2-devel
* Tue Nov 13 2012 cfarrell@suse.com
- license update: LGPL-2.1+ or GPL-2.0+ or MPL-1.1
  See License file (most source code notices concur)
* Mon Nov 12 2012 tchvatal@suse.com
- Whitespace trying to figure out why spec file is interpreted as
  binary.
* Fri Nov  9 2012 tchvatal@suse.com
- Fix desc not to mention libexttextcat.
* Tue Nov  6 2012 tchvatal@suse.com
- Initial commit version 1.2.0.