%define fontname arabeyes
%define fontdir %{_datadir}/fonts/%{fontname}

Name: arabeyes-fonts
Version: 2.0.1
Release: 5%{?dist}
License: GPLv2, OFL
Source: http://downloads.sourceforge.net/arabeyes/ae_fonts_2.0.tar.bz2
Source1: http://downloads.sourceforge.net/arabeyes/ae_fonts_mono.tar.bz2
Source2: http://downloads.sourceforge.net/arabeyes/Thabit-0.01.tar.gz
Source3: http://downloads.sourceforge.net/arabeyes/Mothanna-0.01.tar.gz
Source4: http://www.khaledhosny.org/files/pub/SimplifiedNaskh/SimplifiedNaskh.ttf
Source5: 65-arabeyes-core.conf
BuildArch: noarch
Summary: Arabic fonts form Arabeyes.org
URL: http://www.arabeyes.org

%description
This package contains fonts for the display of Arabic 
from the Arabeyes.org project.

%prep
# merge and flaten the tree
%setup -q -n ae_fonts_2.0
mkdir decorative
tar xjf %{SOURCE1} -C decorative
find . -type f | xargs mv -t decorative
rm decorative/ae_AlMothnna*.ttf
mkdir core-tree
tar xzf %{SOURCE2} -C core-tree
mv core-tree/Thabit*/ChangeLog core-tree/ChangeLog-Thabit
mv core-tree/Thabit*/README core-tree/README-Thabit
mv core-tree/Thabit*/README.arabic core-tree/README-Thabit.arabic
rm core-tree/Thabit*/OFL* # diplicated
tar xzf %{SOURCE3} -C core-tree
mv core-tree/Mothanna*/ChangeLog core-tree/ChangeLog-Mothanna
mv core-tree/Mothanna*/README core-tree/README-Mothanna
mv core-tree/Mothanna*/README.arabic core-tree/README-Mothanna.arabic
cp -p %{SOURCE4} core-tree
mkdir core
find core-tree -type f | xargs mv -t core

# used if .txt files have dos line feeds
#find . -not -name \*.ttf -type f -exec dos2unix -k {} \;

%build

%install
rm -rf %{buildroot} 

install -m 0755 -d %{buildroot}%{fontdir}
install -m 0644 -p decorative/*.ttf %{buildroot}%{fontdir}
install -m 0644 -p decorative/*.bdf %{buildroot}%{fontdir}
install -m 0644 -p decorative/*.pcf %{buildroot}%{fontdir}
install -m 0755 -d %{buildroot}%{fontdir}-core
install -m 0644 -p core/*.ttf %{buildroot}%{fontdir}-core

%clean
rm -rf %{buildroot}

%package -n arabeyes-decorative-fonts
Group: User Interface/X
Summary: Core arabic fonts form Arabeyes.org
BuildArch: noarch
License: GPLv2
Requires: arabeyes-core-fonts
Provides: arabeyes-fonts
Requires(post): fontconfig
%description -n arabeyes-decorative-fonts
This package contains decorative Arabic fonts from the Arabeyes.org project.

%package -n arabeyes-core-fonts
Group: User Interface/X
Summary: Core arabic fonts form Arabeyes.org
License: OFL
BuildArch: noarch
Requires(post): fontconfig
%description -n arabeyes-core-fonts
This package contains fonts for the display of Arabic 
from the Arabeyes.org project.

%post -n arabeyes-decorative-fonts
if [ -x %{_bindir}/fc-cache ]; then
  %{_bindir}/fc-cache %{fontdir}
fi

%postun -n arabeyes-decorative-fonts
if [ "$1" = "0" ]; then
  if [ -x %{_bindir}/fc-cache ]; then
    %{_bindir}/fc-cache %{fontdir}
  fi
fi

%post -n arabeyes-core-fonts
if [ -x %{_bindir}/fc-cache ]; then
  %{_bindir}/fc-cache %{fontdir}-core
fi

%postun -n arabeyes-core-fonts
if [ "$1" = "0" ]; then
  if [ -x %{_bindir}/fc-cache ]; then
    %{_bindir}/fc-cache %{fontdir}-core
  fi
fi

%files -n arabeyes-decorative-fonts
%defattr(-,root,root,-)
%doc 	decorative/COPYING*
%doc 	decorative/README*
%doc 	decorative/ChangeLog*
%dir %{fontdir}
%{fontdir}/*.ttf
%{fontdir}/*.bdf
%{fontdir}/*.pcf

%files -n arabeyes-core-fonts
%doc 	core/OFL*
%doc 	core/README*
%doc 	core/ChangeLog*
%dir %{fontdir}-core
%{fontdir}-core/*.ttf

%changelog
* Sun Nov 27 2016 Mosaab Alzoubi <moceap@hotmail.com> - 2.0.1-5
- Rebuilt for Fedora 25

* Sat Jan 24 2009  Muayyad Salah Alsadi <alsadi@ojuba.org> - 2.0.1-3
- add Othmani support to SimplifiedNaskh

* Sun Aug 03 2008  Muayyad Salah Alsadi <alsadi@ojuba.org> - 2.0.1-2
- makes two subpackages

* Tue Jun 10 2008 Muayyad Salah Alsadi <alsadi@ojuba.org> - 2.0.1
- Update Mothanna and Thabit

* Tue Jun 10 2008 Muayyad Salah Alsadi <alsadi@ojuba.org> - 2.0.0
- Initial Packaging