%global upstreamid 20140811.1

Name:          hunspell-en
Summary:       English hunspell dictionaries
Version:       0.%{upstreamid}
Release:       14
Source0:       https://github.com/en-wl/wordlist/archive/rel-2014.08.11.1.tar.gz
Source1:       https://download.services.openoffice.org/contrib/dictionaries/en_GB.zip
#http://mxr.mozilla.org/mozilla/source/extensions/spellcheck/locales/en-US/hunspell/mozilla_words.diff?raw=1
Patch0:        mozilla_words.patch
Patch1:        en_GB-singleletters.patch
Patch2:        en_GB.two_initial_caps.patch
#http://sourceforge.net/tracker/?func=detail&aid=2355344&group_id=10079&atid=1014602
Patch3:        en_US-strippedabbrevs.patch
#https://sourceforge.net/tracker/?func=detail&aid=2987192&group_id=143754&atid=756397
Patch4:        hunspell-en-allow-non-typographical.marks.patch
#https://sourceforge.net/tracker/?func=detail&aid=3012183&group_id=10079&atid=1014602
#https://bugzilla.redhat.com/show_bug.cgi?id=619577 add SI and IEC prefixes
Patch5:        hunspell-en-SI_and_IEC.patch
#https://sourceforge.net/tracker/?func=detail&aid=3175662&group_id=10079&atid=1014602 obscure Calender hides misspelling of Calendar
Patch6:        hunspell-en-calender.patch
Patch7:        en_IE.supplemental.patch
Patch8:        hunspell-en-dont-call-git-during-build.patch
Patch9:        hunspell-en-fixbuild.patch
Patch10:       en_GB.etc.patch
Patch11:       perl.regex.patch
URL:           https://wordlist.sourceforge.net/
License:       LGPLv2+ and LGPLv2 and BSD
BuildArch:     noarch
BuildRequires: git aspell zip dos2unix perl-Getopt-Long gcc-c++
Requires:      hunspell
Supplements:   (hunspell and langpacks-en) (hunspell and langpacks-en_GB)

Provides:       %{name}-GB
Obsoletes:      %{name}-GB

Provides:       %{name}-US
Obsoletes:      %{name}-US

%description
English (US, UK, etc.) hunspell dictionaries


%package_help

%prep
%setup -q -n wordlist-rel-2014.08.11.1
%setup -q -T -D -a 1 -n wordlist-rel-2014.08.11.1
%patch0 -p0 -b .mozilla
%patch1 -p1 -b .singleletters
%patch2 -p1 -b .two_initial_cap
%patch3 -p0 -b .strippedabbrevs
%patch4 -p0 -b .allow-non-typographical
%patch5 -p0 -b .SI_and_IEC
%patch6 -p1 -b .calender
%patch7 -p1 -b .en_IE
%patch8 -p1 -b .nogit
%patch9 -p1 -b .fixbuild
%patch10 -p1 -b .etc
%patch11 -p1 -b .regex

%build
export PERL5LIB=`pwd`/scowl/r/varcon${PERL5LIB:+:${PERL5LIB}}
make
cd scowl/speller
make hunspell
for i in README_en_CA.txt README_en_US.txt; do
  if ! iconv -f utf-8 -t utf-8 -o /dev/null $i > /dev/null 2>&1; then
    iconv -f ISO-8859-1 -t UTF-8 $i > $i.new
    touch -r $i $i.new
    mv -f $i.new $i
  fi
  tr -d '\r' < $i > $i.new
  touch -r $i $i.new
  mv -f $i.new $i
done

%install
mkdir -p $RPM_BUILD_ROOT/%{_datadir}/myspell
cp -p en_??.dic en_??.aff $RPM_BUILD_ROOT/%{_datadir}/myspell
cd scowl/speller
cp -p en_??.dic en_??.aff $RPM_BUILD_ROOT/%{_datadir}/myspell

pushd $RPM_BUILD_ROOT/%{_datadir}/myspell/
en_GB_aliases="en_AG en_AU en_BS en_BW en_BZ en_DK en_GH en_HK en_IE en_IN en_JM en_MW en_NA en_NG en_NZ en_SG en_TT en_ZA en_ZM en_ZW"
for lang in $en_GB_aliases; do
        ln -s en_GB.aff $lang.aff
        ln -s en_GB.dic $lang.dic
done
en_US_aliases="en_PH"
for lang in $en_US_aliases; do
        ln -s en_US.aff $lang.aff
        ln -s en_US.dic $lang.dic
done
popd


%files
%defattr(-,root,root)
%doc scowl/speller/README_en_*.txt
%{_datadir}/myspell/*

%files help
%defattr(-,root,root)
%doc README_en_GB.txt

%changelog
* Fri Sep 20 2019 openEuler Buildteam <buildteam@openeuler.org> - 0.20140811.1-14
- Package init

