Blob Blame History Raw
%{?scl:%scl_package dotnet}
%{!?scl:%global pkg_name %{name}}

# lldb doesn't like our nice debug information
%undefine _include_minidebuginfo
%global _find_debuginfo_dwz_opts %{nil}

# Avoid provides/requires from private libraries
%global privlibs             libhostfxr
%global privlibs %{privlibs}|libclrjit
%global privlibs %{privlibs}|libcoreclr
%global privlibs %{privlibs}|libcoreclrtraceptprovider
%global privlibs %{privlibs}|libdbgshim
%global privlibs %{privlibs}|libhostpolicy
%global privlibs %{privlibs}|libmscordaccore
%global privlibs %{privlibs}|libmscordbi
%global privlibs %{privlibs}|libsos
%global privlibs %{privlibs}|libsosplugin
%global __provides_exclude ^(%{privlibs})\\.so

# Remove private libraries and the automatically generated dependency
# on system libcurl package. We require the %%{?scl_prefix}libcurl package
%global __requires_exclude ^(%{privlibs}|libcurl)\\.so

# Filter flags not supported by clang/dotnet:
#  -fcf-protection is not supported by clang
#  -specs= is not supported by clang
%global dotnet_cflags %(echo %optflags | sed -e 's/-fcf-protection//' | sed -re 's/-specs=[^ ]*//g')
%global dotnet_ldflags %(echo %{__global_ldflags} | sed -re 's/-specs=[^ ]*//g')

%global host_version 2.2.7
%global runtime_version 2.2.7
%global sdk_version 2.2.109

Name:           %{?scl_prefix}dotnet
Version:        %{sdk_version}
Release:        1%{?dist}
Group:          Development/Languages
Summary:        .NET Core CLI tools and runtime
License:        MIT and ASL 2.0 and BSD
URL:            https://github.com/dotnet/

# The source is generated on a RHEL box via:
# - git clone https://github.com/dotnet/source-build
# - git checkout v%%{sdk_version}
# - set environment variables + tweak sources to build
# - ./build-source-tarball.sh dotnet-%%{sdk_version}
# - tar cvzf dotnet-%%{sdk_version}.tar.gz dotnet-%%{sdk_version}

Source0:        dotnet-v%{runtime_version}.tar.gz
Source1:        check-debug-symbols.py
Source2:        https://raw.githubusercontent.com/dotnet/cli/53f485c23cc467c62f80252696b8ec51ce8b4564/scripts/register-completions.bash

Patch100:       corefx-32956-alpn.patch
Patch101:       corefx-optflags-support.patch

Patch200:       coreclr-21084-llvm-home.patch

Patch300:       core-setup-4510-commit-id.patch

ExclusiveArch:  x86_64

BuildRequires:  llvm-toolset-7-clang
BuildRequires:  cmake
BuildRequires:  git
BuildRequires:  hostname
BuildRequires:  krb5-devel
BuildRequires:  %{?scl_prefix}libcurl-devel
BuildRequires:  libicu-devel
BuildRequires:  libunwind-devel
BuildRequires:  llvm-toolset-7-lldb-devel
BuildRequires:  llvm-toolset-7-llvm
BuildRequires:  %{?scl_prefix}lttng-ust-devel
BuildRequires:  openssl-devel
BuildRequires:  python2
BuildRequires:  zlib-devel

Requires:       %{name}-sdk-2.2%{?_isa}

%description
.NET Core is a fast, lightweight and modular platform for creating
cross platform applications that work on Linux, macOS and Windows.

It particularly focuses on creating console applications, web
applications and micro-services.

.NET Core contains a runtime conforming to .NET Standards a set of
framework libraries, an SDK containing compilers and a 'dotnet'
application to drive everything.

%package host

Version:        %{runtime_version}
Summary:        .NET command line launcher

%description host
The .NET Core host is a command line program that runs a standalone
.NET core application or launches the SDK.

.NET Core is a fast, lightweight and modular platform for creating
cross platform applications that work on Linux, Mac and Windows.

It particularly focuses on creating console applications, web
applications and micro-services.

%package host-fxr-2.2

Version:        %{host_version}
Summary:        .NET Core command line host resolver

# Theoretically any version of the host should work
Requires:       %{name}-host%{?_isa}

%description host-fxr-2.2
The .NET Core host resolver contains the logic to resolve and select
the right version of the .NET Core SDK or runtime to use.

.NET Core is a fast, lightweight and modular platform for creating
cross platform applications that work on Linux, Mac and Windows.

It particularly focuses on creating console applications, web
applications and micro-services.

%package runtime-2.2

Version:        %{runtime_version}
Summary:        NET Core 2.2 runtime

Requires:       %{name}-host-fxr-2.2%{?_isa}

# libicu is dlopen()ed
Requires:       libicu
# libcurl is dlopen()ed
Requires:       %{?scl_prefix}libcurl

%description runtime-2.2
The .NET Core runtime contains everything needed to run .NET Core applications.
It includes a high performance Virtual Machine as well as the framework
libraries used by .NET Core applications.

.NET Core is a fast, lightweight and modular platform for creating
cross platform applications that work on Linux, Mac and Windows.

It particularly focuses on creating console applications, web
applications and micro-services.

%package sdk-2.2

Version:        %{sdk_version}
Summary:        .NET Core 2.2 Software Development Kit

Requires:       %{name}-sdk-2.2.1xx%{?_isa}

%description sdk-2.2
The .NET Core SDK is a collection of command line applications to
create, build, publish and run .NET Core applications.

.NET Core is a fast, lightweight and modular platform for creating
cross platform applications that work on Linux, Mac and Windows.

It particularly focuses on creating console applications, web
applications and micro-services.

%package sdk-2.2.1xx

Version:        %{sdk_version}
Summary:        .NET Core 2.2.1xx Software Development Kit

Requires:       %{name}-runtime-2.2%{?_isa}

%description sdk-2.2.1xx
The .NET Core SDK is a collection of command line applications to
create, build, publish and run .NET Core applications.

.NET Core is a fast, lightweight and modular platform for creating
cross platform applications that work on Linux, Mac and Windows.

It particularly focuses on creating console applications, web
applications and micro-services.

%prep
%setup -q -n %{pkg_name}-v%{runtime_version}

# Disable warnings
sed -i 's|skiptests|skiptests ignorewarnings|' repos/coreclr.proj

# Fix bad hardcoded path in build
sed -i 's|/usr/share/dotnet|%{_libdir}/%{pkg_name}|' src/core-setup/src/corehost/common/pal.unix.cpp

pushd src/corefx
%patch100 -p1
%patch101 -p1
popd

pushd src/coreclr
%patch200 -p1
popd

pushd src/core-setup
%patch300 -p1
popd

%build
%{?scl:scl enable %scl llvm-toolset-7 - << \EOF}
set -xe

export CFLAGS="%{dotnet_cflags}"
export CXXFLAGS="%{dotnet_cflags}"
export LDFLAGS="%{dotnet_ldflags}"

export LIBRARY_PATH="%{_libdir}"
export LLVM_HOME=/opt/rh/llvm-toolset-7/root/usr 
export CMAKE_PREFIX_PATH="%{_prefix}"

VERBOSE=1 ./build.sh \
  /v:diag \
  /p:MinimalConsoleLogOutput=false \
  /p:ContinueOnPrebuiltBaselineError=true

%{?scl:EOF}

%install
install -d -m 0755 %{buildroot}%{_libdir}/%{pkg_name}/
ls bin/x64/Release
tar vxf bin/x64/Release/dotnet-sdk-%{sdk_version}-*.tar.gz -C %{buildroot}%{_libdir}/%{pkg_name}/

# Fix permissions on files
find %{buildroot}%{_libdir}/%{pkg_name}/ -type f -name '*.props' -exec chmod -x {} \;
find %{buildroot}%{_libdir}/%{pkg_name}/ -type f -name '*.targets' -exec chmod -x {} \;
find %{buildroot}%{_libdir}/%{pkg_name}/ -type f -name '*.dll' -exec chmod -x {} \;
find %{buildroot}%{_libdir}/%{pkg_name}/ -type f -name '*.pubxml' -exec chmod -x {} \;

install -dm 755 %{buildroot}/%{_root_datadir}/bash-completion/completions
# dynamic completion needs the file to be named the same as the base command
install %{SOURCE2} %{buildroot}/%{_root_datadir}/bash-completion/completions/dotnet

# TODO: the zsh completion script needs to be ported to use #compdef
#install -dm 755 %%{buildroot}/%%{_datadir}/zsh/site-functions
#install src/cli/scripts/register-completions.zsh %%{buildroot}/%%{_datadir}/zsh/site-functions/_dotnet

install -d -m 0755 %{buildroot}%{_bindir}
ln -s %{_libdir}/%{pkg_name}/dotnet %{buildroot}%{_bindir}/

install -d -m 0755 %{buildroot}%{_mandir}/man1/
find -iname 'dotnet*.1' -type f -exec cp {} %{buildroot}%{_mandir}/man1/ \;

# Check debug symbols in all elf objects. This is not in %%check
# because native binaries are stripped by rpm-build after %%install.
# So we need to do this check earlier.
echo "Testing build results for debug symbols..."
%{SOURCE1} -v %{buildroot}%{_libdir}/%{pkg_name}/

%check
%{buildroot}%{_libdir}/%{pkg_name}/dotnet --info

%files
# empty package useful for dependencies

%files host
%dir %{_libdir}/%{pkg_name}
%{_libdir}/%{pkg_name}/dotnet
%{_libdir}/%{pkg_name}/host
%{_bindir}/dotnet
%doc %{_libdir}/%{pkg_name}/LICENSE.txt
%doc %{_libdir}/%{pkg_name}/ThirdPartyNotices.txt
%doc %{_mandir}/man1/dotnet*.1.gz
# shell completions are currently only picked up from %%{_root_datadir}
%dir %{_root_datadir}/bash-completion
%dir %{_root_datadir}/bash-completion/completions
%{_root_datadir}/bash-completion/completions/dotnet

%files host-fxr-2.2
%dir %{_libdir}/%{pkg_name}/host/fxr
%{_libdir}/%{pkg_name}/host/fxr/%{host_version}

%files runtime-2.2
%dir %{_libdir}/%{pkg_name}/shared
%dir %{_libdir}/%{pkg_name}/shared/Microsoft.NETCore.App
%{_libdir}/%{pkg_name}/shared/Microsoft.NETCore.App/%{runtime_version}

%files sdk-2.2
# empty package useful for dependencies

%files sdk-2.2.1xx
%dir %{_libdir}/%{pkg_name}/sdk
%{_libdir}/%{pkg_name}/sdk/%{sdk_version}

%changelog
* Thu Aug 29 2019 Omair Majid <omajid@redhat.com> - 2.2.109-1
- Update to .NET Core Runtime 2.2.7 and SDK 2.2.109
- Resolves: RHBZ#1744260

* Thu Jul 11 2019 Omair Majid <omajid@redhat.com> - 2.2.108-2
- Fix strerror linkage issue identified by tests
- Resolves: RHBZ#1728895

* Wed Jul 10 2019 Omair Majid <omajid@redhat.com> - 2.2.108-1
- Update to .NET Core Runtime 2.2.6 and SDK 2.2.108
- Resolves: RHBZ#1728895

* Wed May 01 2019 Omair Majid <omajid@redhat.com> - 2.2.107-2
- Enable bash completion using the latest upstream completion file
- Resolves: RHBZ#1654863

* Tue Apr 30 2019 Omair Majid <omajid@redhat.com> - 2.2.107-1
- Update to .NET Core Runtime 2.2.5 and SDK 2.2.107
- Resolves: RHBZ#1704934

* Mon Apr 08 2019 Omair Majid <omajid@redhat.com> - 2.2.106-2
- Update to .NET Core Runtime 2.2.4 and SDK 2.2.106
- Resolves: RHBZ#1696779

* Fri Apr 05 2019 Omair Majid <omajid@redhat.com> - 2.2.203-1
- Update to .NET Core Runtime 2.2.4 and SDK 2.2.203
- Resolves: RHBZ#1696779

* Tue Mar 05 2019 Omair Majid <omajid@redhat.com> - 2.2.105-1
- Update to .NET Core Runtime 2.2.3 and SDK 2.2.105
- Resolves: RHBZ#1685718

* Wed Jan 30 2019 Omair Majid <omajid@redhat.com> - 2.2.104-2
- Update to .NET Core Runtime 2.2.2 and SDK 2.2.104
- Resolves: RHBZ#1671056

* Tue Jan 15 2019 Omair Majid <omajid@redhat.com> - 2.2.103-2
- Update to .NET Core SDK 2.2.103
- Resolves: RHBZ#1666465

* Tue Dec 18 2018 Omair Majid <omajid@redhat.com> - 2.2.102-1
- Update to .NET Core Runtime 2.2.1 and SDK 2.2.102
- Resolves: RHBZ#1660223

* Thu Nov 29 2018 Omair Majid <omajid@redhat.com> - 2.2.100-5
- Remove bash completion to fix parallel installation with .NET Core 2.1
- Resolves: RHBZ#1649584

* Wed Nov 21 2018 Omair Majid <omajid@redhat.com> - 2.2.100-4
- Fix dependency on host-fxr-2.2
- Resolves: RHBZ#1649584

* Wed Nov 21 2018 Omair Majid <omajid@redhat.com> - 2.2.100-3
- Fix configure check in the presence of distro-supplied cflags/ldflags
- Fixes ALPN support
- Resolves: RHBZ#1649584

* Tue Nov 20 2018 Omair Majid <omajid@redhat.com> - 2.2.100-2
- Increase build verbosity
- Resolves: RHBZ#1649584

* Mon Nov 19 2018 Omair Majid <omajid@redhat.com> - 2.2.100-1
- New package.
- Resolves: RHBZ#1649584