diff --git a/.gitignore b/.gitignore new file mode 100644 index 0000000..ee2735f --- /dev/null +++ b/.gitignore @@ -0,0 +1 @@ +SOURCES/dotnet-v2.1.13.tar.gz diff --git a/.rh-dotnet21-dotnet.metadata b/.rh-dotnet21-dotnet.metadata new file mode 100644 index 0000000..7da8822 --- /dev/null +++ b/.rh-dotnet21-dotnet.metadata @@ -0,0 +1 @@ +5e682c8e8c5b07db830b324d4c8649e986abc9e8 SOURCES/dotnet-v2.1.13.tar.gz diff --git a/SOURCES/check-debug-symbols.py b/SOURCES/check-debug-symbols.py new file mode 100755 index 0000000..7eb06f9 --- /dev/null +++ b/SOURCES/check-debug-symbols.py @@ -0,0 +1,134 @@ +#!/usr/bin/python2 + +""" +Check debug symbols are present in shared object and can identify +code. + +It starts scanning from a directory and recursively scans all ELF +files found in it for various symbols to ensure all debuginfo is +present and nothing has been stripped. + +Usage: + +./check-debug-symbols /path/of/dir/to/scan/ + + +Example: + +./check-debug-symbols /usr/lib64 +""" + +# This technique was explained to me by Mark Wielaard (mjw). + +import collections +import os +import re +import subprocess +import sys + +ScanResult = collections.namedtuple('ScanResult', + 'file_name debug_info debug_abbrev file_symbols gnu_debuglink') + + +def scan_file(file): + "Scan the provided file and return a ScanResult containing results of the scan." + + # Test for .debug_* sections in the shared object. This is the main test. + # Stripped objects will not contain these. + readelf_S_result = subprocess.check_output(['eu-readelf', '-S', file]) + has_debug_info = any(line for line in readelf_S_result.split('\n') if '] .debug_info' in line) + + has_debug_abbrev = any(line for line in readelf_S_result.split('\n') if '] .debug_abbrev' in line) + + # Test FILE symbols. These will most likely be removed by anyting that + # manipulates symbol tables because it's generally useless. So a nice test + # that nothing has messed with symbols. + def contains_file_symbols(line): + parts = line.split() + if len(parts) < 8: + return False + return \ + parts[2] == '0' and parts[3] == 'FILE' and parts[4] == 'LOCAL' and parts[5] == 'DEFAULT' and \ + parts[6] == 'ABS' and re.match(r'((.*/)?[-_a-zA-Z0-9]+\.(c|cc|cpp|cxx))?', parts[7]) + + readelf_s_result = subprocess.check_output(["eu-readelf", '-s', file]) + has_file_symbols = any(line for line in readelf_s_result.split('\n') if contains_file_symbols(line)) + + # Test that there are no .gnu_debuglink sections pointing to another + # debuginfo file. There shouldn't be any debuginfo files, so the link makes + # no sense either. + has_gnu_debuglink = any(line for line in readelf_s_result.split('\n') if '] .gnu_debuglink' in line) + + return ScanResult(file, has_debug_info, has_debug_abbrev, has_file_symbols, has_gnu_debuglink) + +def is_elf(file): + result = subprocess.check_output(['file', file]) + return re.search('ELF 64-bit LSB (?:executable|shared object)', result) + +def scan_file_if_sensible(file): + if is_elf(file): + # print(file) + return scan_file(file) + return None + +def scan_dir(dir): + results = [] + for root, _, files in os.walk(dir): + for name in files: + result = scan_file_if_sensible(os.path.join(root, name)) + if result: + results.append(result) + return results + +def scan(file): + file = os.path.abspath(file) + if os.path.isdir(file): + return scan_dir(file) + elif os.path.isfile(file): + return scan_file_if_sensible(file) + +def is_bad_result(result): + return not result.debug_info or not result.debug_abbrev or not result.file_symbols or result.gnu_debuglink + +def print_scan_results(results, verbose): + # print(results) + for result in results: + file_name = result.file_name + found_issue = False + if not result.debug_info: + found_issue = True + print('error: missing .debug_info section in ' + file_name) + if not result.debug_abbrev: + found_issue = True + print('error: missing .debug_abbrev section in ' + file_name) + if not result.file_symbols: + found_issue = True + print('error: missing FILE symbols in ' + file_name) + if result.gnu_debuglink: + found_issue = True + print('error: unexpected .gnu_debuglink section in ' + file_name) + if verbose and not found_issue: + print('OK: ', file_name) + +def main(args): + verbose = False + files = [] + for arg in args: + if arg == '--verbose' or arg == '-v': + verbose = True + else: + files.append(arg) + + results = [] + for file in files: + results.extend(scan(file) or []) + + print_scan_results(results, verbose) + + if any(is_bad_result(result) for result in results): + return 1 + return 0 + + +if __name__ == '__main__': + sys.exit(main(sys.argv[1:])) diff --git a/SOURCES/core-setup-4510-commit-id.patch b/SOURCES/core-setup-4510-commit-id.patch new file mode 100644 index 0000000..cf896ef --- /dev/null +++ b/SOURCES/core-setup-4510-commit-id.patch @@ -0,0 +1,48 @@ +From e02ee86364b9db3edc298a6a081004aa07473d09 Mon Sep 17 00:00:00 2001 +From: Omair Majid +Date: Wed, 29 Aug 2018 17:03:25 -0400 +Subject: [PATCH] Allow setting the commit id using /p:LatestCommit + +This is similar to how CommitCount is already supported. + +This lets consumers who are building outside a git repo, such as +source-build, set a commit id which is displayed by `dotnet --info` +and `strings dotnet | grep '@(#)'`. + +See: https://github.com/dotnet/source-build/issues/651 +See: https://github.com/dotnet/cli/pull/5945 +--- + dir.targets | 9 +++++---- + 1 file changed, 5 insertions(+), 4 deletions(-) + +diff --git a/dir.targets b/dir.targets +index 8d34872c6..59dc1ebde 100644 +--- a/dir.targets ++++ b/dir.targets +@@ -17,7 +17,8 @@ + + + +- ++ + + + +@@ -29,13 +30,13 @@ + + + +- ++ + ++ ConsoleToMSBuild="true"> + + + diff --git a/SOURCES/corefx-32956-alpn.patch b/SOURCES/corefx-32956-alpn.patch new file mode 100644 index 0000000..88788b2 --- /dev/null +++ b/SOURCES/corefx-32956-alpn.patch @@ -0,0 +1,22 @@ +From 9b9697318e9990655ea878a28a00eda44fb615c2 Mon Sep 17 00:00:00 2001 +From: Jeremy Barton +Date: Mon, 22 Oct 2018 11:54:52 -0700 +Subject: [PATCH] Fix ALPN detection logic (for non-portable shim builds) + +--- + .../Unix/System.Security.Cryptography.Native/configure.cmake | 2 +- + 1 file changed, 1 insertion(+), 1 deletion(-) + +diff --git a/src/Native/Unix/System.Security.Cryptography.Native/configure.cmake b/src/Native/Unix/System.Security.Cryptography.Native/configure.cmake +index cdc9f50f3c33..fac8c16343df 100644 +--- a/src/Native/Unix/System.Security.Cryptography.Native/configure.cmake ++++ b/src/Native/Unix/System.Security.Cryptography.Native/configure.cmake +@@ -2,7 +2,7 @@ include(CheckLibraryExists) + include(CheckFunctionExists) + + set(CMAKE_REQUIRED_INCLUDES ${OPENSSL_INCLUDE_DIR}) +-set(CMAKE_REQUIRED_LIBRARIES ${OPENSSL_CRYPTO_LIBRARY}) ++set(CMAKE_REQUIRED_LIBRARIES ${OPENSSL_CRYPTO_LIBRARY} ${OPENSSL_SSL_LIBRARY}) + + check_function_exists( + EC_GF2m_simple_method diff --git a/SOURCES/register-completions.bash b/SOURCES/register-completions.bash new file mode 100644 index 0000000..1dd6509 --- /dev/null +++ b/SOURCES/register-completions.bash @@ -0,0 +1,16 @@ +# bash parameter completion for the dotnet CLI + +_dotnet_bash_complete() +{ + local word=${COMP_WORDS[COMP_CWORD]} + + local completions + completions="$(dotnet complete --position "${COMP_POINT}" "${COMP_LINE}" 2>/dev/null)" + if [ $? -ne 0 ]; then + completions="" + fi + + COMPREPLY=( $(compgen -W "$completions" -- "$word") ) +} + +complete -f -F _dotnet_bash_complete dotnet diff --git a/SPECS/dotnet.spec b/SPECS/dotnet.spec new file mode 100644 index 0000000..337e2c3 --- /dev/null +++ b/SPECS/dotnet.spec @@ -0,0 +1,365 @@ +# Do *NOT* try and build this locally (using rhpkg or any other tool) if one of +# the parent directories is a git repository. This build uses git-apply during +# the upstream build process. git-apply will simply skip all patches since none +# of the patches affect the build subdirectory. +# +# Use `rhpkg local --builddir ../dotnet-build` or something similar to work +# around this. + +%{?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 + +%global runtime_version 2.1.13 +%global sdk_version 2.1.509 + +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 + +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.1%{?_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 runtime-2.1 + +Version: %{runtime_version} +Summary: NET Core 2.1 runtime + +# Theoretically any version of the host should work +Requires: %{name}-host%{?_isa} + +# libicu is dlopen()ed +Requires: libicu +# libcurl is dlopen()ed +Requires: %{?scl_prefix}libcurl + +%description runtime-2.1 +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.1 + +Version: %{sdk_version} +Summary: .NET Core 2.1 Software Development Kit + +Requires: %{name}-sdk-2.1.5xx%{?_isa} + +%description sdk-2.1 +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.1.5xx + +Version: %{sdk_version} +Summary: .NET Core 2.1.5xx Software Development Kit + +Requires: %{name}-runtime-2.1%{?_isa} + +%description sdk-2.1.5xx +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} + +# See https://github.com/dotnet/source-build/pull/669 +rm -rf Tools/configuration/configuration.props + +# 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 +popd + +pushd src/core-setup +%patch300 -p1 +popd + +%build +%{?scl:scl enable %scl llvm-toolset-7 - << \EOF} +set -xe + +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 xf 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 runtime-2.1 +%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.1 +# empty package useful for dependencies + +%files sdk-2.1.5xx +%dir %{_libdir}/%{pkg_name}/sdk +%{_libdir}/%{pkg_name}/sdk/%{sdk_version} + +%changelog +* Thu Aug 29 2019 Omair Majid - 2.1.509-1 +- Update to .NET Core Runtime 2.1.13 and SDK 2.1.509 +- Resolves: RHBZ#1743290 + +* Wed Jul 10 2019 Omair Majid - 2.1.508-1 +- Update to .NET Core Runtime 2.1.12 and SDK 2.1.508 +- Resolves: RHBZ#1728839 + +* Wed May 01 2019 Omair Majid - 2.1.507-2 +- Use the latest upstream completion file for bash completion +- Resolves: RHBZ#1705259 + +* Wed May 01 2019 Omair Majid - 2.1.507-1 +- Update to .NET Core Runtime 2.1.11 and SDK 2.1.507 +- Resolves: RHBZ#1705147 + +* Tue Apr 02 2019 Omair Majid - 2.1.506-1 +- Update to .NET Core Runtime 2.1.10 and SDK 2.1.506 + +* Wed Mar 06 2019 Omair Majid - 2.1.505-1 +- Update to .NET Core Runtime 2.1.9 and SDK 2.1.505 +- Resolves: RHBZ#1685720 + +* Tue Jan 29 2019 Omair Majid - 2.1.504-1 +- Update to .NET Core Runtime 2.1.8 and SDK 2.1.504 +- Resolves: RHBZ#1670648 + +* Thu Dec 13 2018 Omair Majid - 2.1.503-1 +- Update to .NET Core Runtime 2.1.7 and SDK 2.1.503 +- Resolves: RHBZ#1659216 + +* Wed Nov 14 2018 Omair Majid - 2.1.500-5 +- Fix extract out of directory +- Resolves: CVE-2018-8416 +- Resolves: rhbz#1649693 + +* Fri Nov 09 2018 Omair Majid - 2.1.500-3 +- Fix linking alpn support by linking to OpenSSL correctly +- Fix commit ids in dotnet --info +- Resolves: rhbz#1643978 +- Resolves: rhbz#1648425 + +* Thu Nov 08 2018 Omair Majid - 2.1.500-2 +- Update to rebuild of .NET Core Runtime 2.1.5 and SDK 2.1.500 +- Resolves: rhbz#1646697 + +* Mon Nov 05 2018 Omair Majid - 2.1.500-1 +- Update to .NET Core Runtime 2.1.5 and SDK 2.1.500 +- Resolves: rhbz#1646697 + +* Mon Oct 01 2018 Omair Majid - 2.1.403-1 +- Update to .NET Core Runtime 2.1.5 and SDK 2.1.403 +- Resolves: rhbz#1634169 + +* Fri Sep 07 2018 Omair Majid - 2.1.402-2 +- Update to new build of .NET Core Runtime 2.1.4 and SDK 2.1.402 +- Resolves: RHBZ#1625403 + +* Tue Sep 04 2018 Omair Majid - 2.1.402-1 +- Update to .NET Core Runtime 2.1.4 and SDK 2.1.402 +- Fix OOM error in containers +- Resolves: RHBZ#1621889 + +* Wed Aug 08 2018 Omair Majid - 2.1.401-1 +- Update to .NET Core Runtime 2.1.3 and SDK 2.1.401 + +* Wed Jul 4 2018 Omair Majid - 2.1.302-1 +- Update to .NET Core Runtime 2.1.2 and SDK 2.1.302 + +* Wed Jun 20 2018 Omair Majid - 2.1.301-5 +- Add sdk-2.1.3xx subpackage + +* Tue Jun 19 2018 Omair Majid - 2.1.301-4 +- Rebuild to pick up new lttng-ust + +* Tue Jun 19 2018 Omair Majid - 2.1.301-3 +- Add workaround for unreadable system certificates +- Resolves: rhbz#1588099 + +* Tue Jun 19 2018 Omair Majid - 2.1.301-2 +- Add updated man pages +- Resolves: rhbz#1584790 + +* Thu Jun 14 2018 Omair Majid - 2.1.301-1 +- Update to .NET Core SDK 2.1.301 + +* Wed May 30 2018 Omair Majid - 2.1.300-7 +- Explicitly require a modified libcurl + +* Tue May 29 2018 Omair Majid - 2.1.300-6 +- Install bash completions in %%{_root_datadir} + +* Mon May 28 2018 Omair Majid - 2.1.300-5 +- Add provides for dotnet-sdk-2.1.3xx + +* Mon May 28 2018 Omair Majid - 2.1.300-4 +- Remove patch for ASP.NET Core templates. No longer needed for 2.1. + +* Fri May 25 2018 Omair Majid - 2.1.300-3 +- Remove net46 symlink + +* Thu May 24 2018 Omair Majid - 2.1.300-2 +- Rebuild to pick up updated dependencies + +* Thu May 24 2018 Omair Majid - 2.1.300-1 +- New package. Import from Fedora (DotNet SIG package).