-%define _rc rc2
+#
+# Conditional build:
+%bcond_without tests # build without tests
+#
Summary: David's Advanced Revision Control System - yet another replacement for CVS
Summary(pl.UTF-8): David's Advanced Revision Control System - jeszcze jeden zamiennik CVS-a
Name: darcs
-Version: 1.0.9
-Release: 0.%{_rc}.1
+Version: 2.5.2
+Release: 0.1
License: GPL v2
Group: Development/Version Control
-Source0: http://abridgegame.org/darcs/%{name}-%{version}%{_rc}.tar.gz
-# Source0-md5: fe268bc6d030141fc7f92417b96fca16
-URL: http://abridgegame.org/darcs/
-BuildRequires: curl-devel
-BuildRequires: ghc >= 6.2
-BuildRequires: ncurses-devel
-BuildRequires: readline-devel
-BuildRequires: zlib-devel
+Source0: http://darcs.net/releases/%{name}-%{version}.tar.gz
+# Source0-md5: 491b6ca01dec245a16112ad2c7e07dc1
+Patch0: %{name}-ghc72.patch
+Patch1: %{name}-relax-regex-libs-deps.patch
+Patch2: %{name}-tests-ghc72.patch
+URL: http://darcs.net/
+BuildRequires: curl-devel >= 7.19.1
+BuildRequires: ghc >= 6.12.3
+BuildRequires: ghc-hashed-storage >= 0.5
+BuildRequires: ghc-haskeline >= 0.6.1
+BuildRequires: ghc-mmap >= 1:0.5
+BuildRequires: ghc-tar >= 0.3
+BuildRequires: ghc-terminfo >= 0.3
+BuildRequires: ghc-utf8-string >= 0.3
+BuildRequires: ghc-zlib >= 0.5.1.0
+BuildRequires: gmp-devel
+BuildRequires: pkgconfig
BuildRoot: %{tmpdir}/%{name}-%{version}-root-%(id -u -n)
+%define ghcdir ghc-%(/usr/bin/ghc --numeric-version)
+
%description
David's Advanced Revision Control System is yet another replacement
for CVS. It is written in Haskell, and has been used on Linux, MacOS
OpenBSD i Microsoft Windows. Darcs zawiera skrypt CGI, który może być
używany do oglądania zawartości repozytorium.
+%package -n bash-completion-darcs
+Summary: bash-completion for darcs
+Summary(pl.UTF-8): bashowe uzupełnianie nazw dla darcsa
+Group: Applications/Shells
+Requires: bash-completion
+
+%description -n bash-completion-darcs
+This package provides bash-completion for darcs.
+
+%description -n bash-completion-darcs -l pl.UTF-8
+Pakiet ten dostarcza bashowe uzupełnianie nazw dla darcsa.
+
%prep
-%setup -q -n %{name}-%{version}%{_rc}
+%setup -q
+%patch0 -p1
+%patch1 -p1
+%patch2 -p1
%build
-CPPFLAGS="-I/usr/include/ncurses"
-%configure
-%{__make}
+runhaskell Setup.lhs configure -v2 \
+ --prefix=%{_prefix} \
+ --libdir=%{_libdir} \
+ --libexecdir=%{_libexecdir} \
+ --docdir=%{_docdir}/%{name}-%{version} \
+ --flags="curl curl-pipelining terminfo color mmap"
+
+runhaskell Setup.lhs build
+%{?with_tests:runhaskell Setup.lhs test}
+
+runhaskell Setup.lhs haddock --executables \
+ --css=doc/darcs.css
%install
rm -rf $RPM_BUILD_ROOT
-%{__make} install \
- DESTDIR=$RPM_BUILD_ROOT
+runhaskell Setup.lhs copy --destdir=$RPM_BUILD_ROOT
+
+# work around automatic haddock docs installation
+rm -rf %{name}-%{version}-doc
+cp -a $RPM_BUILD_ROOT%{_docdir}/%{name}-%{version} %{name}-%{version}-doc
+
+# bash completion
+install -d $RPM_BUILD_ROOT%{_sysconfdir}/bash_completion.d
+install -p contrib/darcs_completion $RPM_BUILD_ROOT%{_sysconfdir}/bash_completion.d/%{name}
-rm -rf $RPM_BUILD_ROOT%{_datadir}/doc/%{name}
+# we only want the binary
+rm -r $RPM_BUILD_ROOT/%{_libdir}/%{ghcdir}
%clean
rm -rf $RPM_BUILD_ROOT
%files
%defattr(644,root,root,755)
-%doc manual AUTHORS
+%doc NEWS README
+%doc %{name}-%{version}-doc/html
%attr(755,root,root) %{_bindir}/*
+%{_mandir}/man1/*
+
+%files -n bash-completion-darcs
+%defattr(644,root,root,755)
%{_sysconfdir}/bash_completion.d/%{name}
-%{_mandir}/man?/*