Name:           nunit
Version:        2.6.4
Release:        2%{?_dist_release}
Summary:        Unit-testing framework for all .NET languages
Summary(ja):    .NET 向けのユニットテストフレームワーク

License:        Zlib
Url:            http://www.nunit.org/
Group:          Development/Tools

Source0:        https://github.com/nunit/nunitv2/archive/%{version}.tar.gz

Source10:	mono-find-requires 

BuildRoot:      %{_tmppath}/%{name}-%{version}-build
BuildArch:      noarch
BuildRequires:  mono-devel dos2unix libgdiplus-devel
#%if 0%{?fedora_version} strace 
#BuildRequires:  xorg-x11-fonts-truetype
#%endif

%global __mono_requires %{SOURCE10}

%description
NUnit is a unit testing framework for all .NET languages. It serves the
same purpose as JUnit does in the Java world. It supports test
categories, testing for exceptions and writing test results in plain
text or XML.

%package devel
Summary:        Development files for NUnit
Summary(ja):    NUnit の開発用ファイル
Group:          Development/Libraries
Requires:       nunit = %{version}-%{release}

%description devel
This package contains development files for NUnit integration.

%prep
%setup -q -n nunitv2-%{version}
chmod +x %{SOURCE10}

%build
xbuild nunit.sln /t:Build /p:Configuration=Debug

%install
rm -rf %{buildroot}
mkdir -p "%{buildroot}%{_prefix}/lib/nunit"
cp -a bin/Debug/* "%{buildroot}%{_prefix}/lib/nunit"

#mkdir -p "%{buildroot}%{_docdir}/%{name}"
#cp -a license.txt "%{buildroot}%{_docdir}/%{name}/"
#cp -a doc "%{buildroot}%{_docdir}/%{name}/"
#cp -a samples "%{buildroot}%{_docdir}/%{name}/"
rm -rf docs_to_include
mkdir -p docs_to_include
cp -a license.txt docs_to_include
cp -a doc docs_to_include
cp -a samples docs_to_include

pushd docs_to_include
find . -type f -exec dos2unix {} \;
popd

mkdir -p "%{buildroot}%{_bindir}"
echo '#!/bin/sh
exec /usr/bin/mono %{_prefix}/lib/nunit/nunit.exe "$@"' > "%{buildroot}%{_bindir}/nunit"
chmod +x "%{buildroot}%{_bindir}/nunit"

#cd %{buildroot}%{_docdir}/%{name}/
#find . -type f -exec dos2unix {} \;

for i in nunit.core.dll nunit.core.interfaces.dll nunit.framework.dll nunit.util.dll lib/nunit-console-runner.dll lib/nunit-gui-runner.dll lib/nunit.uiexception.dll lib/nunit.uikit.dll framework/nunit.mocks.dll ; do
	gacutil -i %{buildroot}%{_prefix}/lib/nunit/$i -package nunit -root %{buildroot}%{_prefix}/lib
	rm -f %{buildroot}%{_prefix}/lib/nunit/$i
done

mkdir -p %{buildroot}%{_datadir}/pkgconfig
cat <<EOF > %{buildroot}%{_datadir}/pkgconfig/nunit.pc
prefix=%{_prefix}
exec_prefix=\${prefix}
libdir=\${exec_prefix}/lib
pkglibdir=\${prefix}/lib/mono/nunit

Name: NUnit
Description: Testing framework for .NET
Version: %{version}
Libs: -r:\${pkglibdir}/nunit.core.dll -r:\${pkglibdir}/nunit.core.interfaces.dll -r:\${pkglibdir}/nunit.framework.dll -r:\${pkglibdir}/nunit.util.dll r:\${pkglibdir}/nunit-console-runner.dll r:\${pkglibdir}/nunit-gui-runner.dll r:\${pkglibdir}/nunit.uiexception.dll r:\${pkglibdir}/nunit.uikit.dll r:\${pkglibdir}/nunit.mocks.dll
EOF

#fdupes %{buildroot}%{_prefix}

%clean
rm -rf %{buildroot}

%files
%defattr(-,root,root)
%doc docs_to_include/*
%{_bindir}/nunit
%{_prefix}/lib/nunit
%{_prefix}/lib/mono/nunit
%{_prefix}/lib/mono/gac/nunit*
#{_docdir}/nunit

%files devel
%defattr(-, root, root)
%{_datadir}/pkgconfig/nunit.pc

%changelog
* Tue May 26 2015 Ryoichi INAGAKI <ryo1@toki.waseda.jp> 2.6.4-2
- initial build for VineLinux

* Mon Dec 22 2014 mailaender@opensuse.org
- avoid the broken release ZIP file https://github.com/nunit/nunitv2/issues/35
- fix the pkgconfig file for MonoDevelop
- build with Debug symbols
- place copies into the global assembly cache
* Sun Dec 21 2014 mailaender@opensuse.org
- initial packaging
