File msbuild.spec of Package msbuild

#
# spec file for package msbuild
#
# Copyright (c) 2016 Xamarin, Inc (http://www.xamarin.com)
#
# 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.

%bcond offline_packages 1
%bcond offline_tools 1

%define dotnet_sdk_version 3.1.100
%define dotnet_runtime_version 2.1.7

%if %{with offline_packages}
%define with_source_1 -a1
%endif

Name:           msbuild
Version:        16.6+xamarinxplat.2021.01.15.16.11
Release:        0
Summary:        Build system for .NET projects
Epoch:          1
License:        MIT
Group:          Development/Libraries/Other
Url:            https://github.com/Microsoft/msbuild
BuildRoot:      %{_tmppath}/%{name}-%{version}-build
Source0:        https://download.mono-project.com/sources/%{name}/%{name}-%{version}.tar.xz
%if %{with offline_packages}
Source1:        %{name}-%{version}_offline_packages.tar.xz
%endif
%if %{with offline_tools}
Source2:        https://github.com/mono/msbuild/releases/download/0.08/mono_msbuild_6.4.0.208.zip
Source3:        https://dot.net/v1/dotnet-install.sh
Source4:        https://builds.dotnet.microsoft.com/dotnet/Sdk/%{dotnet_sdk_version}/dotnet-sdk-%{dotnet_sdk_version}-linux-x64.tar.gz
Source5:        https://builds.dotnet.microsoft.com/dotnet/Runtime/%{dotnet_runtime_version}/dotnet-runtime-%{dotnet_runtime_version}-linux-x64.tar.gz
%endif
Patch0:         copy_hostfxr.patch
Patch1:         license_check_is_case_sensitive.diff
Patch2:         case_sensitive_dotnetbits.patch
%if %{with offline_packages}
Patch3:         msbuild-16.6-use-offline-packages.patch
%else
# dotnetfeed.blob.core.windows.net has been discontinued.
# https://github.com/dotnet/core/issues/9773
Patch4:         msbuild-16.6-update-dotnet-feed.patch
%endif
# Microsoft.DotNet.Arcade.Sdk 1.0.0-beta.20202.9 is no longer available.
Patch5:         msbuild-16.6-fix-nuget-restore-error.patch
# https://github.com/mono/msbuild/commit/6d59639af22d25f2667db80d62ec1f37529f2271
Patch6:         msbuild-16.6-remove-AzureRepos.Git-package.patch
%if %{with offline_tools}
Patch7:         msbuild-16.6-use-offline-tools.patch
%endif
BuildRequires:  mono-devel
BuildRequires:  libcurl-devel
BuildRequires:  openssl-devel
BuildRequires:  msbuild-libhostfxr
# https://github.com/dotnet/msbuild/issues/4194
BuildRequires:  (glibc-langpack-en or glibc-all-langpacks)
BuildArch:      noarch
# https://github.com/dotnet/msbuild/issues/4194
Requires:       (glibc-langpack-en or glibc-all-langpacks)
Recommends:     %{name}-sdkresolver = %{epoch}:%{version}-%{release}

%description
The Microsoft Build Engine is a platform for building applications.
This engine, which is also known as MSBuild, provides an XML schema
for a project file that controls how the build platform processes
and builds software. Visual Studio uses MSBuild, but MSBuild does
not depend on Visual Studio. By invoking msbuild.exe on your
project or solution file, you can orchestrate and build products
in environments where Visual Studio isn't installed.

%package sdkresolver
Summary:        Build system for .NET projects - .NET Core location resolver
License:        MIT
Group:          Development/Libraries/Other
Requires:       %{name} = %{epoch}:%{version}-%{release}
Requires:       msbuild-libhostfxr

%description sdkresolver
The Microsoft Build Engine is a platform for building applications.
This engine, which is also known as MSBuild, provides an XML schema
for a project file that controls how the build platform processes
and builds software. Visual Studio uses MSBuild, but MSBuild does
not depend on Visual Studio. By invoking msbuild.exe on your
project or solution file, you can orchestrate and build products
in environments where Visual Studio isn't installed. This package
contains components needed to build with .NET Core.

%prep
%autosetup -p1 -n msbuild-16.6 %{?with_source_1}
%if %{with offline_tools}
install -D -t ./offline_tools %{SOURCE2} %{SOURCE3}
install -D -t ./offline_tools/Sdk/%{dotnet_sdk_version} %{SOURCE4}
install -D -t ./offline_tools/Runtime/%{dotnet_runtime_version} %{SOURCE5}
%endif

%define _use_internal_dependency_generator 0
%define requires_filter \\\
  | sed "s/\\(mono(System.Data.Common)\\).*/\\1 = 4.2.1.0/" \\\
  | sed "s/\\(mono(System.Diagnostics.StackTrace)\\).*/\\1 = 4.1.1.0/" \\\
  | sed "s/\\(mono(System.Globalization.Extensions)\\).*/\\1 = 4.1.1.0/" \\\
  | sed "s/\\(mono(System.IO.Compression)\\).*/\\1 = 4.0.0.0/" \\\
  | sed "s/\\(mono(System.Net.Http)\\).*/\\1 = 4.0.0.0/" \\\
  | sed "s/\\(mono(System.Net.Primitives)\\).*/\\1 = 4.0.10.0/" \\\
  | sed "s/\\(mono(System.Net.Requests)\\).*/\\1 = 4.0.10.0/" \\\
  | sed "s/\\(mono(System.Runtime.InteropServices.RuntimeInformation)\\).*/\\1 = 4.0.3.0/" \\\
  | sed "s/\\(mono(System.Security.Cryptography.Algorithms)\\).*/\\1 = 4.3.1.0/" \\\
  | sed "s/\\(mono(System.Security.SecureString)\\).*/\\1 = 4.1.1.0/" \\\
  | sed "s/\\(mono(System.ServiceModel.Duplex)\\).*/\\1 = 4.0.3.0/" \\\
  | sed "s/\\(mono(System.ServiceModel.Http)\\).*/\\1 = 4.1.2.0/" \\\
  | sed "s/\\(mono(System.ServiceModel.Primitives)\\).*/\\1 = 4.2.0.0/" \\\
  | sed "s/\\(mono(System.ServiceModel.Security)\\).*/\\1 = 4.0.2.0/" \\\
  | sed "s/\\(mono(System.Threading.Overlapped)\\).*/\\1 = 4.1.1.0/" \\\
  | sed "s/\\(mono(System.Xml.ReaderWriter)\\).*/\\1 = 4.1.0.0/" \\\
  | sed "s/\\(mono(System.Xml.XPath.XDocument)\\).*/\\1 = 4.1.1.0/" \\\
  | grep -vF "mono(Microsoft.AspNetCore.Razor.Language) = 3.1.2.0" \\\
  | grep -vF "mono(Microsoft.Build.Framework) = 15.1.0.0" \\\
  | grep -vF "mono(Microsoft.Build.Tasks.CodeAnalysis) = 3.6.2.22405" \\\
  | grep -vF "mono(Microsoft.CodeAnalysis) = 3.0.0.0" \\\
  | grep -vF "mono(Microsoft.CodeAnalysis) = 3.3.0.0" \\\
  | grep -vF "mono(Microsoft.CodeAnalysis.CSharp) = 3.0.0.0" \\\
  | grep -vF "mono(Microsoft.CodeAnalysis.CSharp) = 3.3.0.0" \\\
  | grep -vF "mono(Microsoft.CodeAnalysis.Razor) = 3.1.2.0" \\\
  | grep -vF "mono(Microsoft.CodeAnalysis.Workspaces) = 3.0.0.0" \\\
  | grep -vF "mono(Microsoft.Web.Administration) = 7.0.0.0" \\\
  | grep -vF "mono(Microsoft.Web.Deployment.Tracing) = 9.0.0.0" \\\
  | grep -vF "mono(Microsoft.Web.Hosting) = 7.1.0.0" \\\
  | grep -vF "mono(System.Composition.AttributedModel) = 1.0.31.0" \\\
  | grep -vF "= 0.0.0.0" \\\
  %{nil}

%if 0%{?fedora} || 0%{?rhel} || 0%{?centos}
%define __find_provides env sh -c 'filelist=($(cat)) && { printf "%s\\n" "${filelist[@]}" | %{_prefix}/lib/rpm/redhat/find-provides && printf "%s\\n" "${filelist[@]}" | %{_prefix}/bin/mono-find-provides ; } | sort | uniq'
%define __find_requires env sh -c 'filelist=($(cat)) && { printf "%s\\n" "${filelist[@]}" | %{_prefix}/lib/rpm/redhat/find-requires && printf "%s\\n" "${filelist[@]}" | %{_prefix}/bin/mono-find-requires ; } %{requires_filter} | sort | uniq'
%else
%define __find_provides env sh -c 'filelist=($(cat)) && { printf "%s\\n" "${filelist[@]}" | %{_prefix}/lib/rpm/find-provides && printf "%s\\n" "${filelist[@]}" | %{_prefix}/bin/mono-find-provides ; } | sort | uniq'
%define __find_requires env sh -c 'filelist=($(cat)) && { printf "%s\\n" "${filelist[@]}" | %{_prefix}/lib/rpm/find-requires && printf "%s\\n" "${filelist[@]}" | %{_prefix}/bin/mono-find-requires ; } %{requires_filter} | sort | uniq'
%endif

%build
%{?exp_env}
%{?env_options}
./eng/cibuild_bootstrapped_msbuild.sh --host_type mono --configuration Release --skip_tests /p:DisableNerdbankVersioning=true

%install
%{?env_options}
./stage1/mono-msbuild/msbuild mono/build/install.proj /p:MonoInstallPrefix=%{buildroot}/%_prefix /p:Configuration=Release-MONO /p:IgnoreDiffFailure=true
sed -i "s@%{buildroot}@@g" %{buildroot}/%_prefix/bin/msbuild
find %{buildroot} -name Microsoft.DiaSymReader.Native.*dll -delete
find %{buildroot} -name *.dylib -delete
find %{buildroot} -name *.so -delete

%pretrans -p <lua>
path = "/usr/lib/mono/msbuild/15.0"
st = posix.stat(path)
if st and st.type == "directory" then
  status = os.rename(path, path .. ".rpmmoved")
  if not status then
    suffix = 0
    while not status do
      suffix = suffix + 1
      status = os.rename(path .. ".rpmmoved", path .. ".rpmmoved." .. suffix)
    end
    os.rename(path, path .. ".rpmmoved")
  end
end
path = "/usr/lib/mono/xbuild/15.0"
st = posix.stat(path)
if st and st.type == "directory" then
  status = os.rename(path, path .. ".rpmmoved")
  if not status then
    suffix = 0
    while not status do
      suffix = suffix + 1
      status = os.rename(path .. ".rpmmoved", path .. ".rpmmoved." .. suffix)
    end
    os.rename(path, path .. ".rpmmoved")
  end
end

%files
%defattr(-,root,root)
%_prefix/lib/mono/msbuild/15.0
%_prefix/lib/mono/msbuild/Current/bin/ru
%_prefix/lib/mono/msbuild/Current/bin/fr
%_prefix/lib/mono/msbuild/Current/bin/ja
%_prefix/lib/mono/msbuild/Current/bin/cs
%_prefix/lib/mono/msbuild/Current/bin/ko
%_prefix/lib/mono/msbuild/Current/bin/de
%_prefix/lib/mono/msbuild/Current/bin/en
%_prefix/lib/mono/msbuild/Current/bin/es
%_prefix/lib/mono/msbuild/Current/bin/it
%_prefix/lib/mono/msbuild/Current/bin/pl
%_prefix/lib/mono/msbuild/Current/bin/pt-BR
%_prefix/lib/mono/msbuild/Current/bin/tr
%_prefix/lib/mono/msbuild/Current/bin/zh-Hans
%_prefix/lib/mono/msbuild/Current/bin/zh-Hant
%_prefix/lib/mono/msbuild/Current/bin/Sdks
%_prefix/lib/mono/msbuild/Current/bin/*.config
%_prefix/lib/mono/msbuild/Current/bin/*.dll
%_prefix/lib/mono/msbuild/Current/bin/*.json
%_prefix/lib/mono/msbuild/Current/bin/*.overridetasks
%_prefix/lib/mono/msbuild/Current/bin/*.props
%_prefix/lib/mono/msbuild/Current/bin/*.rsp
%_prefix/lib/mono/msbuild/Current/bin/*.targets
%_prefix/lib/mono/msbuild/Current/bin/*.tasks
%_prefix/lib/mono/msbuild/Current/bin/*.xml
%_prefix/lib/mono/msbuild/Current/bin/*.xsd
%_prefix/lib/mono/xbuild/15.0
%_prefix/lib/mono/xbuild/Current
%_prefix/lib/mono/xbuild/Microsoft
%_prefix/lib/mono/xbuild/*.dll*
%_prefix/lib/mono/xbuild/*.pdb*
%_prefix/share/man/*/*
%_bindir/*

%files sdkresolver
%defattr(-,root,root)
%_prefix/lib/mono/msbuild/Current/bin/SdkResolvers/
openSUSE Build Service is sponsored by