File libreoffice-languagetool.spec of Package libreoffice-languagetool

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

# norootforbuild


Name:           libreoffice-languagetool
Version:        1.2
Release:        1
BuildRequires:  ant java-devel libreoffice-ure unzip
#!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 pl nl ro ru sk sv
License:        GPL
Group:          Productivity/Office/Suite
AutoReqProv:    on
PreReq:         libreoffice >= 3.0.99
Requires:       libreoffice >= 3.0.99
Requires:       jre >= 1.6
# 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
Summary:        Language Checker for LibreOffice
Url:            http://www.languagetool.org/
# cvs -z3 -d:pserver:anonymous@languagetool.cvs.sourceforge.net:/cvsroot/languagetool co -r V_0_9_9 -P 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
# rm libs/{activation.jar,jaxb-api.jar,jaxb-impl.jar,jsr173_1.0_api.jar}:
#    + part of JDK 1.6 => not needed
#    + under CDDL or GPL => remove them to avoid necessity to include the related sources
# 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
Source0:        JLanguageTool-%version.tar.bz2
# the Jaminid and jdic sources are unused during build but they should be in
# the package sources according to LGPL (bnc#487807)
# URL: http://jaminid.sourceforge.net/
# Version 0.99 is mentioned in libs/README
Source1:        Jaminid-0.99.tar.bz2
# URL: http://jdic.dev.java.net/
# Version 20061102 is mentioned in the cvs log
Source2:        jdic-20061102-src.tar.bz2
# helper script and data file to create pieces of the spec file
Source100:      lo-LanguageTool-data
Source101:      lo-LanguageTool-gen-spec
Patch0:         JLanguageTool-1.2-package-dicts-separately.diff
Patch1:         JLanguageTool-0.9.3-system-ooo-jars.diff
Patch2:         JLanguageTool-1.2-find-junit-jar.diff
Patch3:         JLanguageTool-0.9.9-ignore-jre-1.5.diff
BuildRoot:      %{_tmppath}/%{name}-%{version}-build
BuildArch:      noarch

%description
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.


########################################################
# Start of a section generated by lo-langtool-gen-spec
# Do not edit!
########################################################

#
# langtool dictionaries
#

%package -n libreoffice-languagetool-ca
License:        GPL
Summary:        Catalan Dictionary for LibreOffice Language Tool
Group:          Productivity/Office/Dictionary
Provides:       locale(libreoffice-languagetool:ca)
PreReq:         libreoffice-ure >= 2.99
Requires:       libreoffice-languagetool = %version
# compat stuff
Provides:       OpenOffice_org-LanguageTool-ca = %version
Obsoletes:      OpenOffice_org-LanguageTool-ca <= %version

%description -n libreoffice-languagetool-ca
The Catalan dictionary that can be used to check grammar and other more
complex mistakes using the LibreOffice language tool extension.



%package -n libreoffice-languagetool-de
License:        CCA-SA3.0
Summary:        German Dictionary for LibreOffice Language Tool
Group:          Productivity/Office/Dictionary
Provides:       locale(libreoffice-languagetool:de)
PreReq:         libreoffice-ure >= 2.99
Requires:       libreoffice-languagetool = %version
# compat stuff
Provides:       OpenOffice_org-LanguageTool-de = %version
Obsoletes:      OpenOffice_org-LanguageTool-de <= %version

%description -n libreoffice-languagetool-de
The German dictionary that can be used to check grammar and other more
complex mistakes using the LibreOffice language tool extension.



%package -n libreoffice-languagetool-en
License:        BSD3c, BSD4c, Public Domain, Freeware
Summary:        English Dictionary for LibreOffice Language Tool
Group:          Productivity/Office/Dictionary
Provides:       locale(libreoffice-languagetool:en)
PreReq:         libreoffice-ure >= 2.99
Requires:       libreoffice-languagetool = %version
# compat stuff
Provides:       OpenOffice_org-LanguageTool-en = %version
Obsoletes:      OpenOffice_org-LanguageTool-en <= %version

%description -n libreoffice-languagetool-en
The English dictionary that can be used to check grammar and other more
complex mistakes using the LibreOffice language tool extension.



%package -n libreoffice-languagetool-es
License:        GPL
Summary:        Spanish Dictionary for LibreOffice Language Tool
Group:          Productivity/Office/Dictionary
Provides:       locale(libreoffice-languagetool:es)
PreReq:         libreoffice-ure >= 2.99
Requires:       libreoffice-languagetool = %version
# compat stuff
Provides:       OpenOffice_org-LanguageTool-es = %version
Obsoletes:      OpenOffice_org-LanguageTool-es <= %version

%description -n libreoffice-languagetool-es
The Spanish dictionary that can be used to check grammar and other more
complex mistakes using the LibreOffice language tool extension.



%package -n libreoffice-languagetool-fr
License:        GPLv2.0, LGPLv2.1, MPLv1.1
Summary:        French Dictionary for LibreOffice Language Tool
Group:          Productivity/Office/Dictionary
Provides:       locale(libreoffice-languagetool:fr)
PreReq:         libreoffice-ure >= 2.99
Requires:       libreoffice-languagetool = %version
# compat stuff
Provides:       OpenOffice_org-LanguageTool-fr = %version
Obsoletes:      OpenOffice_org-LanguageTool-fr <= %version

%description -n libreoffice-languagetool-fr
The French dictionary that can be used to check grammar and other more
complex mistakes using the LibreOffice language tool extension.



%package -n libreoffice-languagetool-gl
License:        GPL
Summary:        Galician Dictionary for LibreOffice Language Tool
Group:          Productivity/Office/Dictionary
Provides:       locale(libreoffice-languagetool:gl)
PreReq:         libreoffice-ure >= 2.99
Requires:       libreoffice-languagetool = %version
# compat stuff
Provides:       OpenOffice_org-LanguageTool-gl = %version
Obsoletes:      OpenOffice_org-LanguageTool-gl <= %version

%description -n libreoffice-languagetool-gl
The Galician dictionary that can be used to check grammar and other more
complex mistakes using the LibreOffice language tool extension.



%package -n libreoffice-languagetool-it
License:        CCA-SA2.0, LGPL
Summary:        Italian Dictionary for LibreOffice Language Tool
Group:          Productivity/Office/Dictionary
Provides:       locale(libreoffice-languagetool:it)
PreReq:         libreoffice-ure >= 2.99
Requires:       libreoffice-languagetool = %version
# compat stuff
Provides:       OpenOffice_org-LanguageTool-it = %version
Obsoletes:      OpenOffice_org-LanguageTool-it <= %version

%description -n libreoffice-languagetool-it
The Italian dictionary that can be used to check grammar and other more
complex mistakes using the LibreOffice language tool extension.



%package -n libreoffice-languagetool-nl
License:        LGPL
Summary:        Dutch Dictionary for LibreOffice Language Tool
Group:          Productivity/Office/Dictionary
Provides:       locale(libreoffice-languagetool:nl)
PreReq:         libreoffice-ure >= 2.99
Requires:       libreoffice-languagetool = %version
# compat stuff
Provides:       OpenOffice_org-LanguageTool-nl = %version
Obsoletes:      OpenOffice_org-LanguageTool-nl <= %version

%description -n libreoffice-languagetool-nl
The Dutch dictionary that can be used to check grammar and other more
complex mistakes using the LibreOffice language tool extension.



%package -n libreoffice-languagetool-pl
License:        LGPL
Summary:        Polish Dictionary for LibreOffice Language Tool
Group:          Productivity/Office/Dictionary
Provides:       locale(libreoffice-languagetool:pl)
PreReq:         libreoffice-ure >= 2.99
Requires:       libreoffice-languagetool = %version
# compat stuff
Provides:       OpenOffice_org-LanguageTool-pl = %version
Obsoletes:      OpenOffice_org-LanguageTool-pl <= %version

%description -n libreoffice-languagetool-pl
The Polish dictionary that can be used to check grammar and other more
complex mistakes using the LibreOffice language tool extension.



%package -n libreoffice-languagetool-ro
License:        LGPL
Summary:        Romanian Dictionary for LibreOffice Language Tool
Group:          Productivity/Office/Dictionary
Provides:       locale(libreoffice-languagetool:ro)
PreReq:         libreoffice-ure >= 2.99
Requires:       libreoffice-languagetool = %version
# compat stuff
Provides:       OpenOffice_org-LanguageTool-ro = %version
Obsoletes:      OpenOffice_org-LanguageTool-ro <= %version

%description -n libreoffice-languagetool-ro
The Romanian dictionary that can be used to check grammar and other more
complex mistakes using the LibreOffice language tool extension.



%package -n libreoffice-languagetool-ru
License:        LGPL
Summary:        Russian Dictionary for LibreOffice Language Tool
Group:          Productivity/Office/Dictionary
Provides:       locale(libreoffice-languagetool:ru)
PreReq:         libreoffice-ure >= 2.99
Requires:       libreoffice-languagetool = %version
# compat stuff
Provides:       OpenOffice_org-LanguageTool-ru = %version
Obsoletes:      OpenOffice_org-LanguageTool-ru <= %version

%description -n libreoffice-languagetool-ru
The Russian dictionary that can be used to check grammar and other more
complex mistakes using the LibreOffice language tool extension.



%package -n libreoffice-languagetool-sk
License:        LGPL
Summary:        Slovak Dictionary for LibreOffice Language Tool
Group:          Productivity/Office/Dictionary
Provides:       locale(libreoffice-languagetool:sk)
PreReq:         libreoffice-ure >= 2.99
Requires:       libreoffice-languagetool = %version
# compat stuff
Provides:       OpenOffice_org-LanguageTool-sk = %version
Obsoletes:      OpenOffice_org-LanguageTool-sk <= %version

%description -n libreoffice-languagetool-sk
The Slovak dictionary that can be used to check grammar and other more
complex mistakes using the LibreOffice language tool extension.



%package -n libreoffice-languagetool-sv
License:        LGPL
Summary:        Swedish Dictionary for LibreOffice Language Tool
Group:          Productivity/Office/Dictionary
Provides:       locale(libreoffice-languagetool:sv)
PreReq:         libreoffice-ure >= 2.99
Requires:       libreoffice-languagetool = %version
# compat stuff
Provides:       OpenOffice_org-LanguageTool-sv = %version
Obsoletes:      OpenOffice_org-LanguageTool-sv <= %version

%description -n libreoffice-languagetool-sv
The Swedish dictionary that can be used to check grammar and other more
complex mistakes using the LibreOffice language tool extension.



######################################################
# End of a section generated by lo-langtool-gen-spec
######################################################


%prep
%setup -q -a1 -n JLanguageTool-%version
%patch0
%patch1
%patch2
%patch3
mkdir jdic
tar -xjf %{S:2} -C jdic
cp libs/README libs/README-libs.txt

%build
ant -Dsys.ooo.dir=%{_libdir}/%ooo_home dist

%install
# 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
export NO_BRP_CHECK_BYTECODE_VERSION="true"
# main package
oxt=$(pwd)/dist/LanguageTool-%version.oxt
mkdir -p $RPM_BUILD_ROOT%_datadir/%ooo_home/share/extensions/languagetool-%version
cd $RPM_BUILD_ROOT%_datadir/%ooo_home/share/extensions/languagetool-%version
unzip "$oxt"
cd - >/dev/null 2>&1 
# dictionaries
for lang in %langtool_langs ; do
    # dir
    mkdir -p $RPM_BUILD_ROOT%_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
	filename=${file#src/resource/$lang/}
	cp $file $RPM_BUILD_ROOT%_datadir/%ooo_home/ure/lib/resource/$lang/$filename
	echo "%_datadir/%ooo_home/ure/lib/resource/$lang/$filename" >>files-langtool-$lang.txt
    done
    cp files-langtool-$lang.txt $RPM_BUILD_ROOT%_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
done

%clean
rm -rf $RPM_BUILD_ROOT

%files
%defattr(-,root,root)
%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
%_datadir/%ooo_home/share/extensions/languagetool-%version

%pre
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;
    fi
    # explain errors if extension that was added by OOo-LanguageTool and OOo packages
    echo
    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!"
    echo
fi

%post
# link to the directory where the extenisons is automatically detected
mkdir -p %ooo_prefix/%ooo_home/share/extensions || exit 0;
ln -sf %_datadir/%ooo_home/share/extensions/languagetool-%version %ooo_prefix/%ooo_home/share/extensions/languagetool-%version || exit 0;

%postun
# remove the arch-dependent link from /usr/lib(64)
link=%ooo_prefix/%ooo_home/share/extensions/languagetool-%version
test -L "$link" -a ! -r "$link" && rm "$link" || exit 0;

########################################################
# Start of a section generated by lo-langtool-gen-spec
# Do not edit!
########################################################

#
# langtool dictionaries
#

# ca

%posttrans -n libreoffice-languagetool-ca
%_datadir/%ooo_home/link-to-ooo-home %_datadir/%ooo_home/files-langtool-ca.txt || true

%preun -n libreoffice-languagetool-ca
test "$1" = "0" && %_datadir/%ooo_home/link-to-ooo-home --unlink %_datadir/%ooo_home/files-langtool-ca.txt || true
# de

%posttrans -n libreoffice-languagetool-de
%_datadir/%ooo_home/link-to-ooo-home %_datadir/%ooo_home/files-langtool-de.txt || true

%preun -n libreoffice-languagetool-de
test "$1" = "0" && %_datadir/%ooo_home/link-to-ooo-home --unlink %_datadir/%ooo_home/files-langtool-de.txt || true
# en

%posttrans -n libreoffice-languagetool-en
%_datadir/%ooo_home/link-to-ooo-home %_datadir/%ooo_home/files-langtool-en.txt || true

%preun -n libreoffice-languagetool-en
test "$1" = "0" && %_datadir/%ooo_home/link-to-ooo-home --unlink %_datadir/%ooo_home/files-langtool-en.txt || true
# es

%posttrans -n libreoffice-languagetool-es
%_datadir/%ooo_home/link-to-ooo-home %_datadir/%ooo_home/files-langtool-es.txt || true

%preun -n libreoffice-languagetool-es
test "$1" = "0" && %_datadir/%ooo_home/link-to-ooo-home --unlink %_datadir/%ooo_home/files-langtool-es.txt || true
# fr

%posttrans -n libreoffice-languagetool-fr
%_datadir/%ooo_home/link-to-ooo-home %_datadir/%ooo_home/files-langtool-fr.txt || true

%preun -n libreoffice-languagetool-fr
test "$1" = "0" && %_datadir/%ooo_home/link-to-ooo-home --unlink %_datadir/%ooo_home/files-langtool-fr.txt || true
# gl

%posttrans -n libreoffice-languagetool-gl
%_datadir/%ooo_home/link-to-ooo-home %_datadir/%ooo_home/files-langtool-gl.txt || true

%preun -n libreoffice-languagetool-gl
test "$1" = "0" && %_datadir/%ooo_home/link-to-ooo-home --unlink %_datadir/%ooo_home/files-langtool-gl.txt || true
# it

%posttrans -n libreoffice-languagetool-it
%_datadir/%ooo_home/link-to-ooo-home %_datadir/%ooo_home/files-langtool-it.txt || true

%preun -n libreoffice-languagetool-it
test "$1" = "0" && %_datadir/%ooo_home/link-to-ooo-home --unlink %_datadir/%ooo_home/files-langtool-it.txt || true
# nl

%posttrans -n libreoffice-languagetool-nl
%_datadir/%ooo_home/link-to-ooo-home %_datadir/%ooo_home/files-langtool-nl.txt || true

%preun -n libreoffice-languagetool-nl
test "$1" = "0" && %_datadir/%ooo_home/link-to-ooo-home --unlink %_datadir/%ooo_home/files-langtool-nl.txt || true
# pl

%posttrans -n libreoffice-languagetool-pl
%_datadir/%ooo_home/link-to-ooo-home %_datadir/%ooo_home/files-langtool-pl.txt || true

%preun -n libreoffice-languagetool-pl
test "$1" = "0" && %_datadir/%ooo_home/link-to-ooo-home --unlink %_datadir/%ooo_home/files-langtool-pl.txt || true
# ro

%posttrans -n libreoffice-languagetool-ro
%_datadir/%ooo_home/link-to-ooo-home %_datadir/%ooo_home/files-langtool-ro.txt || true

%preun -n libreoffice-languagetool-ro
test "$1" = "0" && %_datadir/%ooo_home/link-to-ooo-home --unlink %_datadir/%ooo_home/files-langtool-ro.txt || true
# ru

%posttrans -n libreoffice-languagetool-ru
%_datadir/%ooo_home/link-to-ooo-home %_datadir/%ooo_home/files-langtool-ru.txt || true

%preun -n libreoffice-languagetool-ru
test "$1" = "0" && %_datadir/%ooo_home/link-to-ooo-home --unlink %_datadir/%ooo_home/files-langtool-ru.txt || true
# sk

%posttrans -n libreoffice-languagetool-sk
%_datadir/%ooo_home/link-to-ooo-home %_datadir/%ooo_home/files-langtool-sk.txt || true

%preun -n libreoffice-languagetool-sk
test "$1" = "0" && %_datadir/%ooo_home/link-to-ooo-home --unlink %_datadir/%ooo_home/files-langtool-sk.txt || true
# sv

%posttrans -n libreoffice-languagetool-sv
%_datadir/%ooo_home/link-to-ooo-home %_datadir/%ooo_home/files-langtool-sv.txt || true

%preun -n libreoffice-languagetool-sv
test "$1" = "0" && %_datadir/%ooo_home/link-to-ooo-home --unlink %_datadir/%ooo_home/files-langtool-sv.txt || true
#
# langtool dictionaries
#

%files -f files-langtool-ca.txt -n libreoffice-languagetool-ca
%defattr(-,root,root)
%doc src/resource/ca/README

%files -f files-langtool-de.txt -n libreoffice-languagetool-de
%defattr(-,root,root)
%doc src/resource/de/{errors.txt,tagset.txt}

%files -f files-langtool-en.txt -n libreoffice-languagetool-en
%defattr(-,root,root)
%doc src/resource/en/{12dicts-readme.html,agid-readme.txt,errors.txt,pos-readme.txt}

%files -f files-langtool-es.txt -n libreoffice-languagetool-es
%defattr(-,root,root)
%doc src/resource/es/{README,README.cvs}

%files -f files-langtool-fr.txt -n libreoffice-languagetool-fr
%defattr(-,root,root)
%doc src/resource/fr/README_lexique.txt

%files -f files-langtool-gl.txt -n libreoffice-languagetool-gl
%defattr(-,root,root)
%doc src/resource/gl/{LICENSE,README,README.cvs}

%files -f files-langtool-it.txt -n libreoffice-languagetool-it
%defattr(-,root,root)
%doc src/resource/it/readme-morph-it.txt

%files -f files-langtool-nl.txt -n libreoffice-languagetool-nl
%defattr(-,root,root)

%files -f files-langtool-pl.txt -n libreoffice-languagetool-pl
%defattr(-,root,root)

%files -f files-langtool-ro.txt -n libreoffice-languagetool-ro
%defattr(-,root,root)

%files -f files-langtool-ru.txt -n libreoffice-languagetool-ru
%defattr(-,root,root)

%files -f files-langtool-sk.txt -n libreoffice-languagetool-sk
%defattr(-,root,root)
%doc src/resource/sk/README

%files -f files-langtool-sv.txt -n libreoffice-languagetool-sv
%defattr(-,root,root)

######################################################
# End of a section generated by lo-langtool-gen-spec
######################################################

%changelog
openSUSE Build Service is sponsored by