File of Package libreoffice-languagetool.627

# spec file for package libreoffice-languagetool
# Copyright (c) 2012 SUSE LINUX Products 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

Name:           libreoffice-languagetool
Version:        1.4
Release:        0
#!BuildIgnore:  libreoffice
%define	        ooo_prefix      %{_libdir}
%define	        ooo_home        libreoffice
# ignore cs because of an unlclear license; also unsupported
# ignore sk unknown license; almost empty dictionary
# ignore uk (unsupported)
%define	        langtool_langs  ca de en es fr gl it km pl nl ro ru sk sv
Summary:        Language Checker for LibreOffice
License:        @ALL_LICENSES@
Group:          Productivity/Office/Suite
# svn co languagetool
# cd tags/V_1_4/JLanguageTool
# rm src/resource/cs/{*.dict,*.info}  because of unclear licese; also it is not longer supported (only a bachelor's thesis)
# rm src/resource/uk/{*.dict,*.info}  because of unclear licese
# rm src/resource/ml/{*.dict,*.info}  because of unclear licese
# rm -rf libs/ooo
#    + we use these jars from our libreoffice packages
# FIXME: wanted to remove libs/commons-logging-1.1.1.jar but it was not available on SLED11
#        it is small file (60kB) => it is not worth doing special hacks for SLED11 and other distros
# NOTE: jakarta-regexp-1.4.jar uses the Apache License, v2.0, see
Source0:        JLanguageTool-%{version}.tar.bz2
# helper files to generate the spec file
Source101:      lo-languagetool-data
Source102:      lo-languagetool-gen-spec
# PATCH-FIX-OPENSUSE ignore dictionaries that are not installed; it allows to package them separately
Patch0:         JLanguageTool-1.4-package-dicts-separately.diff
# PATCH-FIX-OPENSUSE use the system libreoffice jars
Patch1:         JLanguageTool-0.9.3-system-ooo-jars.diff
# do not use the broken help; unopkg complained about it when registering extensions
# FIXME: the right fix is to compile the help and produce the .db_, .ht_, and other files
Patch2:         JLanguageTool-1.4-no-broken-help.diff
BuildRequires:  ant
BuildRequires:  java-devel
BuildRequires:  libreoffice >= 3.5
BuildRequires:  unzip
# dependencies for post install scripts
%if 0%{?suse_version} > 01120
Requires(post):   coreutils
Requires(post):   grep
Requires(post):   libreoffice >= 3.5
Requires(postun): coreutils
Requires(postun): grep
Requires(postun): libreoffice >= 3.5
%if 0%{?suse_version} && 0%{?suse_version} <= 01120
PreReq:         coreutils
PreReq:         grep
PreReq:         libreoffice >= 3.5
Requires:       jre >= 1.6
Requires:       libreoffice >= 3.5
# the Czech stuff newer worked; the package was created by mistake
Obsoletes:      OpenOffice_org-LanguageTool-cs < 0.9.9
# compat stuff
Provides:       OpenOffice_org-LanguageTool = %{version}
Obsoletes:      OpenOffice_org-LanguageTool <= %{version}
BuildRoot:      %{_tmppath}/%{name}-%{version}-build
BuildArch:      noarch

This package provides the language checker extension for
LibreOffice. It allows to detect errors that a simple spell checker
cannot detect, e.g. mixing up there/their, no/now etc. It can also
detect some grammar mistakes. It does not include spell checking.

The language checker uses special dictionaries that are provided by the
libreoffice-languagetool-<lang> packages.

%setup -q -n JLanguageTool-%{version}
cp libs/README libs/README-libs.txt

ant{_libdir}/%ooo_home dist

# skip the check for java bytecode version; it uses some jar files prebuilt with JRE-1.6
# can't be complied with JDK-1.5; the dependency on JRE-1.5 is solved at runtime
# main package
mkdir -p %{buildroot}%{_datadir}/%ooo_home/share/extensions/languagetool-%{version}
cd %{buildroot}%{_datadir}/%ooo_home/share/extensions/languagetool-%{version}
unzip "$oxt"
cd - >/dev/null 2>&1
# dictionaries
for lang in %langtool_langs ; do
    # dir
    mkdir -p %{buildroot}%{_datadir}/%ooo_home/ure/lib/resource/$lang
    echo "%dir %{_datadir}/%ooo_home" >files-langtool-$lang.txt
    echo "%dir %{_datadir}/%ooo_home/ure" >>files-langtool-$lang.txt
    echo "%dir %{_datadir}/%ooo_home/ure/lib" >>files-langtool-$lang.txt
    echo "%dir %{_datadir}/%ooo_home/ure/lib/resource" >>files-langtool-$lang.txt
    echo "%dir %{_datadir}/%ooo_home/ure/lib/resource/$lang" >>files-langtool-$lang.txt
    # files
    for file in src/resource/$lang/{*.dict,*.info} ; do
	cp $file %{buildroot}%{_datadir}/%ooo_home/ure/lib/resource/$lang/$filename
	echo "%{_datadir}/%ooo_home/ure/lib/resource/$lang/$filename" >>files-langtool-$lang.txt
    cp files-langtool-$lang.txt %{buildroot}%{_datadir}/%ooo_home
    echo "%{_datadir}/%ooo_home/files-langtool-$lang.txt" >>files-langtool-$lang.txt
    # common README.txt
    echo "%doc README.txt" >>files-langtool-$lang.txt
# we need to create architecture dependent symlinks even for the main package
# create file list for link-to-ooo-home script
find %{buildroot}%{_datadir}/%ooo_home/share/extensions/languagetool-%{version}/ -type d \
     -printf "%%%%dir %{_datadir}/%ooo_home/share/extensions/languagetool-%{version}/%%P\n" \
find %{buildroot}%{_datadir}/%ooo_home/share/extensions/languagetool-%{version}/ -type f \
     -printf "%{_datadir}/%ooo_home/share/extensions/languagetool-%{version}/%%P\n" \
cp files-langtool.txt %{buildroot}%{_datadir}/%ooo_home
echo "%{_datadir}/%ooo_home/files-langtool.txt" >>files-langtool.txt

rm -rf %{buildroot}

%files -f files-langtool.txt
%doc CHANGES.txt COPYING.txt README.txt libs/*.txt libs/build/junit-license.txt
%dir %{_datadir}/%ooo_home
%dir %{_datadir}/%ooo_home/share
%dir %{_datadir}/%ooo_home/share/extensions

if test -f %{_datadir}/ooo3/share/extension/install/LanguageTool-*.oxt ; then
    # unregister the extension that was added by OOo-LanguageTool and LO packages
    if unopkg list --shared | grep -q "org.openoffice.languagetool.oxt" ; then
        unopkg remove --shared org.openoffice.languagetool.oxt || true;
    # explain errors if extension that was added by OOo-LanguageTool and OOo packages
    echo "WARNING: Please ignore the following error about the extension:"
    echo "WARNING:     org.openoffice.languagetool.oxt"
    echo "WARNING: It is printed by the old OpenOffice_org package. The extension cannot"
    echo "WARNING: be unregistered from the OOo cache because unopkg tool already"
    echo "WARNING: works with the LO cache. The LO installation will be correct!"
# the initial libreoffice packages symlinked the whole directory a wrong way (bnc#677354)
for link in "/usr/lib/$home_path" "/usr/lib64/$home_path" ; do
    test -L "$link" && rm "$link" || true

# link to the directory where the extenisons is automatically detected
%{_datadir}/%ooo_home/link-to-ooo-home %{_datadir}/%ooo_home/files-langtool.txt || true

# update UNO cache for bundled extensions
%{_sbindir}/unopkg-sync-bundled || true

test "$1" = "0" && cp %{_datadir}/%ooo_home/files-langtool.txt %{_datadir}/%ooo_home/files-langtool.txt.postun || true

test "$1" = "0" && %{_datadir}/%ooo_home/link-to-ooo-home --unlink %{_datadir}/%ooo_home/files-langtool.txt.postun || true
rm -f %{_datadir}/%ooo_home/files-langtool.txt.postun 2>/dev/null
# update UNO cache for bundled extensions
%{_sbindir}/unopkg-sync-bundled || true

openSUSE Build Service is sponsored by