File libreoffice-hyphen.spec.in of Package libreoffice-hyphen

#
# spec file for package libreoffice-hyphen
#
# 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-hyphen
@DO_NOT_EDIT_COMMENT@
BuildRequires:  dos2unix
BuildRequires:  recode
BuildRequires:  unzip
%if %suse_version > 1020
BuildRequires:  fdupes
%endif
Version:        20110203.1
Release:        0
Summary:        Hyphen Dictionaries for LibreOffice
License:        @ALL_LICENSES@
Group:          Productivity/Office/Dictionary
#compat stuff
@PROVIDES_OOO@@PROVIDES_LO@Provides:       OpenOffice_org-hyphen = %version
Provides:       OpenOffice_org:/usr/lib/ooo-2.0/share/dict/ooo/hyph_en_US.dic
Obsoletes:      OpenOffice_org-hyphen <= %version
BuildRoot:      %{_tmppath}/%{name}-%{version}-build
BuildArch:      noarch
Source0:        libreoffice-hyphen-gen-spec
Source1:        libreoffice-hyphen.spec.in
Source2:        libreoffice-hyphen.data
@SOURCES@
%description
These dictionaries help you to hyphenate texts and words in the
LibreOffice office suite.



%prep
%setup -T -c
# unpack sources
for archive in \
@SOURCES_UNPACK@    ; 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
@PREP_HACKS@#
#
# fix permissions
find . -type f -exec chmod 644 {} \;

%build

%install
install -m 755 -d $RPM_BUILD_ROOT%{_datadir}/hyphen
install -m 755 -d $RPM_BUILD_ROOT%{_docdir}/%{name}
# compat stuff
install -m 755 -d $RPM_BUILD_ROOT%{_datadir}/ooo/hyphen
# init file list
filelist=files.list
echo "%%defattr(-,root,root)" >$filelist
echo "%%dir %{_docdir}/libreoffice-hyphen" >>$filelist
echo "%%dir %{_datadir}/hyphen" >>$filelist
# compat stuff
echo "%%dir %{_datadir}/ooo" >>$filelist
echo "%%dir %{_datadir}/ooo/hyphen" >>$filelist
# process all directories
for lang_dir in * ; do
    test -d $lang_dir || continue
    # install dictionaries
    dic=
    # support locales with 2 and 3 letters in the language code: hyph_ll_CC.dic and hyph_lll_CC.dic
    for dic in `find $lang_dir -regextype posix-extended -regex ".*/hyph_[[:lower:]][[:lower:]][[:lower:]]?_[[:upper:]][[:upper:]].dic" | sort` ; do
	fname=$(basename $dic)
	if test -f $RPM_BUILD_ROOT%{_datadir}/hyphen/$fname ; then
	    echo "Error: file already installed: $f"
	    echo "       Probably is provided by two source tarballs"
	    exit 1;
	fi
	install -m 644 $dic $RPM_BUILD_ROOT%{_datadir}/hyphen/
        echo %{_datadir}/hyphen/$fname >>$filelist
        # compat stuff
        ln -sf ../../hyphen/$fname $RPM_BUILD_ROOT%{_datadir}/ooo/hyphen/
        echo %{_datadir}/ooo/hyphen/$fname >>$filelist
    done

    # detect locale, lang and country
    if test -n "$dic" ; 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 $dic | 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 README encoding
    case "$locale" in 
@ENCODING@	*) coding=`LC_CTYPE="$locale" locale -k LC_CTYPE | grep charmap | sed "s|charmap=\"\(.*\)\"\$|\1|"` ;;
    esac

    # install documentation
    docdir=%{_docdir}/libreoffice-hyphen/hyph_$locale
    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
done
# link duplicated files
%if %suse_version > 1020
%fdupes $RPM_BUILD_ROOT
%endif

%clean
rm -rf $RPM_BUILD_ROOT

%files -f files.list

%changelog
openSUSE Build Service is sponsored by