LogoopenSUSE Build Service > Projects
Sign Up | Log In

View File libreoffice-languagetool.spec.in of Package libreoffice-languagetool (Project LibreOffice:Stable)

# 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 http://bugs.opensuse.org/

Name:           libreoffice-languagetool
Version:        2.0
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  ast br ca da de en es fr gl it km pl nl ro ru sk sv tl zh
Summary:        Language Checker for LibreOffice
License:        @ALL_LICENSES@
Group:          Productivity/Office/Suite
Url:            http://www.languagetool.org/
# svn co https://languagetool.svn.sourceforge.net/svnroot/languagetool languagetool
# cd tags/V_1_4/JLanguageTool
# rm -rf src/main/resources/org/languagetool/resource/be/*  because of unclear licese
# rm -rf src/main/resources/org/languagetool/resource/cs/*  because of unclear licese; also it is not longer supported (only a bachelor's thesis)
# rm -rf src/main/resources/org/languagetool/resource/el/*  because of unclear licese
# rm -rf src/main/resources/org/languagetool/resource/eo/*  because of unclear licese
# rm -rf src/main/resources/org/languagetool/resource/is/*  unused
# rm -rf src/main/resources/org/languagetool/resource/lt/*  unused
# rm -rf src/main/resources/org/languagetool/resource/ml/*  because of unclear licese
# rm -rf src/main/resources/org/languagetool/resource/pt/*  because of unclear licese
# rm -rf src/main/resources/org/languagetool/resource/sl/*  because of unclear licese and looks pretty incomplete
# rm -rf src/main/resources/org/languagetool/resource/uk/*  because of unclear licese
# rm -rf libs/ooo
#    + we use these jars from our libreoffice packages
# rm -rf libs/native-lib
#    + we want to use the system libs; also the sources are missing
# rm -f libs/jna.jar           because of missing source code; needed only for web stuff
# rm -f libs/junit-4.7.jar     because of missing source code and is unused
# rm -f libs/swc-*.jar         because of missing source code; unused???
# 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: lucene-analyzers-common-4.0.0-BETA.jar, uses the Apache License, v2.0, see the jar file, see http://grepcode.com/snapshot/repo1.maven.org/maven2/org.apache.lucene/lucene-analyzers-common/4.0.0, and http://lucene.apache.org/
# NOTE: lucene-sandbox-4.0.0-BETA.jar, uses the Apache License, v2.0, see the jar file, see http://grepcode.com/snapshot/repo1.maven.org/maven2/org.apache.lucene/lucene-sandbox/4.0.0, and http://lucene.apache.org/
# NOTE: randomizedtesting-runner-1.6.0.jar, uses the Apache License, v2.0, see the jar file, http://grepcode.com/snapshot/repo1.maven.org/maven2/com.carrotsearch.randomizedtesting/randomizedtesting-runner/1.6.0, and http://labs.carrotsearch.com/randomizedtesting.html
# NOTE: jakarta-regexp-1.4.jar uses the Apache License, v2.0, see http://archive.apache.org/dist/jakarta/regexp/jakarta-regexp-1.4.tar.gz
Source0:        languagetool-%{version}.tar.xz
# the following sources are needed to fulfill the license terms
# http://www.versioneye.com/package/com~google~code--lucene-gosen-ipadic
Source1:        lucene-gosen-ipadic-1.2.1-sources.jar
# http://sourceforge.net/projects/junit/files/junit/4.10/
Source2:        junit-4.10-src.jar
# http://pt.sourceforge.jp/projects/sfnet_plog4u/downloads/Wikipedia%20Syntax%20API/wp_api.3.0.3/bliki.3.0.3.zip/
Source3:        bliki-3.0.3.tar.xz
# http://grepcode.com/snapshot/repo1.maven.org/maven2/net.java.dev.jna/jna/3.4.0
Source4:        jna-3.4.0-sources.jar
# swc-*.jar sources found tat http://cs.nyu.edu/rgrimm/xtc/
Source5:        xtc-core-1.15.0.zip
# helper files to generate the spec file
Source100:      libreoffice-languagetool.spec.in
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:         languagetool-2.0-package-dicts-separately.patch
# PATCH-FIX-OPENSUSE use the system libreoffice jars
Patch1:         languagetool-2.0-system-lo-jars.patch
# do not use the broken help; LO complains about it when registering extensions
# FIXME: the right fix is to compile the help and produce the .db_, .ht_, and other files
Patch2:         languagetool-2.0-no-broken-help.patch
# LO does not know some language variants and shows ugly entries when editing "Tools/Options/Langauge Settings/Writing Aids/Available Language Modules"
Patch3:         languagetool-2.0-remove-problematic-language-variants.patch
BuildRequires:  ant
BuildRequires:  java-devel
BuildRequires:  libreoffice >= 3.5
BuildRequires:  unzip
BuildRequires:  xz
# 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 languagetool-%{version}
%patch0 -p1
%patch1 -p1
%patch2 -p1
%patch3 -p1
cp libs/README libs/README-libs.txt

ant -Dsys.lo.dir=%{_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
# 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" \
echo "%{_datadir}/%ooo_home/files-langtool.txt" >>files-langtool.txt
# dictionaries
for lang in %langtool_langs ; do
    grep "$dict_pattern" files-langtool.txt >files-langtool-$lang.txt
    grep -v "$dict_pattern" files-langtool.txt >files-langtool.txt.new
    mv files-langtool.txt.new files-langtool.txt
    # add top level diretories which have to be removed on unistall
    echo "%dir %_datadir/%ooo_home/share/extensions/languagetool-%version"                                 >>files-langtool-$lang.txt
    echo "%dir %_datadir/%ooo_home/share/extensions/languagetool-%version/org"                             >>files-langtool-$lang.txt
    echo "%dir %_datadir/%ooo_home/share/extensions/languagetool-%version/org/languagetool"                >>files-langtool-$lang.txt
    echo "%dir %_datadir/%ooo_home/share/extensions/languagetool-%version/org/languagetool/resource"       >>files-langtool-$lang.txt
    echo "%dir %_datadir/%ooo_home/share/extensions/languagetool-%version/org/languagetool/resource/$lang" >>files-langtool-$lang.txt
    # copy the finalized lang filelist for symlinking
    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
# copy the finalized main filelist for symlinking
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

# 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

# we will need to remove symlinks that are not longer valid
cp %{_datadir}/%ooo_home/files-langtool.txt %{_datadir}/%ooo_home/files-langtool.txt.postun || true

# remove symlinks that are not longer valid
grep -q "unlink-dirs" %{_datadir}/%ooo_home/link-to-ooo-home && unlink_options="$unlink_options --unlink-dirs" || true
%{_datadir}/%ooo_home/link-to-ooo-home $unlink_options %{_datadir}/%ooo_home/files-langtool.txt.postun || true
rm -f %{_datadir}/%ooo_home/files-langtool.txt.postun || true

# the previous versions did not remove the symlinks correctly when updating
for libdir in "%{_prefix}/lib" "%{_prefix}/lib64" ; do
    for extension_dir in "%ooo_home/share/extensions/languagetool-1.2" \
                         "%ooo_home/share/extensions/languagetool-1.4" ; do
        test -d "$libdir/$extension_dir" && rm -rf "$libdir/$extension_dir" || true