LogoopenSUSE Build Service > Projects
Sign Up | Log In

View File myspell-dictionaries.spec.in of Package myspell-dictionaries (Project openSUSE:Factory)

# spec file for package myspell-dictionaries
# 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:           myspell-dictionaries
Version:        20090731
Release:        0
Summary:        A Source Package for Dictionaries Used by MySpell
License:        @ALL_LICENSES@
Group:          Productivity/Text/Spell
Url:            http://lingucomponent.openoffice.org/download_dictionary.html
# Novell jargon bnc#306333
Source0:        Nwordlist.tgz
Source1:        myspell-dictionaries-gen-spec
Source2:        myspell-dictionaries.spec.in
Source3:        myspell-dictionaries.data
# dictionaries
BuildRequires:  dos2unix
BuildRequires:  recode
BuildRequires:  unzip
BuildRoot:      %{_tmppath}/%{name}-%{version}-build
BuildArch:      noarch

This source package contains dictionaries for MySpell.

The MySpell spell-checker is used by the OpenOffice.org office suite,
the Mozilla Composer, and the Mozilla Mail message composition window.

%setup -c
install -m 644 %{SOURCE1} .
# unpack sources
for archive in \
	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
		cd $archive_name; unzip $archive || exit 1; cd -
		tar -xzf $archive -C $archive_name || exit 1;
		tar -xjf $archive -C $archive_name || exit 1;
		echo "Error: Do not know how to uncompress $archive"
		exit 1;
# fix wrong filenames
# fix permissions
find . -type f -exec chmod 644 {} \;

# add the Novell jargon into all dictionaries bnc#306333
# Beware! The Nwordlist must begin with a newline. Some files do not contain
# LF at the end of file.
for dic in `find . -name "*.dic` ; do
    cat Nwordlist >> $dic
    # delete empty lines if they were created in some cases
    grep -v "^$" $dic > $dic.no_space && mv $dic.no_space $dic

rm -f filelist.template
install -m 755 -d %{buildroot}%{_datadir}/myspell/
for lang_dir in * ; do
    test -d $lang_dir || continue
    # support locales with 2 and 3 letters in the language code: ll_CC.aff and lll_CC.aff
    for aff in `find $lang_dir -regextype posix-extended -regex ".*/[[:lower:]][[:lower:]][[:lower:]]?_[[:upper:]][[:upper:]].aff" | sort` ; do
	# find dictionaries
	dic=`echo $aff | sed -e "s|.aff$|.dic|"`
	if ! test -f $dic ; then
	    echo "Warning: Found $aff but not $dic"
	    echo "Skipping $aff"

	# both .dic and .aff files exists => valid dictionary
	# initialize file list
	filelist=`mktemp /tmp/myspell-dictionaries-XXXXXX`
	echo "%%defattr(-,root,root,-)" >$filelist
	echo "%%dir %{_datadir}/myspell/" >>$filelist

	# install the dictionary
	for f in $aff $dic ; do
	    fname=$(basename $f)
	    if test -f %{buildroot}%{_datadir}/myspell/$fname ; then
		echo "Error: file already installed: $f"
		echo "       Probably is provided by two source tarballs"
		exit 1;
	    install -m 644 $f %{buildroot}%{_datadir}/myspell/
	    echo %{_datadir}/myspell/$fname >>$filelist

	# 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|_|.|"`
	    lang=`echo $dic_pname | cut -d "." -f1`
	    country=`echo $dic_pname | cut -d "." -f2`
	    echo "Error: No dictionary found in $lang_dir"
	    exit 1;

	# detect long language name
	case "$locale" in
@LANG_NAME@	    *)       echo "Error: do not know language name for the locale $locale"
		     exit 1

	# detect README encoding
	coding=`LC_CTYPE="$locale" locale -k LC_CTYPE | grep charmap | sed "s|charmap=\"\(.*\)\"\$|\1|"`
	# special hack for some locales
	case "$locale" in

	# install documentation
	mkdir -p %{buildroot}$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;
	    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 %{buildroot}$docdir/$dname
	    install -m 644 $lang_dir/$doc %{buildroot}$docdir/$dname
	# 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 -n myspell-$lang_name" >>filelist.template
	echo "" >>filelist.template

echo "******"