%define pkg_name    xmobar
%define pkg_version 0.29.3
%define pkg_release 1%{?_dist_release}

Summary:     a minimalistic text based status bar
Summary(ja): テキストを基礎とした最小のステータスバー
Name:    %{pkg_name}
Version: %{pkg_version}
Release: %{pkg_release}

License: BSD3
Group:   User Interface/Desktops
URL:     http://hackage.haskell.org

Source0: packages

# # Patch for building with hinotify-3.10
# Source2: xmobar-0.26_with_hinotify-3.10.patch

Source11: hinotify-0.4.tar.gz
Source12: hinotify.cabal
Source13: parsec-numbers-0.1.0.tar.gz
Source14: parsec-numbers.cabal
Source15: timezone-series-0.1.9.tar.gz
Source16: timezone-series.cabal
Source17: timezone-olson-0.1.9.tar.gz
Source18: timezone-olson.cabal
Source19: xmobar-0.29.3.tar.gz
Source20: xmobar.cabal

BuildRoot: %{_tmppath}/%{name}-%{version}-root

BuildRequires: ghc haskell-platform
BuildRequires: xmonad xmonad-contrib
BuildRequires: libXScrnSaver-devel
BuildRequires: libffi-devel gmp-devel zlib-devel
BuildRequires: xorg-x11-devel
BuildRequires: libXpm-devel

Requires: haskell-platform-dep
Requires: xmonad xmonad-contrib
Requires: libXpm

Vendor: Project Vine
Distribution: Vine Linux
Packager: ara_t


%description
Xmobar is a minimalistic text based status bar.

Inspired by the Ion3 status bar, it supports similar features,
like dynamic color management, output templates, and extensibility
through plugins.

%description -l ja
Xmobarはテキストを基礎とした最小のステータスバーです。


%prep
%{__rm} -rf ${RPM_BUILD_ROOT}

%build
%ghc_pkg_init

cd %{_builddir}
for pkg in `sed '$d' %{SOURCE0}`; do
    %{__tar} xzf %{_sourcedir}/${pkg}.tar.gz
    pushd ${pkg}
        %ghc_fix_dependencies ${pkg}
        %cabal_configure2 %{name} ${pkg}
        %cabal_build
        %cabal_haddock
        %cabal_copy_resister %{name}_${pkg}
    popd
done

cd %{_builddir}
for pkg in `tail -n 1 %{SOURCE0}`; do
    %{__tar} xzf %{_sourcedir}/${pkg}.tar.gz
    pushd ${pkg}
        %ghc_fix_dependencies ${pkg}

        # # Patch for building with hinotify-3.10
        # %{__patch} -p1 < %{SOURCE2}

        %cabal_configure2 %{name} ${pkg} \
            --flags="with_utf8" --flags="with_xft" \
            --flags="with_threaded" --flags="with_inotify" \
            --flags="with_datazone" --flags="with_xpm"
        %cabal_build
        %cabal_haddock
        %cabal_copy_resister %{name}_${pkg}
    popd
done


%install
# copy documents
pushd %{_builddir}/%{name}-%{version}
    %{__cp} readme.md \
     ${RPM_BUILD_ROOT}%{_docdir}/%{name}/%{name}-%{version}
popd


%clean
%{__rm} -rf ${RPM_BUILD_ROOT}

%post
%ghc_pkg_recache

%postun
%ghc_pkg_recache


%files
%defattr(-, root, root)
%{_bindir}/
%{_libdir}/ghc-%{ghc_version}/
%{_libdir}/ghc-lib/
%{_docdir}/%{name}/


%changelog
* Mon Dec 17 2018 Toshiaki Ara <ara_t@384.jp> 0.29.3-1
- update to 0.29.3
- build using ghc-8.6.3

* Wed Aug 08 2018 Toshiaki Ara <ara_t@384.jp> 0.27-2
- build using ghc-8.4.3-2
- add BuildRequires: libXScrnSaver-devel
- correct BuildRequires

* Fri Jul 20 2018 Toshiaki Ara <ara_t@384.jp> 0.27-1
- update to 0.27
- drop Patch2 (fixed at upstream)
- build using ghc-8.4.3

* Fri May 18 2018 Toshiaki Ara <ara_t@384.jp> 0.26-1
- update to 0.26
- rebuild using ghc-8.4.2
- add Patch for building with hinotify-3.10 (Source2)
- rewrite using macro

* Tue Jan 09 2018 Toshiaki Ara <ara_t@384.jp> 0.24.5-2
- update to 0.24.5
- rebuild using ghc-8.2.2

* Fri Feb 03 2017 Toshiaki Ara <ara_t@384.jp> 0.24.3-1
- update to 0.24.3
- build using ghc-8.0.1

* Wed May 04 2016 Toshiaki Ara <ara_t@384.jp> 0.23.1-6
- rebuilt

* Tue Apr 12 2016 Toshiaki Ara <ara_t@384.jp> 0.23.1-5
- rebuild under xmonad-0.12-3 and xmonad-contrib-0.12-4
- correct SPEC file

* Sun Mar 06 2016 Toshiaki Ara <ara_t@384.jp> 0.23.1-4
- correct SPEC file

* Tue Mar 01 2016 Toshiaki Ara <ara_t@384.jp> 0.23.1-3
- rebuild under xmonad-0.12-2 and xmonad-contrib-0.12-3

* Sun Feb 28 2016 Toshiaki Ara <ara_t@384.jp> 0.23.1-2
- add configure option and required libraries

* Sat Feb 27 2016 Toshiaki Ara <ara_t@384.jp> 0.23.1-1
- new package
