File libreoffice-thesaurus.spec of Package libreoffice-thesaurus

#
# spec file for package libreoffice-thesaurus
#
# 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-thesaurus
###################################################################
## DO NOT EDIT THIS SPEC FILE
## Generated by:
## perl libreoffice-thesaurus-gen-spec libreoffice-thesaurus.spec.in libreoffice-thesaurus.data
###################################################################
BuildRequires:  dos2unix recode unzip
License:        GPLv2+
Group:          Productivity/Office/Dictionary
AutoReqProv:    on
Version:        20110202
Release:        1
Summary:        A Source Package for LibreOffice Thesaurus Dictionaries
BuildRoot:      %{_tmppath}/%{name}-%{version}-build
BuildArch:      noarch
Url:            http://wiki.services.openoffice.org/wiki/Dictionaries
Source0:        libreoffice-thesaurus-gen-spec
Source1:        libreoffice-thesaurus.spec.in
Source2:        libreoffice-thesaurus.data
Source1000:     thes_bg_BG_v2.tar.bz2
Source1001:     thesaurus-ca.oxt
Source1002:     thes_cs_CZ_v2.tar.bz2
Source1003:     DanskeSynonymer.oxt
Source1004:     dict-de_DE-frami_2010-03-07.oxt
Source1005:     dict-de_AT-frami_2010-03-07.oxt
Source1006:     dict-de_CH-frami_2010-03-07.oxt
Source1007:     th_el.tar.bz2
Source1008:     dict-en-au-2008-12-15.oxt
Source1009:     thes_en_GB_v2.tar.bz2
Source1010:     thes_en_US_v2.tar.bz2
Source1011:     thes_es_ES_v2.tar.bz2
Source1012:     Diccionarios-Argentina_1.oxt
Source1013:     dict-es_VE.oxt
Source1014:     ooo-dictionnaire-fr-reforme1990-v3.5.oxt
Source1015:     focloiri-gaeilge-4.4.oxt
Source1016:     thes_hu_HU_v2.tar.bz2
Source1017:     Dizionari.IT_20081129.oxt
Source1018:     thes_nb_NO_v2.tar.bz2
Source1019:     thes_ne_NP_v2.tar.bz2
Source1020:     pl-dict.oxt
Source1021:     oo3x-pt-PT.oxt
Source1022:     dict-ro.1.1.oxt
Source1023:     dict_ru_RU-0.3.4.oxt
Source1024:     dict-sk.oxt
Source1025:     thes_sl_SI_v2.tar.bz2
Source1026:     SwedishThesaurus.oxt

%description
This source package is used to build LibreOffice thesaurus
dictionaries.



%package bg
License:        GPLv2+
Version:        20071210
Release:        1
Group:          Productivity/Office/Dictionary
Summary:        Bulgarian Thesaurus Dictionary for LibreOffice
Provides:       locale(libreoffice:bg) locale(OpenOffice_org:bg)
# compat stuff
Provides:       OpenOffice_org:/usr/lib/ooo-2.0/share/dict/ooo/th_bg_BG_v2.dat
Provides:       OpenOffice_org-thesaurus-bg = %version
Obsoletes:      OpenOffice_org-thesaurus-bg <= %version

%description bg
The Bulgarian thesaurus dictionary that can be used to look up for
synonyms and related words in the LibreOffice office suite.



%package ca
License:        GPLv2, LGPLv2.1
Version:        1.5.0
Release:        1
Group:          Productivity/Office/Dictionary
Summary:        Catalan Thesaurus Dictionary for LibreOffice
Provides:       locale(libreoffice:ca) locale(OpenOffice_org:ca)
# compat stuff
Provides:       OpenOffice_org:/usr/lib/ooo-2.0/share/dict/ooo/th_ca_ES_v2.dat
Provides:       OpenOffice_org-thesaurus-ca = %version
Obsoletes:      OpenOffice_org-thesaurus-ca <= %version

%description ca
The Catalan thesaurus dictionary that can be used to look up for
synonyms and related words in the LibreOffice office suite.



%package cs
License:        BSD3c
Version:        20070913
Release:        1
Group:          Productivity/Office/Dictionary
Summary:        Czech Thesaurus Dictionary for LibreOffice
Provides:       locale(libreoffice:cs) locale(OpenOffice_org:cs)
# compat stuff
Provides:       OpenOffice_org:/usr/lib/ooo-2.0/share/dict/ooo/th_cs_CZ_v2.dat
Provides:       OpenOffice_org-thesaurus-cs = %version
Obsoletes:      OpenOffice_org-thesaurus-cs <= %version

%description cs
The Czech thesaurus dictionary that can be used to look up for
synonyms and related words in the LibreOffice office suite.



%package da
License:        GPLv2, LGPLv2.1, MPLv1.1
Version:        20100126
Release:        1
Group:          Productivity/Office/Dictionary
Summary:        Danish Thesaurus Dictionary for LibreOffice
Provides:       locale(libreoffice:da) locale(OpenOffice_org:da)
# compat stuff
Provides:       OpenOffice_org:/usr/lib/ooo-2.0/share/dict/ooo/th_da_DK_v2.dat
Provides:       OpenOffice_org-thesaurus-da = %version
Obsoletes:      OpenOffice_org-thesaurus-da <= %version

%description da
The Danish thesaurus dictionary that can be used to look up for
synonyms and related words in the LibreOffice office suite.



%package de
License:        LGPLv2.1+
Version:        20100307
Release:        1
Group:          Productivity/Office/Dictionary
Summary:        German Thesaurus Dictionary for LibreOffice
Provides:       locale(libreoffice:de) locale(OpenOffice_org:de)
# compat stuff
Provides:       OpenOffice_org:/usr/lib/ooo-2.0/share/dict/ooo/th_de_DE_v2.dat
Provides:       OpenOffice_org-thesaurus-de = %version
Obsoletes:      OpenOffice_org-thesaurus-de <= %version

%description de
The German thesaurus dictionary that can be used to look up for
synonyms and related words in the LibreOffice office suite.



%package de-AT
License:        LGPLv2.1+
Version:        20100307
Release:        1
Group:          Productivity/Office/Dictionary
Summary:        Austrian Thesaurus Dictionary for LibreOffice
Provides:       locale(libreoffice:de_AT) locale(OpenOffice_org:de_AT)
# compat stuff
Provides:       OpenOffice_org:/usr/lib/ooo-2.0/share/dict/ooo/th_de_AT_v2.dat
Provides:       OpenOffice_org-thesaurus-de-AT = %version
Obsoletes:      OpenOffice_org-thesaurus-de-AT <= %version

%description de-AT
The Austrian thesaurus dictionary that can be used to look up for
synonyms and related words in the LibreOffice office suite.



%package de-CH
License:        LGPLv2.1+
Version:        20100307
Release:        1
Group:          Productivity/Office/Dictionary
Summary:        German-Swiss Thesaurus Dictionary for LibreOffice
Provides:       locale(libreoffice:de_CH) locale(OpenOffice_org:de_CH)
# compat stuff
Provides:       OpenOffice_org:/usr/lib/ooo-2.0/share/dict/ooo/th_de_CH_v2.dat
Provides:       OpenOffice_org-thesaurus-de-CH = %version
Obsoletes:      OpenOffice_org-thesaurus-de-CH <= %version

%description de-CH
The German-Swiss thesaurus dictionary that can be used to look up for
synonyms and related words in the LibreOffice office suite.



%package el
License:        GPLv2+
Version:        20061203
Release:        1
Group:          Productivity/Office/Dictionary
Summary:        Greek Thesaurus Dictionary for LibreOffice
Provides:       locale(libreoffice:el) locale(OpenOffice_org:el)
# compat stuff
Provides:       OpenOffice_org:/usr/lib/ooo-2.0/share/dict/ooo/th_el_GR_v2.dat
Provides:       OpenOffice_org-thesaurus-el = %version
Obsoletes:      OpenOffice_org-thesaurus-el <= %version

%description el
The Greek thesaurus dictionary that can be used to look up for
synonyms and related words in the LibreOffice office suite.



%package en-AU
License:        BSD4c
Version:        20081215
Release:        1
Group:          Productivity/Office/Dictionary
Summary:        Australian Thesaurus Dictionary for LibreOffice
Provides:       locale(libreoffice:en_AU) locale(OpenOffice_org:en_AU)
# compat stuff
Provides:       OpenOffice_org:/usr/lib/ooo-2.0/share/dict/ooo/th_en_AU_v2.dat
Provides:       OpenOffice_org-thesaurus-en-AU = %version
Obsoletes:      OpenOffice_org-thesaurus-en-AU <= %version

%description en-AU
The Australian thesaurus dictionary that can be used to look up for
synonyms and related words in the LibreOffice office suite.



%package en-GB
License:        BSD4c
Version:        20051128
Release:        1
Group:          Productivity/Office/Dictionary
Summary:        British Thesaurus Dictionary for LibreOffice
Provides:       locale(libreoffice:en_GB) locale(OpenOffice_org:en_GB)
# compat stuff
Provides:       OpenOffice_org:/usr/lib/ooo-2.0/share/dict/ooo/th_en_GB_v2.dat
Provides:       OpenOffice_org-thesaurus-en-GB = %version
Obsoletes:      OpenOffice_org-thesaurus-en-GB <= %version

%description en-GB
The British thesaurus dictionary that can be used to look up for
synonyms and related words in the LibreOffice office suite.



%package en-US
License:        BSD4c
Version:        20060111
Release:        1
Group:          Productivity/Office/Dictionary
Summary:        American Thesaurus Dictionary for LibreOffice
Provides:       locale(libreoffice:en_US) locale(OpenOffice_org:en_US)
# compat stuff
Provides:       OpenOffice_org:/usr/lib/ooo-2.0/share/dict/ooo/th_en_US_v2.dat
Provides:       OpenOffice_org-thesaurus-en-US = %version
Obsoletes:      OpenOffice_org-thesaurus-en-US <= %version
Provides:       OpenOffice_org-thesaurus-en = 20060111
Obsoletes:      OpenOffice_org-thesaurus-en <= 20060111

%description en-US
The American thesaurus dictionary that can be used to look up for
synonyms and related words in the LibreOffice office suite.



%package es
License:        LGPLv2.1+
Version:        20050720
Release:        1
Group:          Productivity/Office/Dictionary
Summary:        Spanish Thesaurus Dictionary for LibreOffice
Provides:       locale(libreoffice:es) locale(OpenOffice_org:es)
# compat stuff
Provides:       OpenOffice_org:/usr/lib/ooo-2.0/share/dict/ooo/th_es_ES_v2.dat
Provides:       OpenOffice_org-thesaurus-es = %version
Obsoletes:      OpenOffice_org-thesaurus-es <= %version

%description es
The Spanish thesaurus dictionary that can be used to look up for
synonyms and related words in the LibreOffice office suite.



%package es-AR
License:        LGPLv2.1
Version:        0.1
Release:        1
Group:          Productivity/Office/Dictionary
Summary:        Argentine Spanish Thesaurus Dictionary for LibreOffice
Provides:       locale(libreoffice:es_AR) locale(OpenOffice_org:es_AR)
# compat stuff
Provides:       OpenOffice_org:/usr/lib/ooo-2.0/share/dict/ooo/th_es_AR_v2.dat
Provides:       OpenOffice_org-thesaurus-es-AR = %version
Obsoletes:      OpenOffice_org-thesaurus-es-AR <= %version

%description es-AR
The Argentine Spanish thesaurus dictionary that can be used to look up for
synonyms and related words in the LibreOffice office suite.



%package es-VE
License:        GPLv3+
Version:        1.0.1
Release:        1
Group:          Productivity/Office/Dictionary
Summary:        Venezuelan Spanish Thesaurus Dictionary for LibreOffice
Provides:       locale(libreoffice:es_VE) locale(OpenOffice_org:es_VE)
# compat stuff
Provides:       OpenOffice_org:/usr/lib/ooo-2.0/share/dict/ooo/th_es_VE_v2.dat
Provides:       OpenOffice_org-thesaurus-es-VE = %version
Obsoletes:      OpenOffice_org-thesaurus-es-VE <= %version

%description es-VE
The Venezuelan Spanish thesaurus dictionary that can be used to look up for
synonyms and related words in the LibreOffice office suite.



%package fr
License:        LGPLv2.1+
Version:        20100125
Release:        1
Group:          Productivity/Office/Dictionary
Summary:        French Thesaurus Dictionary for LibreOffice
Provides:       locale(libreoffice:fr) locale(OpenOffice_org:fr)
# compat stuff
Provides:       OpenOffice_org:/usr/lib/ooo-2.0/share/dict/ooo/th_fr_FR_v2.dat
Provides:       OpenOffice_org-thesaurus-fr = %version
Obsoletes:      OpenOffice_org-thesaurus-fr <= %version

%description fr
The French thesaurus dictionary that can be used to look up for
synonyms and related words in the LibreOffice office suite.



%package ga
License:        GFDLv1.2+
Version:        20071002
Release:        1
Group:          Productivity/Office/Dictionary
Summary:        Irish Thesaurus Dictionary for LibreOffice
Provides:       locale(libreoffice:ga) locale(OpenOffice_org:ga)
# compat stuff
Provides:       OpenOffice_org:/usr/lib/ooo-2.0/share/dict/ooo/th_ga_IE_v2.dat
Provides:       OpenOffice_org-thesaurus-ga = %version
Obsoletes:      OpenOffice_org-thesaurus-ga <= %version

%description ga
The Irish thesaurus dictionary that can be used to look up for
synonyms and related words in the LibreOffice office suite.



%package hu
License:        LGPLv2.1+
Version:        20080319
Release:        1
Group:          Productivity/Office/Dictionary
Summary:        Hungarian Thesaurus Dictionary for LibreOffice
Provides:       locale(libreoffice:hu) locale(OpenOffice_org:hu)
# compat stuff
Provides:       OpenOffice_org:/usr/lib/ooo-2.0/share/dict/ooo/th_hu_HU_v2.dat
Provides:       OpenOffice_org-thesaurus-hu = %version
Obsoletes:      OpenOffice_org-thesaurus-hu <= %version

%description hu
The Hungarian thesaurus dictionary that can be used to look up for
synonyms and related words in the LibreOffice office suite.



%package it
License:        AGPLv3+
Version:        20081129
Release:        1
Group:          Productivity/Office/Dictionary
Summary:        Italian Thesaurus Dictionary for LibreOffice
Provides:       locale(libreoffice:it) locale(OpenOffice_org:it)
# compat stuff
Provides:       OpenOffice_org:/usr/lib/ooo-2.0/share/dict/ooo/th_it_IT_v2.dat
Provides:       OpenOffice_org-thesaurus-it = %version
Obsoletes:      OpenOffice_org-thesaurus-it <= %version

%description it
The Italian thesaurus dictionary that can be used to look up for
synonyms and related words in the LibreOffice office suite.



%package nb
License:        GPLv2+
Version:        20080310
Release:        1
Group:          Productivity/Office/Dictionary
Summary:        Norwegian Bokmaal Thesaurus Dictionary for LibreOffice
Provides:       locale(libreoffice:nb) locale(OpenOffice_org:nb)
# compat stuff
Provides:       OpenOffice_org:/usr/lib/ooo-2.0/share/dict/ooo/th_nb_NO_v2.dat
Provides:       OpenOffice_org-thesaurus-nb = %version
Obsoletes:      OpenOffice_org-thesaurus-nb <= %version

%description nb
The Norwegian Bokmaal thesaurus dictionary that can be used to look up for
synonyms and related words in the LibreOffice office suite.



%package ne
License:        LGPLv2.1+
Version:        1.1
Release:        1
Group:          Productivity/Office/Dictionary
Summary:        Nepali Thesaurus Dictionary for LibreOffice
Provides:       locale(libreoffice:ne) locale(OpenOffice_org:ne)
# compat stuff
Provides:       OpenOffice_org:/usr/lib/ooo-2.0/share/dict/ooo/th_ne_NP_v2.dat
Provides:       OpenOffice_org-thesaurus-ne = %version
Obsoletes:      OpenOffice_org-thesaurus-ne <= %version

%description ne
The Nepali thesaurus dictionary that can be used to look up for
synonyms and related words in the LibreOffice office suite.



%package pl
License:        LGPLv2.1
Version:        20081206
Release:        1
Group:          Productivity/Office/Dictionary
Summary:        Polish Thesaurus Dictionary for LibreOffice
Provides:       locale(libreoffice:pl) locale(OpenOffice_org:pl)
# compat stuff
Provides:       OpenOffice_org:/usr/lib/ooo-2.0/share/dict/ooo/th_pl_PL_v2.dat
Provides:       OpenOffice_org-thesaurus-pl = %version
Obsoletes:      OpenOffice_org-thesaurus-pl <= %version

%description pl
The Polish thesaurus dictionary that can be used to look up for
synonyms and related words in the LibreOffice office suite.



%package pt
License:        GPLv2+
Version:        20091015
Release:        1
Group:          Productivity/Office/Dictionary
Summary:        Portuguese Thesaurus Dictionary for LibreOffice
Provides:       locale(libreoffice:pt) locale(OpenOffice_org:pt)
# compat stuff
Provides:       OpenOffice_org:/usr/lib/ooo-2.0/share/dict/ooo/th_pt_PT_v2.dat
Provides:       OpenOffice_org-thesaurus-pt = %version
Obsoletes:      OpenOffice_org-thesaurus-pt <= %version

%description pt
The Portuguese thesaurus dictionary that can be used to look up for
synonyms and related words in the LibreOffice office suite.



%package ro
License:        GPLv2+
Version:        20091130
Release:        1
Group:          Productivity/Office/Dictionary
Summary:        Romanian Thesaurus Dictionary for LibreOffice
Provides:       locale(libreoffice:ro) locale(OpenOffice_org:ro)
# compat stuff
Provides:       OpenOffice_org:/usr/lib/ooo-2.0/share/dict/ooo/th_ro_RO_v2.dat
Provides:       OpenOffice_org-thesaurus-ro = %version
Obsoletes:      OpenOffice_org-thesaurus-ro <= %version

%description ro
The Romanian thesaurus dictionary that can be used to look up for
synonyms and related words in the LibreOffice office suite.



%package ru
License:        LGPLv3
Version:        20081013
Release:        1
Group:          Productivity/Office/Dictionary
Summary:        Russian Thesaurus Dictionary for LibreOffice
Provides:       locale(libreoffice:ru) locale(OpenOffice_org:ru)
# compat stuff
Provides:       OpenOffice_org:/usr/lib/ooo-2.0/share/dict/ooo/th_ru_RU_v2.dat
Provides:       OpenOffice_org-thesaurus-ru = %version
Obsoletes:      OpenOffice_org-thesaurus-ru <= %version

%description ru
The Russian thesaurus dictionary that can be used to look up for
synonyms and related words in the LibreOffice office suite.



%package sk
License:        BSD3c
Version:        20100208
Release:        1
Group:          Productivity/Office/Dictionary
Summary:        Slovak Thesaurus Dictionary for LibreOffice
Provides:       locale(libreoffice:sk) locale(OpenOffice_org:sk)
# compat stuff
Provides:       OpenOffice_org:/usr/lib/ooo-2.0/share/dict/ooo/th_sk_SK_v2.dat
Provides:       OpenOffice_org-thesaurus-sk = %version
Obsoletes:      OpenOffice_org-thesaurus-sk <= %version

%description sk
The Slovak thesaurus dictionary that can be used to look up for
synonyms and related words in the LibreOffice office suite.



%package sl
License:        LGPLv2.1+
Version:        20080601
Release:        1
Group:          Productivity/Office/Dictionary
Summary:        Slovenian Thesaurus Dictionary for LibreOffice
Provides:       locale(libreoffice:sl) locale(OpenOffice_org:sl)
# compat stuff
Provides:       OpenOffice_org:/usr/lib/ooo-2.0/share/dict/ooo/th_sl_SI_v2.dat
Provides:       OpenOffice_org-thesaurus-sl = %version
Obsoletes:      OpenOffice_org-thesaurus-sl <= %version

%description sl
The Slovenian thesaurus dictionary that can be used to look up for
synonyms and related words in the LibreOffice office suite.



%package sv
License:        BSD3c
Version:        20090624
Release:        1
Group:          Productivity/Office/Dictionary
Summary:        Swedish Thesaurus Dictionary for LibreOffice
Provides:       locale(libreoffice:sv) locale(OpenOffice_org:sv)
# compat stuff
Provides:       OpenOffice_org:/usr/lib/ooo-2.0/share/dict/ooo/th_sv_SE_v2.dat
Provides:       OpenOffice_org-thesaurus-sv = %version
Obsoletes:      OpenOffice_org-thesaurus-sv <= %version

%description sv
The Swedish thesaurus dictionary that can be used to look up for
synonyms and related words in the LibreOffice office suite.




%prep
%setup -T -c
# unpack sources
for archive in \
    %{S:1000} \
    %{S:1001} \
    %{S:1002} \
    %{S:1003} \
    %{S:1004} \
    %{S:1005} \
    %{S:1006} \
    %{S:1007} \
    %{S:1008} \
    %{S:1009} \
    %{S:1010} \
    %{S:1011} \
    %{S:1012} \
    %{S:1013} \
    %{S:1014} \
    %{S:1015} \
    %{S:1016} \
    %{S:1017} \
    %{S:1018} \
    %{S:1019} \
    %{S:1020} \
    %{S:1021} \
    %{S:1022} \
    %{S:1023} \
    %{S:1024} \
    %{S:1025} \
    %{S:1026} \
    ; do
	archive_name=`basename $archive | sed -e "s|.zip$||" -e "s|.oxt$||" -e "s|.tar.gz$||" -e "s|.tar.bz2$||"`
	mkdir $archive_name || exit 1;
	case $archive in
	    *.zip|*.oxt)
		cd $archive_name; unzip $archive || exit 1; cd -
		;;
	    *.tar.gz)
		tar -xzf $archive -C $archive_name || exit 1;
		;;
	    *.tar.bz2)
		tar -xjf $archive -C $archive_name || exit 1;
		;;
	    *)
		echo "Error: Do not know how to uncompress $archive"
		exit 1;
		;;
	esac
done
#
# fix file names
mv thesaurus-ca/dictionaries/README_th_ca_ES_v3.txt thesaurus-ca/dictionaries/README_th_ca_ES_v2.txt
mv thesaurus-ca/dictionaries/th_ca_ES_v3.dat thesaurus-ca/dictionaries/th_ca_ES_v2.dat
mv thesaurus-ca/dictionaries/th_ca_ES_v3.idx thesaurus-ca/dictionaries/th_ca_ES_v2.idx
mv thes_en_GB_v2/th_en_GB_final.dat	thes_en_GB_v2/th_en_GB_v2.dat
mv thes_en_GB_v2/th_en_GB_final.idx	thes_en_GB_v2/th_en_GB_v2.idx
mv ooo-dictionnaire-fr-reforme1990-v3.5/dictionaries/thes_fr.dat ooo-dictionnaire-fr-reforme1990-v3.5/dictionaries/th_fr_FR_v2.dat
mv ooo-dictionnaire-fr-reforme1990-v3.5/dictionaries/thes_fr.idx ooo-dictionnaire-fr-reforme1990-v3.5/dictionaries/th_fr_FR_v2.idx
#
# rename thes_ to th_ and add _v2 suffix
for suffix in idx dat ; do
    for file in `find . -name "th*_*.$suffix" -type f` ; do
	dir=$(dirname $file)
	fname=$(basename $file)
	fname_new=`echo $fname | sed -e "s|^thes_|th_|" -e "s|\.$suffix$|_v2.$suffix|" -e "s|_v2_v2|_v2|"`
	test "$fname" = "$fname_new" || mv -v "$dir/$fname" "$dir/$fname_new"
    done
done
#
# fix permissions
find . -type f -exec chmod 644 {} \;

%build

%install
rm -f filelist.template
install -m 755 -d $RPM_BUILD_ROOT%{_datadir}/mythes
# compat dir
install -m 755 -d $RPM_BUILD_ROOT%{_datadir}/ooo/thesaurus
for lang_dir in * ; do
    test -d $lang_dir || continue
    # temporary file list
    filelist=`mktemp /tmp/lo-thes-XXXXXX`
    echo "%%defattr(-,root,root)" >$filelist
    echo "%%dir %{_datadir}/mythes" >>$filelist
    # compat dir
    echo "%%dir %{_datadir}/ooo" >>$filelist
    echo "%%dir %{_datadir}/ooo/thesaurus" >>$filelist
    # install dictionaries
    dic=
    # support locales with 2 and 3 letters in the language code: th_ll_CC_v2.idx and th_lll_CC_v2.idx
    for idx in `find $lang_dir -regextype posix-extended -regex ".*/th_[[:lower:]][[:lower:]][[:lower:]]?_[[:upper:]][[:upper:]]_v2.idx" | sort` ; do
	dat=`echo $idx | sed -e "s|.idx$|.dat|"`
	if ! test -f $dat ; then
	    echo "Warning: Found $idx but not $dat"
	    echo "Skipping $idx"
	    continue;
	fi
	# both .idx and .dat files exists => install them
	for f in $idx $dat ; do
	    fname=$(basename $f)
	    if test -f $RPM_BUILD_ROOT%{_datadir}/mythes/$fname ; then
		echo "Error: file already installed: $f"
		echo "       Probably is provided by two source tarballs"
		exit 1;
	    fi
	    install -m 644 $f $RPM_BUILD_ROOT%{_datadir}/mythes/
	    echo %{_datadir}/mythes/$fname >>$filelist
            # compat stuff
	    ln -sf ../../mythes/$fname $RPM_BUILD_ROOT%{_datadir}/ooo/thesaurus/
	    echo %{_datadir}/ooo/thesaurus/$fname >>$filelist
	done
    done

    # detect locale, lang and country
    if test -n $idx ; then
    # replace the underscore with a dot to be able to separate the language and the coutry code with the command "cut"
	dic_pname=`basename $idx | sed "s|_|.|g"`
	lang=`echo $dic_pname | cut -d "." -f2`
	country=`echo $dic_pname | cut -d "." -f3`
    else
	echo "Error: No dictionary found in $lang_dir"
	exit 1;
    fi
    locale="${lang}_${country}"

    # detect long language name
    case "$locale" in 
	"bg_BG") lang_name="bg" ;;
	"ca_ES") lang_name="ca" ;;
	"cs_CZ") lang_name="cs" ;;
	"da_DK") lang_name="da" ;;
	"de_DE") lang_name="de" ;;
	"de_AT") lang_name="de-AT" ;;
	"de_CH") lang_name="de-CH" ;;
	"el_GR") lang_name="el" ;;
	"en_AU") lang_name="en-AU" ;;
	"en_GB") lang_name="en-GB" ;;
	"en_US") lang_name="en-US" ;;
	"es_ES") lang_name="es" ;;
	"es_AR") lang_name="es-AR" ;;
	"es_VE") lang_name="es-VE" ;;
	"fr_FR") lang_name="fr" ;;
	"ga_IE") lang_name="ga" ;;
	"hu_HU") lang_name="hu" ;;
	"it_IT") lang_name="it" ;;
	"nb_NO") lang_name="nb" ;;
	"ne_NP") lang_name="ne" ;;
	"pl_PL") lang_name="pl" ;;
	"pt_PT") lang_name="pt" ;;
	"ro_RO") lang_name="ro" ;;
	"ru_RU") lang_name="ru" ;;
	"sk_SK") lang_name="sk" ;;
	"sl_SI") lang_name="sl" ;;
	"sv_SE") lang_name="sv" ;;
	*)	 lang_name="$lang" ;;
    esac

    # detect README encoding
    case "$locale" in 
	*) coding=`LC_CTYPE="$locale" locale -k LC_CTYPE | grep charmap | sed "s|charmap=\"\(.*\)\"\$|\1|"` ;;
    esac

    # install documentation
    docdir=%{_docdir}/libreoffice-thesaurus-$lang_name
    mkdir -p $RPM_BUILD_ROOT$docdir
    echo "%%doc $docdir" >>$filelist
    for doc in `find $lang_dir -type f -printf "%%P\n" | \
                grep -v -e ".aff$" -e ".dic$" -e ".dat$" -e ".idx$" \
                        -e ".orig$" -e ".old$" -e "~$" \
                        -e ".sh$" -e "makefile" -e "META-INF"` ; do
	if ! test -f $lang_dir/$doc ; then
	    echo "Error: is not a file: $lang_dir/$doc"
	    exit 1;
	fi
	recode utf8..utf16 <$lang_dir/$doc >/dev/null 2>&1 || recode $coding..utf8 $lang_dir/$doc
	dos2unix $lang_dir/$doc
	dname=$(dirname $doc)
	install -m 755 -d $RPM_BUILD_ROOT$docdir/$dname
	install -m 644 $lang_dir/$doc $RPM_BUILD_ROOT$docdir/$dname
    done
    # rename the file list according to the detacted lang and country
    mv $filelist $locale.list
    # generate tempalte for the %files section
    echo "%%files -f $locale.list $lang_name" >>filelist.template
    echo "" >>filelist.template
done

%clean
rm -rf $RPM_BUILD_ROOT

%files -f bg_BG.list bg

%files -f ca_ES.list ca

%files -f cs_CZ.list cs

%files -f da_DK.list da

%files -f de_DE.list de

%files -f de_AT.list de-AT

%files -f de_CH.list de-CH

%files -f el_GR.list el

%files -f en_AU.list en-AU

%files -f en_GB.list en-GB

%files -f en_US.list en-US

%files -f es_ES.list es

%files -f es_AR.list es-AR

%files -f es_VE.list es-VE

%files -f fr_FR.list fr

%files -f ga_IE.list ga

%files -f hu_HU.list hu

%files -f it_IT.list it

%files -f nb_NO.list nb

%files -f ne_NP.list ne

%files -f pl_PL.list pl

%files -f pt_PT.list pt

%files -f ro_RO.list ro

%files -f ru_RU.list ru

%files -f sk_SK.list sk

%files -f sl_SI.list sl

%files -f sv_SE.list sv

%changelog
openSUSE Build Service is sponsored by