myspell-dictionaries/myspell-dictionaries.spec.in

175 lines
5.5 KiB
RPMSpec
Raw Normal View History

#
# 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/
#
@DO_NOT_EDIT_COMMENT@
Name: myspell-dictionaries
Version: 20140102
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
@SOURCES@
BuildRequires: dos2unix
BuildRequires: recode
BuildRequires: unzip
BuildRoot: %{_tmppath}/%{name}-%{version}-build
BuildArch: noarch
%description
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.
@METADATA@
%prep
%setup -c
install -m 644 %{SOURCE1} .
# 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 wrong filenames
@PREP_HACKS@#
# fix permissions
#
find . -type f -exec chmod 644 {} \;
%build
# 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
done
%install
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"
continue;
fi
# 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;
fi
install -m 644 $f %{buildroot}%{_datadir}/myspell/
echo %{_datadir}/myspell/$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|_|.|"`
lang=`echo $dic_pname | cut -d "." -f1`
country=`echo $dic_pname | cut -d "." -f2`
else
echo "Error: No dictionary found in $lang_dir"
exit 1;
fi
locale="${lang}_${country}"
# detect long language name
case "$locale" in
@LANG_NAME@ *) echo "Error: do not know language name for the locale $locale"
exit 1
;;
esac
# 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
@ENCODING@ esac
# install documentation
docdir=%{_docdir}/myspell-$lang_name
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;
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 %{buildroot}$docdir/$dname
install -m 644 $lang_dir/$doc %{buildroot}$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 -n myspell-$lang_name" >>filelist.template
echo "" >>filelist.template
done
done
echo "******"
@FILES@
%changelog