File newtonsoft-json.spec of Package newtonsoft-json

#
# spec file for package newtonsoft-json
#
# Copyright (c) 2015 SUSE LINUX GmbH, Nuernberg, Germany.
#
# All modifications and additions to the file contributed by third parties
# remain the property of their copyright owners, unless otherwise agreed
# upon. The license for this file, and modifications and additions to the
# file, is the same license as for the pristine package itself (unless the
# license for the pristine package is not an Open Source License, in which
# case the license is the MIT License). An "Open Source License" is a
# license that conforms to the Open Source Definition (Version 1.9)
# published by the Open Source Initiative.

# Please submit bugfixes or comments via http://bugs.opensuse.org/
#

%global libname Newtonsoft.Json

%bcond_with tests

Name:           newtonsoft-json
Version:        7.0.1
Release:        0
Summary:        Popular high-performance JSON framework

# almost all files are licensed as MIT/X11, but BSD for LinqBridge.cs
# (and LGPLv2.1+ for Tools/7-Zip, not used)
License:        MIT and BSD-3-Clause
URL:            http://www.newtonsoft.com/json
Source:         https://github.com/JamesNK/%{libname}/archive/%{version}.tar.gz#/%{name}-%{version}.tar.gz
# PATCH-MISSING-TAG
Patch0:         %{name}-sign.patch
# PATCH-MISSING-TAG
Patch1:         %{name}-tests-skip-samples.patch

BuildArch:      noarch
BuildRequires:  mono-devel
%if %{with tests}
# versioned binary enforces nunit version
BuildRequires:  nunit = 2.6.4
%endif

%description
%{libname} aka Json.NET is a popular high-performance JSON framework

%package devel
Summary:        Popular high-performance JSON framework
Group:          Development/Libraries/Other
Requires:       %{name} = %{version}-%{release}

%description devel
%{libname} aka Json.NET is a popular high-performance JSON framework


%prep
%setup -qn%{libname}-%{version}

# sign the assembly to get a strong name, https://msdn.microsoft.com/en-us/library/xc31ft41.aspx
%patch0
sn -k myKey.snk
sed -i /InternalsVisibleTo/d Src/%{libname}/Properties/AssemblyInfo.cs

%if %{with tests}
# skip files with unmet dependencies (FSharp etc.), FIXME use nuget
%patch1
sed -i /DiscriminatedUnionConverterTests.cs/d Src/%{libname}.Tests/%{libname}.Tests.csproj
sed -i /Serialization.DependencyInjectionTests.cs/d Src/%{libname}.Tests/%{libname}.Tests.csproj
sed -i /Serialization.FSharpTests.cs/d Src/%{libname}.Tests/%{libname}.Tests.csproj
sed -i /Serialization.ImmutableCollectionsTests.cs/d Src/%{libname}.Tests/%{libname}.Tests.csproj
sed -i /TestObjects.Currency.cs/d Src/%{libname}.Tests/%{libname}.Tests.csproj
sed -i /TestObjects.Shape.cs/d Src/%{libname}.Tests/%{libname}.Tests.csproj
sed -i /Schema.JsonSchemaBuilderTests.cs/d Src/%{libname}.Tests/%{libname}.Tests.csproj
sed -i /Schema.JsonSchemaNodeTests.cs/d Src/%{libname}.Tests/%{libname}.Tests.csproj
sed -i /Utilities.StringUtilsTests.cs/d Src/%{libname}.Tests/%{libname}.Tests.csproj
%endif


%build
pushd Src/%{libname}
xbuild %{libname}.csproj


%install
mkdir -p %{buildroot}/%{_prefix}/lib/mono/gac/
gacutil -i Src/%{libname}/bin/Debug/Net45/%{libname}.dll -f -package %{name} -root %{buildroot}/%{_prefix}/lib
# pkgconfig
mkdir -p %{buildroot}/%{_datadir}/pkgconfig
cat <<EOT >>%{buildroot}/%{_datadir}/pkgconfig/%{name}.pc
Name: %{libname}
Description: %{summary}
Version: %{version}
Requires: 
Libs: -r:%{_monodir}/%{name}/%{libname}.dll
Libraries=%{_monodir}/%{name}/%{libname}.dll
EOT


%check
%if %{with tests}
pushd Src/%{libname}.Tests
# FIXME unmet dependencies prevent many tests (Linq, Utilities etc.)
xbuild %{libname}.Tests.csproj
nunit-console26 -labels -stoponerror bin\Debug\Net45\*.dll
#rm -r obj bin
%endif


%files
%defattr(-,root,root,-)
%doc *.md Doc/readme.txt Doc/license.txt
%{_prefix}/lib/mono/gac/%{libname}
%{_prefix}/lib/mono/%{name}/

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


%changelog
openSUSE Build Service is sponsored by