From 6a9d9f51d7a908aefa02e745a6bd576b351e5a6a Mon Sep 17 00:00:00 2001 From: Jia Yuan Lo Date: Fri, 20 Dec 2024 13:55:32 +0800 Subject: [PATCH] addpkg(main): dotnet9.0 --- packages/dotnet-host/build.sh | 7 +- packages/dotnet9.0/0001-build-all-libs.patch | 17 + .../dotnet9.0/0002-define-memfd_create.patch | 11 + ...ve-libs-System.IO.Compression.Native.patch | 31 ++ ...ty.Cryptography.Native-opensslshim.c.patch | 17 + ...ime-eng-common-cross-toolchain.cmake.patch | 55 +++ .../0007-runtime-eng-DotNetBuild.props.patch | 11 + .../0008-aspire_fix-gitinfo-target.patch | 12 + ...ime-src-coreclr-vm-threadstatics.cpp.patch | 13 + ...HOSTPOLICY_EMBEDDED-PINVOKE_OVERRIDE.patch | 234 ++++++++++++ .../aspnetcore-runtime-9.0.subpackage.sh | 4 + .../aspnetcore-runtime-dbg-9.0.subpackage.sh | 4 + ...spnetcore-targeting-pack-9.0.subpackage.sh | 4 + packages/dotnet9.0/build.sh | 343 ++++++++++++++++++ .../dotnet-apphost-pack-9.0.subpackage.sh | 3 + .../dotnet9.0/dotnet-host-9.0.subpackage.sh | 4 + .../dotnet-hostfxr-9.0.subpackage.sh | 4 + .../dotnet-runtime-9.0.subpackage.sh | 4 + .../dotnet-runtime-dbg-9.0.subpackage.sh | 4 + .../dotnet9.0/dotnet-sdk-9.0.subpackage.sh | 31 ++ .../dotnet-sdk-dbg-9.0.subpackage.sh | 4 + .../dotnet-targeting-pack-9.0.subpackage.sh | 4 + .../dotnet-templates-9.0.subpackage.sh | 4 + packages/dotnet9.0/dotnet.sh.in | 13 + ...ndard-targeting-pack-2.1-9.0.subpackage.sh | 5 + .../netstandard-targeting-pack-2.1/build.sh | 7 +- scripts/big-pkgs.list | 1 + 27 files changed, 843 insertions(+), 8 deletions(-) create mode 100644 packages/dotnet9.0/0001-build-all-libs.patch create mode 100644 packages/dotnet9.0/0002-define-memfd_create.patch create mode 100644 packages/dotnet9.0/0003-runtime-src-native-libs-System.IO.Compression.Native.patch create mode 100644 packages/dotnet9.0/0005-runtime-src-native-libs-System.Security.Cryptography.Native-opensslshim.c.patch create mode 100644 packages/dotnet9.0/0006-runtime-eng-common-cross-toolchain.cmake.patch create mode 100644 packages/dotnet9.0/0007-runtime-eng-DotNetBuild.props.patch create mode 100644 packages/dotnet9.0/0008-aspire_fix-gitinfo-target.patch create mode 100644 packages/dotnet9.0/0009-src-runtime-src-coreclr-vm-threadstatics.cpp.patch create mode 100644 packages/dotnet9.0/0010-revert-stop-setting-separate-properties-BUNDLE_PROP-HOSTPOLICY_EMBEDDED-PINVOKE_OVERRIDE.patch create mode 100644 packages/dotnet9.0/aspnetcore-runtime-9.0.subpackage.sh create mode 100644 packages/dotnet9.0/aspnetcore-runtime-dbg-9.0.subpackage.sh create mode 100644 packages/dotnet9.0/aspnetcore-targeting-pack-9.0.subpackage.sh create mode 100644 packages/dotnet9.0/build.sh create mode 100644 packages/dotnet9.0/dotnet-apphost-pack-9.0.subpackage.sh create mode 100644 packages/dotnet9.0/dotnet-host-9.0.subpackage.sh create mode 100644 packages/dotnet9.0/dotnet-hostfxr-9.0.subpackage.sh create mode 100644 packages/dotnet9.0/dotnet-runtime-9.0.subpackage.sh create mode 100644 packages/dotnet9.0/dotnet-runtime-dbg-9.0.subpackage.sh create mode 100644 packages/dotnet9.0/dotnet-sdk-9.0.subpackage.sh create mode 100644 packages/dotnet9.0/dotnet-sdk-dbg-9.0.subpackage.sh create mode 100644 packages/dotnet9.0/dotnet-targeting-pack-9.0.subpackage.sh create mode 100644 packages/dotnet9.0/dotnet-templates-9.0.subpackage.sh create mode 100644 packages/dotnet9.0/dotnet.sh.in create mode 100644 packages/dotnet9.0/netstandard-targeting-pack-2.1-9.0.subpackage.sh diff --git a/packages/dotnet-host/build.sh b/packages/dotnet-host/build.sh index 6198e4ff115877..af37ac52013c8b 100644 --- a/packages/dotnet-host/build.sh +++ b/packages/dotnet-host/build.sh @@ -2,10 +2,9 @@ TERMUX_PKG_HOMEPAGE=https://dotnet.microsoft.com/en-us/ TERMUX_PKG_DESCRIPTION="A metapackage for .NET Host" TERMUX_PKG_LICENSE="Public Domain" TERMUX_PKG_MAINTAINER="@truboxl" -TERMUX_PKG_VERSION="8.0" -TERMUX_PKG_REVISION=1 -TERMUX_PKG_DEPENDS="dotnet-host-8.0" -TERMUX_PKG_ANTI_BUILD_DEPENDS="dotnet-host-8.0" +TERMUX_PKG_VERSION="9.0" +TERMUX_PKG_DEPENDS="dotnet-host-9.0 | dotnet-host-8.0" +TERMUX_PKG_ANTI_BUILD_DEPENDS="dotnet-host-9.0, dotnet-host-8.0" TERMUX_PKG_AUTO_UPDATE=false TERMUX_PKG_METAPACKAGE=true TERMUX_PKG_PLATFORM_INDEPENDENT=true diff --git a/packages/dotnet9.0/0001-build-all-libs.patch b/packages/dotnet9.0/0001-build-all-libs.patch new file mode 100644 index 00000000000000..75dd3f34c0f0ec --- /dev/null +++ b/packages/dotnet9.0/0001-build-all-libs.patch @@ -0,0 +1,17 @@ +--- a/src/runtime/src/native/libs/CMakeLists.txt ++++ b/src/runtime/src/native/libs/CMakeLists.txt +@@ -150,13 +150,10 @@ if (CLR_CMAKE_TARGET_UNIX OR CLR_CMAKE_TARGET_BROWSER OR CLR_CMAKE_TARGET_WASI) + #add_subdirectory(System.Net.Security.Native) # no gssapi on tvOS, see https://developer.apple.com/documentation/gss + # System.Security.Cryptography.Native is intentionally disabled on tvOS + # it is only used for interacting with OpenSSL which isn't useful there +- elseif (CLR_CMAKE_TARGET_ANDROID AND NOT FORCE_ANDROID_OPENSSL) +- add_subdirectory(System.Security.Cryptography.Native.Android) +- elseif (FORCE_ANDROID_OPENSSL) +- add_subdirectory(System.Security.Cryptography.Native) + else () + add_subdirectory(System.Net.Security.Native) + add_subdirectory(System.Security.Cryptography.Native) ++ add_subdirectory(System.Security.Cryptography.Native.Android) + endif () + + if (CLR_CMAKE_TARGET_APPLE) diff --git a/packages/dotnet9.0/0002-define-memfd_create.patch b/packages/dotnet9.0/0002-define-memfd_create.patch new file mode 100644 index 00000000000000..be433c43dde8ac --- /dev/null +++ b/packages/dotnet9.0/0002-define-memfd_create.patch @@ -0,0 +1,11 @@ +--- a/src/runtime/src/coreclr/minipal/Unix/doublemapping.cpp ++++ b/src/runtime/src/coreclr/minipal/Unix/doublemapping.cpp +@@ -14,7 +14,7 @@ + #include + #include + #include +-#if defined(TARGET_LINUX) && !defined(MFD_CLOEXEC) ++#if (defined(TARGET_LINUX) && !defined(MFD_CLOEXEC)) || defined(TARGET_ANDROID) + #include + #include // __NR_memfd_create + #define memfd_create(...) syscall(__NR_memfd_create, __VA_ARGS__) diff --git a/packages/dotnet9.0/0003-runtime-src-native-libs-System.IO.Compression.Native.patch b/packages/dotnet9.0/0003-runtime-src-native-libs-System.IO.Compression.Native.patch new file mode 100644 index 00000000000000..d3870807999ff4 --- /dev/null +++ b/packages/dotnet9.0/0003-runtime-src-native-libs-System.IO.Compression.Native.patch @@ -0,0 +1,31 @@ +--- a/src/runtime/src/native/libs/System.IO.Compression.Native/CMakeLists.txt ++++ b/src/runtime/src/native/libs/System.IO.Compression.Native/CMakeLists.txt +@@ -60,7 +60,7 @@ if (CLR_CMAKE_TARGET_UNIX OR CLR_CMAKE_TARGET_BROWSER OR CLR_CMAKE_TARGET_WASI) + ${NATIVE_LIBS_EXTRA} + ) + +- if (NOT CLR_CMAKE_TARGET_MACCATALYST AND NOT CLR_CMAKE_TARGET_IOS AND NOT CLR_CMAKE_TARGET_TVOS AND NOT CLR_CMAKE_TARGET_ANDROID AND NOT CLR_CMAKE_USE_SYSTEM_BROTLI) ++ if (NOT CLR_CMAKE_TARGET_MACCATALYST AND NOT CLR_CMAKE_TARGET_IOS AND NOT CLR_CMAKE_TARGET_TVOS AND NOT CLR_CMAKE_USE_SYSTEM_BROTLI) + set(DEF_SOURCES ${CMAKE_CURRENT_SOURCE_DIR}/System.IO.Compression.Native_unixexports.src) + set(EXPORTS_FILE ${CMAKE_CURRENT_BINARY_DIR}/System.IO.Compression.Native.exports) + generate_exports_file(${DEF_SOURCES} ${EXPORTS_FILE}) +@@ -114,7 +114,7 @@ else () + endif() + endif () + +- if (NOT GEN_SHARED_LIB AND NOT CLR_CMAKE_TARGET_MACCATALYST AND NOT CLR_CMAKE_TARGET_IOS AND NOT CLR_CMAKE_TARGET_TVOS AND NOT CLR_CMAKE_TARGET_ANDROID AND NOT CLR_CMAKE_TARGET_BROWSER AND NOT CLR_CMAKE_TARGET_WASI) ++ if (NOT GEN_SHARED_LIB AND NOT CLR_CMAKE_TARGET_MACCATALYST AND NOT CLR_CMAKE_TARGET_IOS AND NOT CLR_CMAKE_TARGET_TVOS AND NOT CLR_CMAKE_TARGET_BROWSER AND NOT CLR_CMAKE_TARGET_WASI) + set(NATIVECOMPRESSION_SOURCES ${NATIVECOMPRESSION_SOURCES} entrypoints.c) + endif () + +--- a/src/runtime/src/native/libs/System.IO.Compression.Native/extra_libs.cmake ++++ b/src/runtime/src/native/libs/System.IO.Compression.Native/extra_libs.cmake +@@ -16,7 +16,7 @@ macro(append_extra_compression_libs NativeLibsExtra) + # 'zlib' represents our in-tree zlib, and is used in all other platforms + # that don't meet any of the previous special requirements, like most + # regular Unix and Windows builds. +- list(APPEND ZLIB_LIBRARIES $,z,zlib>) ++ list(APPEND ZLIB_LIBRARIES $,z,zlib> m) + endif () + list(APPEND ${NativeLibsExtra} ${ZLIB_LIBRARIES}) + diff --git a/packages/dotnet9.0/0005-runtime-src-native-libs-System.Security.Cryptography.Native-opensslshim.c.patch b/packages/dotnet9.0/0005-runtime-src-native-libs-System.Security.Cryptography.Native-opensslshim.c.patch new file mode 100644 index 00000000000000..b9d7019cb8aa22 --- /dev/null +++ b/packages/dotnet9.0/0005-runtime-src-native-libs-System.Security.Cryptography.Native-opensslshim.c.patch @@ -0,0 +1,17 @@ +--- a/src/runtime/src/native/libs/System.Security.Cryptography.Native/opensslshim.c ++++ b/src/runtime/src/native/libs/System.Security.Cryptography.Native/opensslshim.c +@@ -77,14 +77,6 @@ static void OpenLibraryOnce(void) + DlOpen(soName); + } + +-#ifdef TARGET_ANDROID +- if (libssl == NULL) +- { +- // Android OpenSSL has no soname +- DlOpen(LIBNAME); +- } +-#endif +- + if (libssl == NULL) + { + // Prefer OpenSSL 3.x diff --git a/packages/dotnet9.0/0006-runtime-eng-common-cross-toolchain.cmake.patch b/packages/dotnet9.0/0006-runtime-eng-common-cross-toolchain.cmake.patch new file mode 100644 index 00000000000000..85644adfa488e5 --- /dev/null +++ b/packages/dotnet9.0/0006-runtime-eng-common-cross-toolchain.cmake.patch @@ -0,0 +1,55 @@ +--- a/src/runtime/eng/common/cross/toolchain.cmake ++++ b/src/runtime/eng/common/cross/toolchain.cmake +@@ -36,6 +36,8 @@ if(TARGET_ARCH_NAME STREQUAL "arm") + set(TOOLCHAIN "armv7-alpine-linux-musleabihf") + elseif(EXISTS ${CROSS_ROOTFS}/usr/lib/gcc/armv6-alpine-linux-musleabihf) + set(TOOLCHAIN "armv6-alpine-linux-musleabihf") ++ elseif(EXISTS ${CROSS_ROOTFS}/usr/lib/arm-linux-androideabi) ++ set(TOOLCHAIN "armv7-linux-androideabi") + else() + set(TOOLCHAIN "arm-linux-gnueabihf") + endif() +@@ -46,6 +48,8 @@ elseif(TARGET_ARCH_NAME STREQUAL "arm64") + set(CMAKE_SYSTEM_PROCESSOR aarch64) + if(EXISTS ${CROSS_ROOTFS}/usr/lib/gcc/aarch64-alpine-linux-musl) + set(TOOLCHAIN "aarch64-alpine-linux-musl") ++ elseif(EXISTS ${CROSS_ROOTFS}/usr/lib/aarch64-linux-android) ++ set(TOOLCHAIN "aarch64-linux-android") + elseif(LINUX) + set(TOOLCHAIN "aarch64-linux-gnu") + if(TIZEN) +@@ -78,6 +82,8 @@ elseif(TARGET_ARCH_NAME STREQUAL "riscv64") + set(CMAKE_SYSTEM_PROCESSOR riscv64) + if(EXISTS ${CROSS_ROOTFS}/usr/lib/gcc/riscv64-alpine-linux-musl) + set(TOOLCHAIN "riscv64-alpine-linux-musl") ++ elseif(EXISTS ${CROSS_ROOTFS}/usr/lib/riscv64-linux-android) ++ set(TOOLCHAIN "riscv64-linux-android") + else() + set(TOOLCHAIN "riscv64-linux-gnu") + endif() +@@ -92,6 +98,8 @@ elseif(TARGET_ARCH_NAME STREQUAL "x64") + set(CMAKE_SYSTEM_PROCESSOR x86_64) + if(EXISTS ${CROSS_ROOTFS}/usr/lib/gcc/x86_64-alpine-linux-musl) + set(TOOLCHAIN "x86_64-alpine-linux-musl") ++ elseif(EXISTS ${CROSS_ROOTFS}/usr/lib/x86_64-linux-android) ++ set(TOOLCHAIN "x86_64-linux-android") + elseif(LINUX) + set(TOOLCHAIN "x86_64-linux-gnu") + if(TIZEN) +@@ -108,6 +116,8 @@ elseif(TARGET_ARCH_NAME STREQUAL "x86") + set(CMAKE_SYSTEM_PROCESSOR i686) + if(EXISTS ${CROSS_ROOTFS}/usr/lib/gcc/i586-alpine-linux-musl) + set(TOOLCHAIN "i586-alpine-linux-musl") ++ elseif(EXISTS ${CROSS_ROOTFS}/usr/lib/i686-linux-android) ++ set(TOOLCHAIN "i686-linux-android") + else() + set(TOOLCHAIN "i686-linux-gnu") + endif() +@@ -244,6 +254,7 @@ else() + set(CMAKE_C_COMPILER_EXTERNAL_TOOLCHAIN "${CROSS_ROOTFS}/usr") + set(CMAKE_CXX_COMPILER_EXTERNAL_TOOLCHAIN "${CROSS_ROOTFS}/usr") + set(CMAKE_ASM_COMPILER_EXTERNAL_TOOLCHAIN "${CROSS_ROOTFS}/usr") ++ include(${CROSS_ROOTFS}/../build/cmake/android.toolchain.cmake) + endif() + + # Specify link flags diff --git a/packages/dotnet9.0/0007-runtime-eng-DotNetBuild.props.patch b/packages/dotnet9.0/0007-runtime-eng-DotNetBuild.props.patch new file mode 100644 index 00000000000000..fb7d8301e52913 --- /dev/null +++ b/packages/dotnet9.0/0007-runtime-eng-DotNetBuild.props.patch @@ -0,0 +1,11 @@ +--- a/src/runtime/eng/DotNetBuild.props ++++ b/src/runtime/eng/DotNetBuild.props +@@ -88,7 +88,7 @@ + + + +$(UseSystemLibs)+ +- $(InnerBuildArgs) --cmakeargs -DCLR_CMAKE_USE_SYSTEM_BROTLI=true ++ $(InnerBuildArgs) --cmakeargs -DCLR_CMAKE_USE_SYSTEM_BROTLI=true + $(InnerBuildArgs) --cmakeargs -DCLR_CMAKE_USE_SYSTEM_LIBUNWIND=true + + diff --git a/packages/dotnet9.0/0008-aspire_fix-gitinfo-target.patch b/packages/dotnet9.0/0008-aspire_fix-gitinfo-target.patch new file mode 100644 index 00000000000000..c73ee1841cc09f --- /dev/null +++ b/packages/dotnet9.0/0008-aspire_fix-gitinfo-target.patch @@ -0,0 +1,12 @@ +--- a/src/aspire/Directory.Build.targets ++++ b/src/aspire/Directory.Build.targets +@@ -14,8 +14,7 @@ + + + +- +- ++ + + + diff --git a/packages/dotnet9.0/0009-src-runtime-src-coreclr-vm-threadstatics.cpp.patch b/packages/dotnet9.0/0009-src-runtime-src-coreclr-vm-threadstatics.cpp.patch new file mode 100644 index 00000000000000..c7b71970551b73 --- /dev/null +++ b/packages/dotnet9.0/0009-src-runtime-src-coreclr-vm-threadstatics.cpp.patch @@ -0,0 +1,13 @@ +--- a/src/runtime/src/coreclr/vm/threadstatics.cpp ++++ b/src/runtime/src/coreclr/vm/threadstatics.cpp +@@ -913,6 +913,10 @@ bool CanJITOptimizeTLSAccess() + // Optimization is disabled for linux/x86 + #elif defined(TARGET_LINUX_MUSL) && defined(TARGET_ARM64) + // Optimization is disabled for linux musl arm64 ++#elif defined(TARGET_LINUX_BIONIC) && defined(TARGET_ARM64) ++ // Optimization is disabled for linux bionic arm64 ++#elif defined(TARGET_ANDROID) && defined(TARGET_ARM64) ++ // Optimization is disabled for Android arm64 + #elif defined(TARGET_FREEBSD) && defined(TARGET_ARM64) + // Optimization is disabled for FreeBSD/arm64 + #elif defined(FEATURE_INTERPRETER) diff --git a/packages/dotnet9.0/0010-revert-stop-setting-separate-properties-BUNDLE_PROP-HOSTPOLICY_EMBEDDED-PINVOKE_OVERRIDE.patch b/packages/dotnet9.0/0010-revert-stop-setting-separate-properties-BUNDLE_PROP-HOSTPOLICY_EMBEDDED-PINVOKE_OVERRIDE.patch new file mode 100644 index 00000000000000..12602344e3e60b --- /dev/null +++ b/packages/dotnet9.0/0010-revert-stop-setting-separate-properties-BUNDLE_PROP-HOSTPOLICY_EMBEDDED-PINVOKE_OVERRIDE.patch @@ -0,0 +1,234 @@ +Revert https://github.com/dotnet/runtime/commit/da5bd2bc91c78a457c4bf28c09759f368e0f3238 + +--- a/src/runtime/docs/design/features/host-runtime-information.md ++++ b/src/runtime/docs/design/features/host-runtime-information.md +@@ -84,16 +84,10 @@ List of directory paths corresponding to shared store paths and additional probi + + Hex string representation of a function pointer. It is set when running a single-file application. The function is called by the runtime to look for assemblies bundled into the application. The expected signature is defined as `BundleProbeFn` in [`coreclrhost.h`](/src/coreclr/hosts/inc/coreclrhost.h) + +-**.NET 9 and above** This property is no longer set by the host. `host_runtime_contract.bundle_probe` is set when running a single-file application. +- + `HOSTPOLICY_EMBEDDED` + + Indicates whether or not [`hostpolicy`](./host-components.md#host-policy) is embedded in the host executable. It is set to `true` when running a self-contained single-file application. + +-**.NET 9 and above** This property is no longer set by the host or read by the runtime. Self-contained single-file includes both host and runtime components in the executable, so the information is known at build-time. +- + `PINVOKE_OVERRIDE` + + Hex string representation of a function pointer. It is set when running a self-contained single-file application. The function is called by the runtime to check for redirected p/invokes. The expected signature is defined as `PInvokeOverrideFn` in [`coreclrhost.h`](/src/coreclr/hosts/inc/coreclrhost.h) and [`mono-private-unstable-types.h`](/src/native/public/mono/metadata/details/mono-private-unstable-types.h). +- +-**.NET 9 and above** This property is no longer set by the host. `host_runtime_contract.pinvoke_override` is set when running a self-contained single-file application. +--- a/src/runtime/src/coreclr/dlls/mscoree/exports.cpp ++++ b/src/runtime/src/coreclr/dlls/mscoree/exports.cpp +@@ -138,6 +138,7 @@ static void ConvertConfigPropertiesToUnicode( + LPCWSTR** propertyValuesWRef, + BundleProbeFn** bundleProbe, + PInvokeOverrideFn** pinvokeOverride, ++ bool* hostPolicyEmbedded, + host_runtime_contract** hostContract) + { + LPCWSTR* propertyKeysW = new (nothrow) LPCWSTR[propertyCount]; +@@ -169,6 +170,11 @@ static void ConvertConfigPropertiesToUnicode( + if (*pinvokeOverride == nullptr) + *pinvokeOverride = (PInvokeOverrideFn*)u16_strtoui64(propertyValuesW[propertyIndex], nullptr, 0); + } ++ else if (strcmp(propertyKeys[propertyIndex], HOST_PROPERTY_HOSTPOLICY_EMBEDDED) == 0) ++ { ++ // The HOSTPOLICY_EMBEDDED property indicates if the executable has hostpolicy statically linked in ++ *hostPolicyEmbedded = (u16_strcmp(propertyValuesW[propertyIndex], W("true")) == 0); ++ } + else if (strcmp(propertyKeys[propertyIndex], HOST_PROPERTY_RUNTIME_CONTRACT) == 0) + { + // Host contract is passed in as the value of HOST_RUNTIME_CONTRACT property (encoded as a string). +@@ -246,6 +252,7 @@ int coreclr_initialize( + LPCWSTR* propertyKeysW; + LPCWSTR* propertyValuesW; + BundleProbeFn* bundleProbe = nullptr; ++ bool hostPolicyEmbedded = false; + PInvokeOverrideFn* pinvokeOverride = nullptr; + host_runtime_contract* hostContract = nullptr; + +@@ -261,6 +268,7 @@ int coreclr_initialize( + &propertyValuesW, + &bundleProbe, + &pinvokeOverride, ++ &hostPolicyEmbedded, + &hostContract); + + #ifdef TARGET_UNIX +@@ -275,6 +283,8 @@ int coreclr_initialize( + } + #endif + ++ g_hostpolicy_embedded = hostPolicyEmbedded; ++ + if (hostContract != nullptr) + { + HostInformation::SetContract(hostContract); +--- a/src/runtime/src/coreclr/vm/ceemain.cpp ++++ b/src/runtime/src/coreclr/vm/ceemain.cpp +@@ -229,12 +229,13 @@ extern "C" HRESULT __cdecl CorDBGetInterface(DebugInterface** rcInterface); + + // g_coreclr_embedded indicates that coreclr is linked directly into the program + // g_hostpolicy_embedded indicates that the hostpolicy library is linked directly into the executable ++// Note: that it can happen that the hostpolicy is embedded but coreclr isn't (on Windows singlefilehost is built that way) + #ifdef CORECLR_EMBEDDED + bool g_coreclr_embedded = true; + bool g_hostpolicy_embedded = true; // We always embed hostpolicy if coreclr is also embedded + #else + bool g_coreclr_embedded = false; +-bool g_hostpolicy_embedded = false; ++bool g_hostpolicy_embedded = false; // In this case the value may come from a runtime property and may change + #endif + + // Remember how the last startup of EE went. +--- a/src/runtime/src/mono/mono/mini/monovm.c ++++ b/src/runtime/src/mono/mono/mini/monovm.c +@@ -15,8 +15,6 @@ + + #include + +-#include +- + static MonoCoreTrustedPlatformAssemblies *trusted_platform_assemblies; + static MonoCoreLookupPaths *native_lib_paths; + static MonoCoreLookupPaths *app_paths; +@@ -189,28 +187,19 @@ parse_properties (int propertyCount, const char **propertyKeys, const char **pro + // A partial list of relevant properties is at: + // https://learn.microsoft.com/dotnet/core/tutorials/netcore-hosting#step-3---prepare-runtime-properties + +- PInvokeOverrideFn override_fn = NULL; + for (int i = 0; i < propertyCount; ++i) { + size_t prop_len = strlen (propertyKeys [i]); +- if (prop_len == 27 && !strncmp (propertyKeys [i], HOST_PROPERTY_TRUSTED_PLATFORM_ASSEMBLIES, 27)) { ++ if (prop_len == 27 && !strncmp (propertyKeys [i], "TRUSTED_PLATFORM_ASSEMBLIES", 27)) { + parse_trusted_platform_assemblies (propertyValues[i]); +- } else if (prop_len == 9 && !strncmp (propertyKeys [i], HOST_PROPERTY_APP_PATHS, 9)) { ++ } else if (prop_len == 9 && !strncmp (propertyKeys [i], "APP_PATHS", 9)) { + app_paths = parse_lookup_paths (propertyValues [i]); +- } else if (prop_len == 23 && !strncmp (propertyKeys [i], HOST_PROPERTY_PLATFORM_RESOURCE_ROOTS, 23)) { ++ } else if (prop_len == 23 && !strncmp (propertyKeys [i], "PLATFORM_RESOURCE_ROOTS", 23)) { + platform_resource_roots = parse_lookup_paths (propertyValues [i]); +- } else if (prop_len == 29 && !strncmp (propertyKeys [i], HOST_PROPERTY_NATIVE_DLL_SEARCH_DIRECTORIES, 29)) { ++ } else if (prop_len == 29 && !strncmp (propertyKeys [i], "NATIVE_DLL_SEARCH_DIRECTORIES", 29)) { + native_lib_paths = parse_lookup_paths (propertyValues [i]); +- } else if (prop_len == 16 && !strncmp (propertyKeys [i], HOST_PROPERTY_PINVOKE_OVERRIDE, 16)) { +- if (override_fn == NULL) { +- override_fn = (PInvokeOverrideFn)(uintptr_t)strtoull (propertyValues [i], NULL, 0); +- } +- } else if (prop_len == STRING_LENGTH(HOST_PROPERTY_RUNTIME_CONTRACT) && !strncmp (propertyKeys [i], HOST_PROPERTY_RUNTIME_CONTRACT, STRING_LENGTH(HOST_PROPERTY_RUNTIME_CONTRACT))) { +- // Functions in HOST_RUNTIME_CONTRACT have priority over the individual properties +- // for callbacks, so we set them as long as the contract has a non-null function. +- struct host_runtime_contract* contract = (struct host_runtime_contract*)(uintptr_t)strtoull (propertyValues [i], NULL, 0); +- if (contract->pinvoke_override != NULL) { +- override_fn = (PInvokeOverrideFn)contract->pinvoke_override; +- } ++ } else if (prop_len == 16 && !strncmp (propertyKeys [i], "PINVOKE_OVERRIDE", 16)) { ++ PInvokeOverrideFn override_fn = (PInvokeOverrideFn)(uintptr_t)strtoull (propertyValues [i], NULL, 0); ++ mono_loader_install_pinvoke_override (override_fn); + } else { + #if 0 + // can't use mono logger, it's not initialized yet. +@@ -218,10 +207,6 @@ parse_properties (int propertyCount, const char **propertyKeys, const char **pro + #endif + } + } +- +- if (override_fn != NULL) +- mono_loader_install_pinvoke_override (override_fn); +- + return TRUE; + } + +--- a/src/runtime/src/native/corehost/apphost/static/CMakeLists.txt ++++ b/src/runtime/src/native/corehost/apphost/static/CMakeLists.txt +@@ -46,6 +46,7 @@ set(HEADERS + ../../fxr_resolver.h + ) + ++add_compile_definitions(HOSTPOLICY_EMBEDDED) + add_compile_definitions(NATIVE_LIBS_EMBEDDED) + + include(../../fxr/files.cmake) +--- a/src/runtime/src/native/corehost/host_runtime_contract.h ++++ b/src/runtime/src/native/corehost/host_runtime_contract.h +@@ -18,6 +18,7 @@ + #define HOST_PROPERTY_APP_PATHS "APP_PATHS" + #define HOST_PROPERTY_BUNDLE_PROBE "BUNDLE_PROBE" + #define HOST_PROPERTY_ENTRY_ASSEMBLY_NAME "ENTRY_ASSEMBLY_NAME" ++#define HOST_PROPERTY_HOSTPOLICY_EMBEDDED "HOSTPOLICY_EMBEDDED" + #define HOST_PROPERTY_NATIVE_DLL_SEARCH_DIRECTORIES "NATIVE_DLL_SEARCH_DIRECTORIES" + #define HOST_PROPERTY_PINVOKE_OVERRIDE "PINVOKE_OVERRIDE" + #define HOST_PROPERTY_PLATFORM_RESOURCE_ROOTS "PLATFORM_RESOURCE_ROOTS" +--- a/src/runtime/src/native/corehost/hostpolicy/coreclr.cpp ++++ b/src/runtime/src/native/corehost/hostpolicy/coreclr.cpp +@@ -165,6 +165,9 @@ namespace + _X("STARTUP_HOOKS"), + _X("APP_PATHS"), + _X("RUNTIME_IDENTIFIER"), ++ _X("BUNDLE_PROBE"), ++ _X("HOSTPOLICY_EMBEDDED"), ++ _X("PINVOKE_OVERRIDE") + }; + + static_assert((sizeof(PropertyNameMapping) / sizeof(*PropertyNameMapping)) == static_cast(common_property::Last), "Invalid property count"); +--- a/src/runtime/src/native/corehost/hostpolicy/coreclr.h ++++ b/src/runtime/src/native/corehost/hostpolicy/coreclr.h +@@ -64,6 +64,9 @@ enum class common_property + StartUpHooks, + AppPaths, + RuntimeIdentifier, ++ BundleProbe, ++ HostPolicyEmbedded, ++ PInvokeOverride, + // Sentinel value - new values should be defined above + Last + }; +--- a/src/runtime/src/native/corehost/hostpolicy/hostpolicy_context.cpp ++++ b/src/runtime/src/native/corehost/hostpolicy/hostpolicy_context.cpp +@@ -329,6 +329,44 @@ int hostpolicy_context_t::initialize(const hostpolicy_init_t &hostpolicy_init, c + coreclr_properties.add(common_property::StartUpHooks, startup_hooks.c_str()); + } + ++ // Single-File Bundle Probe ++ if (bundle::info_t::is_single_file_bundle()) ++ { ++ // Encode the bundle_probe function pointer as a string, and pass it to the runtime. ++ pal::stringstream_t ptr_stream; ++ ptr_stream << "0x" << std::hex << (size_t)(&bundle_probe); ++ ++ if (!coreclr_properties.add(common_property::BundleProbe, ptr_stream.str().c_str())) ++ { ++ log_duplicate_property_error(coreclr_property_bag_t::common_property_to_string(common_property::BundleProbe)); ++ return StatusCode::LibHostDuplicateProperty; ++ } ++ } ++ ++#if defined(NATIVE_LIBS_EMBEDDED) ++ // PInvoke Override ++ if (bundle::info_t::is_single_file_bundle()) ++ { ++ // Encode the pinvoke_override function pointer as a string, and pass it to the runtime. ++ pal::stringstream_t ptr_stream; ++ ptr_stream << "0x" << std::hex << (size_t)(&pinvoke_override); ++ ++ if (!coreclr_properties.add(common_property::PInvokeOverride, ptr_stream.str().c_str())) ++ { ++ log_duplicate_property_error(coreclr_property_bag_t::common_property_to_string(common_property::PInvokeOverride)); ++ return StatusCode::LibHostDuplicateProperty; ++ } ++ } ++#endif ++ ++#if defined(HOSTPOLICY_EMBEDDED) ++ if (!coreclr_properties.add(common_property::HostPolicyEmbedded, _X("true"))) ++ { ++ log_duplicate_property_error(coreclr_property_bag_t::common_property_to_string(common_property::HostPolicyEmbedded)); ++ return StatusCode::LibHostDuplicateProperty; ++ } ++#endif ++ + { + host_contract = { sizeof(host_runtime_contract), this }; + if (bundle::info_t::is_single_file_bundle()) diff --git a/packages/dotnet9.0/aspnetcore-runtime-9.0.subpackage.sh b/packages/dotnet9.0/aspnetcore-runtime-9.0.subpackage.sh new file mode 100644 index 00000000000000..3b412c949a3741 --- /dev/null +++ b/packages/dotnet9.0/aspnetcore-runtime-9.0.subpackage.sh @@ -0,0 +1,4 @@ +TERMUX_SUBPKG_DESCRIPTION="ASP.NET Core 9.0 Runtime" +TERMUX_SUBPKG_DEPEND_ON_PARENT=false +TERMUX_SUBPKG_DEPENDS="dotnet-runtime-9.0" +TERMUX_SUBPKG_INCLUDE=$(cat "${TERMUX_PKG_TMPDIR}"/aspnetcore-runtime.txt) diff --git a/packages/dotnet9.0/aspnetcore-runtime-dbg-9.0.subpackage.sh b/packages/dotnet9.0/aspnetcore-runtime-dbg-9.0.subpackage.sh new file mode 100644 index 00000000000000..f2dbf0fd7a5db3 --- /dev/null +++ b/packages/dotnet9.0/aspnetcore-runtime-dbg-9.0.subpackage.sh @@ -0,0 +1,4 @@ +TERMUX_SUBPKG_DESCRIPTION="ASP.NET Core 9.0 Runtime Managed Debug Symbols" +TERMUX_SUBPKG_DEPEND_ON_PARENT=false +TERMUX_SUBPKG_DEPENDS="aspnetcore-runtime-9.0" +TERMUX_SUBPKG_INCLUDE=$(cat "${TERMUX_PKG_TMPDIR}"/aspnetcore-runtime-dbg.txt) diff --git a/packages/dotnet9.0/aspnetcore-targeting-pack-9.0.subpackage.sh b/packages/dotnet9.0/aspnetcore-targeting-pack-9.0.subpackage.sh new file mode 100644 index 00000000000000..e9edcd84a0f567 --- /dev/null +++ b/packages/dotnet9.0/aspnetcore-targeting-pack-9.0.subpackage.sh @@ -0,0 +1,4 @@ +TERMUX_SUBPKG_DESCRIPTION="ASP.NET Core 9.0 Targeting Pack" +TERMUX_SUBPKG_DEPEND_ON_PARENT=false +TERMUX_SUBPKG_DEPENDS="dotnet-host" +TERMUX_SUBPKG_INCLUDE=$(cat "${TERMUX_PKG_TMPDIR}"/aspnetcore-targeting-pack.txt) diff --git a/packages/dotnet9.0/build.sh b/packages/dotnet9.0/build.sh new file mode 100644 index 00000000000000..e29449cdf4fe45 --- /dev/null +++ b/packages/dotnet9.0/build.sh @@ -0,0 +1,343 @@ +TERMUX_PKG_HOMEPAGE=https://dotnet.microsoft.com/en-us/ +TERMUX_PKG_DESCRIPTION=".NET 9.0" +TERMUX_PKG_LICENSE="MIT" +TERMUX_PKG_MAINTAINER="@truboxl" +TERMUX_PKG_VERSION="9.0.1" +TERMUX_PKG_SRCURL=git+https://github.com/dotnet/dotnet +TERMUX_PKG_GIT_BRANCH="v${TERMUX_PKG_VERSION}" +TERMUX_PKG_BUILD_DEPENDS="krb5, libicu, openssl, zlib" +TERMUX_PKG_SUGGESTS="dotnet-sdk-9.0" +TERMUX_PKG_CONFLICTS="dotnet8.0" +TERMUX_PKG_BUILD_IN_SRC=true +TERMUX_PKG_NO_STATICSPLIT=true +TERMUX_PKG_FORCE_WAIT_FINISH=true +# https://github.com/dotnet/runtime/issues/7335 +# linux-x86 is not officially supported but works +# TODO linux-bionic-arm is broken +TERMUX_PKG_BLACKLISTED_ARCHES="arm" + +termux_step_post_get_source() { + # set up dotnet cli and override source files + ./prep-source-build.sh + + # removed by BinaryTool + git restore src/runtime/src/installer/tests/Assets/Projects/AppWithUnknownLanguageResource/test.res +} + +termux_step_pre_configure() { + # this is a workaround for build-all.sh + TERMUX_PKG_DEPENDS="aspnetcore-runtime-9.0, dotnet-host, dotnet-runtime-9.0" + + termux_setup_cmake + termux_setup_ninja + + # aspnetcore needs nodejs <= 19, but nodejs 19.x is EOL + local NODEJS_VERSION=18.20.5 + local NODEJS_SHA256=e4a3a21e5ac7e074ed50d2533dd0087d8460647ab567464867141a2b643f3fb3 + local NODEJS_FOLDER="${TERMUX_PKG_CACHEDIR}/nodejs-${NODEJS_VERSION}" + local NODEJS_TAR_XZ="${TERMUX_PKG_CACHEDIR}/node.tar.xz" + termux_download \ + https://nodejs.org/dist/v${NODEJS_VERSION}/node-v${NODEJS_VERSION}-linux-x64.tar.xz \ + "${NODEJS_TAR_XZ}" \ + "${NODEJS_SHA256}" + mkdir -p "${NODEJS_FOLDER}" + tar -xf "${NODEJS_TAR_XZ}" -C "${NODEJS_FOLDER}" --strip-components=1 + export PATH="${NODEJS_FOLDER}/bin:${PATH}" + if [[ "$(node --version)" != "v${NODEJS_VERSION}" ]]; then + termux_error_exit "$(command -v node) $(node --version) != ${NODEJS_VERSION}" + fi +} + +termux_step_configure() { + export arch + case "${TERMUX_ARCH}" in + aarch64) arch=arm64 ;; + arm) arch=arm ;; + i686) arch=x86 ;; + x86_64) arch=x64 ;; + *) termux_error_exit "Unknown arch: ${TERMUX_ARCH}" + esac + + export CONFIG="Release" + if [[ "${TERMUX_DEBUG_BUILD}" == "true" ]]; then + CONFIG="Debug" + fi + + export ANDROID_NDK_ROOT="${TERMUX_PKG_TMPDIR}" + + # unified sysroot needed when CMAKE_SYSROOT / --sysroot cannot be used + export ROOTFS_DIR="${TERMUX_PKG_TMPDIR}/sysroot" + if [[ -e "${TERMUX_STANDALONE_TOOLCHAIN}/sysroot.tmp" ]]; then + rm -f "${TERMUX_STANDALONE_TOOLCHAIN}/sysroot" + mv -v "${TERMUX_STANDALONE_TOOLCHAIN}"/sysroot{.tmp,} + fi + rm -fr "${ROOTFS_DIR}" + echo "INFO: Copying ${TERMUX_STANDALONE_TOOLCHAIN}/sysroot to ${ROOTFS_DIR}" + cp -fr "${TERMUX_STANDALONE_TOOLCHAIN}/sysroot" "${ROOTFS_DIR}" + echo "INFO: Copying ${TERMUX_PREFIX} to ${ROOTFS_DIR}" + cp -fr "${TERMUX_PREFIX}" "${ROOTFS_DIR}" + mv -v "${TERMUX_STANDALONE_TOOLCHAIN}"/sysroot{,.tmp} + ln -sv "${ROOTFS_DIR}" "${TERMUX_STANDALONE_TOOLCHAIN}/sysroot" + + #echo "RID=android.${TERMUX_PKG_API_LEVEL}-${arch}" > "${ROOTFS_DIR}/android_platform" + + # manual termux_step_configure_cmake + CMAKE_PROC="${TERMUX_ARCH}" + if [[ "${CMAKE_PROC}" == "arm" ]]; then + CMAKE_PROC="armv7-a" + fi + export CFLAGS+=" --target=${CCTERMUX_HOST_PLATFORM}" + # https://github.com/dotnet/android/pull/4958 + # apphost remove dependency on libc++_shared.so + # by linking statically + export CXXFLAGS+=" --target=${CCTERMUX_HOST_PLATFORM} -stdlib=libc++ -static-libstdc++" + + # easier to embed in toolchain file than CMakeArgs + mkdir -p "${TERMUX_PKG_TMPDIR}/build/cmake" + cat <<- EOL > "${TERMUX_PKG_TMPDIR}/build/cmake/android.toolchain.cmake" + set(CMAKE_C_FLAGS "\${CMAKE_C_FLAGS} ${CFLAGS}") + set(CMAKE_CXX_FLAGS "\${CMAKE_CXX_FLAGS} ${CXXFLAGS}") + set(CMAKE_SYSROOT "${ROOTFS_DIR}") + set(CMAKE_C_COMPILER "${TERMUX_STANDALONE_TOOLCHAIN}/bin/${CC}") + set(CMAKE_CXX_COMPILER "${TERMUX_STANDALONE_TOOLCHAIN}/bin/${CXX}") + set(CMAKE_AR "$(command -v ${AR})") + set(CMAKE_UNAME "$(command -v uname)") + set(CMAKE_RANLIB "$(command -v ${RANLIB})") + set(CMAKE_STRIP "$(command -v ${STRIP})") + set(CMAKE_FIND_ROOT_PATH "${TERMUX_PREFIX}") + set(CMAKE_FIND_ROOT_PATH_MODE_PROGRAM "NEVER") + set(CMAKE_FIND_ROOT_PATH_MODE_INCLUDE "ONLY") + set(CMAKE_FIND_ROOT_PATH_MODE_LIBRARY "ONLY") + #set(CMAKE_INSTALL_PREFIX "${TERMUX_PREFIX}") + #set(CMAKE_INSTALL_LIBDIR "${TERMUX_PREFIX}/lib") + set(CMAKE_SKIP_INSTALL_RPATH "ON") + set(CMAKE_USE_SYSTEM_LIBRARIES "True") + set(CMAKE_CROSSCOMPILING "True") + set(DOXYGEN_EXECUTABLE "") + set(BUILD_TESTING "OFF") + set(CMAKE_LINKER "${TERMUX_STANDALONE_TOOLCHAIN}/bin/${LD}") + set(CMAKE_SYSTEM_NAME "Android") + set(CMAKE_SYSTEM_VERSION "${TERMUX_PKG_API_LEVEL}") + set(CMAKE_SYSTEM_PROCESSOR "${CMAKE_PROC}") + set(CMAKE_ANDROID_STANDALONE_TOOLCHAIN "${TERMUX_STANDALONE_TOOLCHAIN}") + + # https://github.com/dotnet/runtime/blob/445dac9e8e541b2364deea000dde8487ea1ec20e/src/coreclr/pal/src/configure.cmake#L776-L793 + # for unknown reason, this is needed here + set(HAVE_COMPATIBLE_EXP_EXITCODE 0) + + # https://github.com/dotnet/runtime/issues/57784 + # Android has no liblttng-ust, Linux also has different issue + set(FEATURE_EVENT_TRACE 0) + EOL + + echo "INFO: ${TERMUX_PKG_TMPDIR}/build/cmake/android.toolchain.cmake" + cat "${TERMUX_PKG_TMPDIR}/build/cmake/android.toolchain.cmake" + echo + + export EXTRA_CFLAGS="${CFLAGS}" + export EXTRA_CXXFLAGS="${CXXFLAGS}" + export EXTRA_LDFLAGS="${LDFLAGS}" + + unset CC CFLAGS CXX CXXFLAGS LD LDFLAGS PKGCONFIG PKG_CONFIG PKG_CONFIG_DIR PKG_CONFIG_LIBDIR +} + +termux_step_make() { + export CROSSCOMPILE=1 + # --online needed to workaround restore issue + time ./build.sh \ + --clean-while-building \ + --use-mono-runtime \ + --online \ + --source-build \ + -- \ + /p:Configuration=${CONFIG} \ + /p:TargetArchitecture=${arch} \ + /p:TargetRid=linux-bionic-${arch} + + "${TERMUX_PKG_BUILDDIR}/.dotnet/dotnet" build-server shutdown +} + +termux_step_make_install() { + local _DOTNET_ROOT="${TERMUX_PREFIX}/lib/dotnet" + rm -fr "${_DOTNET_ROOT}" + mkdir -p "${_DOTNET_ROOT}" + + # DEBUG copy the artifacts + #mkdir -p "${TERMUX_PREFIX}/opt/${TERMUX_PKG_NAME}" + #find "${TERMUX_PKG_BUILDDIR}/artifacts/assets" -type f \( -name "*.tar.gz" -o -name "*.zip" \) -exec cp -fv "{}" "${TERMUX_PREFIX}/opt/${TERMUX_PKG_NAME}" \; + + # extract tarball + tar -xf "${TERMUX_PKG_BUILDDIR}/artifacts/assets/${CONFIG}"/dotnet-sdk-*.tar.gz -C "${_DOTNET_ROOT}" + tar -xf "${TERMUX_PKG_BUILDDIR}/artifacts/assets/${CONFIG}"/dotnet-symbols-sdk-*.tar.gz -C "${_DOTNET_ROOT}" + + # check need to fix default build target + echo "INFO: Patching Microsoft.NETCoreSdk.BundledVersions.props" + grep "" -nH "${_DOTNET_ROOT}"/sdk/*/Microsoft.NETCoreSdk.BundledVersions.props + grep "" -nH "${_DOTNET_ROOT}"/sdk/*/Microsoft.NETCoreSdk.BundledVersions.props + sed \ + -e "s|.*|linux-bionic-${arch}|" \ + -e "s|.*|linux-bionic-${arch}|" \ + -i "${_DOTNET_ROOT}"/sdk/*/Microsoft.NETCoreSdk.BundledVersions.props + grep "" -nH "${_DOTNET_ROOT}"/sdk/*/Microsoft.NETCoreSdk.BundledVersions.props + grep "" -nH "${_DOTNET_ROOT}"/sdk/*/Microsoft.NETCoreSdk.BundledVersions.props + + # TODO investigate if can replace with runpath or static link + # this is needed to link libssl.so.3, etc + cat <<-EOL > "${TERMUX_PREFIX}/bin/dotnet" + #!${TERMUX_PREFIX}/bin/sh + LD_LIBRARY_PATH="\${LD_LIBRARY_PATH}:${TERMUX_PREFIX}/lib" exec ${_DOTNET_ROOT}/dotnet "\$@" + EOL + chmod 0755 "${TERMUX_PREFIX}/bin/dotnet" + + # https://src.fedoraproject.org/rpms/dotnet9.0/raw/rawhide/f/dotnet.sh.in + mkdir -p "${TERMUX_PREFIX}/etc/profile.d" + sed \ + -e "s|@LIBDIR@|${TERMUX_PREFIX}/lib|g" \ + "${TERMUX_PKG_BUILDER_DIR}/dotnet.sh.in" \ + > "${TERMUX_PREFIX}/etc/profile.d/dotnet.sh" + + # shell completion + install -Dm644 "${TERMUX_PKG_SRCDIR}/src/sdk/scripts/register-completions.bash" "${TERMUX_PREFIX}/share/bash-completion/completions/dotnet" + install -Dm644 "${TERMUX_PKG_SRCDIR}/src/sdk/scripts/register-completions.zsh" "${TERMUX_PREFIX}/share/zsh/site-functions/_dotnet" + + # manpages + install -Dm644 -t "${TERMUX_PREFIX}"/share/man/man1 \ + "${TERMUX_PKG_SRCDIR}"/src/sdk/documentation/manpages/sdk/*.1 + + # fix executable permissions on files + find "${_DOTNET_ROOT}" -type f -name 'apphost' -exec chmod 0755 {} \; + find "${_DOTNET_ROOT}" -type f -name 'singlefilehost' -exec chmod 0755 {} \; + find "${_DOTNET_ROOT}" -type f -name 'lib*so' -exec chmod 0644 {} \; + find "${_DOTNET_ROOT}" -type f -name '*.a' -exec chmod 0644 {} \; + find "${_DOTNET_ROOT}" -type f -name '*.dll' -exec chmod 0644 {} \; + find "${_DOTNET_ROOT}" -type f -name '*.h' -exec chmod 0644 {} \; + find "${_DOTNET_ROOT}" -type f -name '*.json' -exec chmod 0644 {} \; + find "${_DOTNET_ROOT}" -type f -name '*.pdb' -exec chmod 0644 {} \; + find "${_DOTNET_ROOT}" -type f -name '*.props' -exec chmod 0644 {} \; + find "${_DOTNET_ROOT}" -type f -name '*.pubxml' -exec chmod 0644 {} \; + find "${_DOTNET_ROOT}" -type f -name '*.targets' -exec chmod 0644 {} \; + find "${_DOTNET_ROOT}" -type f -name '*.txt' -exec chmod 0644 {} \; + find "${_DOTNET_ROOT}" -type f -name '*.xml' -exec chmod 0644 {} \; + + # check libc++ + local dotnet_readelf=$(${READELF} -d ${_DOTNET_ROOT}/dotnet) + local dotnet_needed=$(echo "${dotnet_readelf}" | sed -ne "s|.*NEEDED.*\[\(.*\)\].*|\1|p") + if [[ -n "$(echo "${dotnet_needed}" | grep "libc++_shared.so")" ]]; then + termux_error_exit " + libc++ found. Check readelf output below: + ${dotnet_readelf} + " + fi + + pushd "${TERMUX_PREFIX}" + # remove unused targeting packs pdb files + find \ + lib/dotnet/packs/Microsoft.AspNetCore.App.Ref \ + lib/dotnet/packs/Microsoft.NETCore.App.Ref \ + \( -type f -o -type l \) -name "*.pdb" | sort | xargs -rt rm -f + + # special handling subpackage files + find \ + lib/dotnet/shared/Microsoft.AspNetCore.App/9.0.* \ + \( -type f -o -type l \) ! -name "*.pdb" | sort \ + > "${TERMUX_PKG_TMPDIR}"/aspnetcore-runtime.txt + + find \ + lib/dotnet/shared/Microsoft.AspNetCore.App/9.0.* \ + \( -type f -o -type l \) -name "*.pdb" | sort \ + > "${TERMUX_PKG_TMPDIR}"/aspnetcore-runtime-dbg.txt + + find \ + lib/dotnet/packs/Microsoft.AspNetCore.App.Ref/9.0.* \ + \( -type f -o -type l \) | sort \ + > "${TERMUX_PKG_TMPDIR}"/aspnetcore-targeting-pack.txt + + find \ + lib/dotnet/packs/Microsoft.NETCore.App.Host.linux-bionic-${arch}/9.0.* \ + \( -type f -o -type l \) | sort \ + > "${TERMUX_PKG_TMPDIR}"/dotnet-apphost-pack.txt + + find \ + bin/dotnet \ + etc/profile.d/dotnet.sh \ + lib/dotnet/LICENSE.txt \ + lib/dotnet/ThirdPartyNotices.txt \ + lib/dotnet/dotnet \ + share/bash-completion/completions/dotnet \ + share/zsh/site-functions/_dotnet \ + \( -type f -o -type l \) | sort \ + > "${TERMUX_PKG_TMPDIR}"/dotnet-host.txt + echo "share/man/man1" >> "${TERMUX_PKG_TMPDIR}"/dotnet-host.txt + + find \ + lib/dotnet/host/fxr/9.0.* \ + \( -type f -o -type l \) | sort \ + > "${TERMUX_PKG_TMPDIR}"/dotnet-hostfxr.txt + + find \ + lib/dotnet/shared/Microsoft.NETCore.App/9.0.* \ + \( -type f -o -type l \) ! -name "*.pdb" | sort \ + > "${TERMUX_PKG_TMPDIR}"/dotnet-runtime.txt + + find \ + lib/dotnet/shared/Microsoft.NETCore.App/9.0.* \ + \( -type f -o -type l \) -name "*.pdb" | sort \ + > "${TERMUX_PKG_TMPDIR}"/dotnet-runtime-dbg.txt + + find \ + lib/dotnet/metadata/workloads/9.0.* \ + lib/dotnet/packs/Microsoft.AspNetCore.App.Runtime.linux-bionic-${arch}/9.0.* \ + lib/dotnet/packs/Microsoft.NETCore.App.Runtime.linux-bionic-${arch}/9.0.* \ + lib/dotnet/sdk/9.0.* \ + lib/dotnet/sdk-manifests \ + \( -type f -o -type l \) ! -name "*.pdb" | sort \ + > "${TERMUX_PKG_TMPDIR}"/dotnet-sdk.txt + + find \ + lib/dotnet/packs/Microsoft.AspNetCore.App.Runtime.linux-bionic-${arch}/9.0.* \ + lib/dotnet/packs/Microsoft.NETCore.App.Runtime.linux-bionic-${arch}/9.0.* \ + lib/dotnet/sdk/9.0.* \ + \( -type f -o -type l \) -name "*.pdb" | sort \ + > "${TERMUX_PKG_TMPDIR}"/dotnet-sdk-dbg.txt + + find \ + lib/dotnet/packs/Microsoft.NETCore.App.Ref/9.0.* \ + \( -type f -o -type l \) | sort \ + > "${TERMUX_PKG_TMPDIR}"/dotnet-targeting-pack.txt + + find \ + lib/dotnet/templates/9.0.* \ + \( -type f -o -type l \) | sort \ + > "${TERMUX_PKG_TMPDIR}"/dotnet-templates.txt + + find \ + lib/dotnet/packs/NETStandard.Library.Ref \ + \( -type f -o -type l \) | sort \ + > "${TERMUX_PKG_TMPDIR}"/netstandard-targeting-pack-2.1.txt + popd + + local txt + for txt in "${TERMUX_PKG_TMPDIR}"/*.txt; do + echo "INFO: $txt" + cat "$txt" + done +} + +termux_step_post_make_install() { + echo "INFO: Restoring sysroot" + rm -fr "${TERMUX_STANDALONE_TOOLCHAIN}/sysroot" + mv -v "${TERMUX_STANDALONE_TOOLCHAIN}"/sysroot{.tmp,} + + unset ANDROID_NDK_ROOT CONFIG CROSSCOMPILE ROOTFS_DIR + unset EXTRA_CFLAGS EXTRA_CXXFLAGS EXTRA_LDFLAGS + unset arch +} + +# References: +# https://dotnet.microsoft.com/en-us/platform/support/policy/dotnet-core +# https://learn.microsoft.com/en-us/dotnet/core/distribution-packaging +# https://git.alpinelinux.org/aports/tree/community/dotnet9-stage0/APKBUILD +# https://git.alpinelinux.org/aports/tree/community/dotnet9-runtime/APKBUILD +# https://git.alpinelinux.org/aports/tree/community/dotnet9-sdk/APKBUILD +# https://src.fedoraproject.org/rpms/dotnet9.0/blob/rawhide/f/dotnet9.0.spec +# https://git.launchpad.net/ubuntu/+source/dotnet9/tree/debian/rules diff --git a/packages/dotnet9.0/dotnet-apphost-pack-9.0.subpackage.sh b/packages/dotnet9.0/dotnet-apphost-pack-9.0.subpackage.sh new file mode 100644 index 00000000000000..8179177c479b62 --- /dev/null +++ b/packages/dotnet9.0/dotnet-apphost-pack-9.0.subpackage.sh @@ -0,0 +1,3 @@ +TERMUX_SUBPKG_DESCRIPTION=".NET 9.0 Targeting Pack" +TERMUX_SUBPKG_DEPEND_ON_PARENT=false +TERMUX_SUBPKG_INCLUDE=$(cat "${TERMUX_PKG_TMPDIR}"/dotnet-apphost-pack.txt) diff --git a/packages/dotnet9.0/dotnet-host-9.0.subpackage.sh b/packages/dotnet9.0/dotnet-host-9.0.subpackage.sh new file mode 100644 index 00000000000000..ca3c760e310f96 --- /dev/null +++ b/packages/dotnet9.0/dotnet-host-9.0.subpackage.sh @@ -0,0 +1,4 @@ +TERMUX_SUBPKG_DESCRIPTION=".NET 9.0 Host" +TERMUX_SUBPKG_DEPEND_ON_PARENT=false +TERMUX_SUBPKG_CONFLICTS="dotnet-host-8.0" +TERMUX_SUBPKG_INCLUDE=$(cat "${TERMUX_PKG_TMPDIR}"/dotnet-host.txt) diff --git a/packages/dotnet9.0/dotnet-hostfxr-9.0.subpackage.sh b/packages/dotnet9.0/dotnet-hostfxr-9.0.subpackage.sh new file mode 100644 index 00000000000000..691be0004a03c4 --- /dev/null +++ b/packages/dotnet9.0/dotnet-hostfxr-9.0.subpackage.sh @@ -0,0 +1,4 @@ +TERMUX_SUBPKG_DESCRIPTION=".NET 9.0 Host Resolver" +TERMUX_SUBPKG_DEPEND_ON_PARENT=false +TERMUX_SUBPKG_DEPENDS="dotnet-host" +TERMUX_SUBPKG_INCLUDE=$(cat "${TERMUX_PKG_TMPDIR}"/dotnet-hostfxr.txt) diff --git a/packages/dotnet9.0/dotnet-runtime-9.0.subpackage.sh b/packages/dotnet9.0/dotnet-runtime-9.0.subpackage.sh new file mode 100644 index 00000000000000..a4d1409a78dcaa --- /dev/null +++ b/packages/dotnet9.0/dotnet-runtime-9.0.subpackage.sh @@ -0,0 +1,4 @@ +TERMUX_SUBPKG_DESCRIPTION=".NET 9.0 Runtime" +TERMUX_SUBPKG_DEPEND_ON_PARENT=false +TERMUX_SUBPKG_DEPENDS="dotnet-hostfxr-9.0, libicu, openssl, zlib" +TERMUX_SUBPKG_INCLUDE=$(cat "${TERMUX_PKG_TMPDIR}"/dotnet-runtime.txt) diff --git a/packages/dotnet9.0/dotnet-runtime-dbg-9.0.subpackage.sh b/packages/dotnet9.0/dotnet-runtime-dbg-9.0.subpackage.sh new file mode 100644 index 00000000000000..5033c55c12adb6 --- /dev/null +++ b/packages/dotnet9.0/dotnet-runtime-dbg-9.0.subpackage.sh @@ -0,0 +1,4 @@ +TERMUX_SUBPKG_DESCRIPTION=".NET 9.0 Runtime Managed Debug Symbols" +TERMUX_SUBPKG_DEPEND_ON_PARENT=false +TERMUX_SUBPKG_DEPENDS="dotnet-runtime-9.0" +TERMUX_SUBPKG_INCLUDE=$(cat "${TERMUX_PKG_TMPDIR}"/dotnet-runtime-dbg.txt) diff --git a/packages/dotnet9.0/dotnet-sdk-9.0.subpackage.sh b/packages/dotnet9.0/dotnet-sdk-9.0.subpackage.sh new file mode 100644 index 00000000000000..d620a54f9b17b5 --- /dev/null +++ b/packages/dotnet9.0/dotnet-sdk-9.0.subpackage.sh @@ -0,0 +1,31 @@ +TERMUX_SUBPKG_DESCRIPTION=".NET 9.0 SDK" +TERMUX_SUBPKG_DEPEND_ON_PARENT=false +TERMUX_SUBPKG_DEPENDS="aspnetcore-runtime-9.0, aspnetcore-targeting-pack-9.0, dotnet-apphost-pack-9.0, dotnet-runtime-9.0, dotnet-targeting-pack-9.0, dotnet-templates-9.0, netstandard-targeting-pack-2.1" +TERMUX_SUBPKG_INCLUDE=$(cat "${TERMUX_PKG_TMPDIR}"/dotnet-sdk.txt) + +# TODO patch msbuild to run single thread by default or fix it +termux_step_create_subpkg_debscripts() { + cat <<- EOF > ./postinst + #!${TERMUX_PREFIX}/bin/sh + cat <<- EOL + + ==================== + NET SDK known issues + ==================== + + 'dotnet' may 'Build FAILED' with no error message when + building certain projects. You may want to try building + with single thread by passing: + + -p:BuildInParallel=false -p:maxcpucount=1 + + Pass '-v n' or '-v d' or '-v diag' to increase + log verbosity. + + Initial build only offers Mono runtime. + Check logcat for runtime errors. + CoreCLR is still WIP. + + EOL + EOF +} diff --git a/packages/dotnet9.0/dotnet-sdk-dbg-9.0.subpackage.sh b/packages/dotnet9.0/dotnet-sdk-dbg-9.0.subpackage.sh new file mode 100644 index 00000000000000..fc115ba98f85a8 --- /dev/null +++ b/packages/dotnet9.0/dotnet-sdk-dbg-9.0.subpackage.sh @@ -0,0 +1,4 @@ +TERMUX_SUBPKG_DESCRIPTION=".NET 9.0 SDK Managed Debug Symbols" +TERMUX_SUBPKG_DEPEND_ON_PARENT=false +TERMUX_SUBPKG_DEPENDS="dotnet-sdk-9.0" +TERMUX_SUBPKG_INCLUDE=$(cat "${TERMUX_PKG_TMPDIR}"/dotnet-sdk-dbg.txt) diff --git a/packages/dotnet9.0/dotnet-targeting-pack-9.0.subpackage.sh b/packages/dotnet9.0/dotnet-targeting-pack-9.0.subpackage.sh new file mode 100644 index 00000000000000..8c98e645c47873 --- /dev/null +++ b/packages/dotnet9.0/dotnet-targeting-pack-9.0.subpackage.sh @@ -0,0 +1,4 @@ +TERMUX_SUBPKG_DESCRIPTION=".NET 9.0 Targeting Pack" +TERMUX_SUBPKG_DEPEND_ON_PARENT=false +TERMUX_SUBPKG_DEPENDS="dotnet-host" +TERMUX_SUBPKG_INCLUDE=$(cat "${TERMUX_PKG_TMPDIR}"/dotnet-targeting-pack.txt) diff --git a/packages/dotnet9.0/dotnet-templates-9.0.subpackage.sh b/packages/dotnet9.0/dotnet-templates-9.0.subpackage.sh new file mode 100644 index 00000000000000..f876daa5c1ec3f --- /dev/null +++ b/packages/dotnet9.0/dotnet-templates-9.0.subpackage.sh @@ -0,0 +1,4 @@ +TERMUX_SUBPKG_DESCRIPTION=".NET 9.0 Templates" +TERMUX_SUBPKG_DEPEND_ON_PARENT=false +TERMUX_SUBPKG_DEPENDS="dotnet-host" +TERMUX_SUBPKG_INCLUDE=$(cat "${TERMUX_PKG_TMPDIR}"/dotnet-templates.txt) diff --git a/packages/dotnet9.0/dotnet.sh.in b/packages/dotnet9.0/dotnet.sh.in new file mode 100644 index 00000000000000..424b5ebf25d4e8 --- /dev/null +++ b/packages/dotnet9.0/dotnet.sh.in @@ -0,0 +1,13 @@ +# Set location for AppHost lookup +[ -z "$DOTNET_ROOT" ] && export DOTNET_ROOT=@LIBDIR@/dotnet + +# Add dotnet tools directory to PATH +DOTNET_TOOLS_PATH="$HOME/.dotnet/tools" +case "$PATH" in + *"$DOTNET_TOOLS_PATH"* ) true ;; + * ) PATH="$PATH:$DOTNET_TOOLS_PATH" ;; +esac + +# Extract self-contained executables under HOME +# to avoid multi-user issues from using the default '/var/tmp'. +[ -z "$DOTNET_BUNDLE_EXTRACT_BASE_DIR" ] && export DOTNET_BUNDLE_EXTRACT_BASE_DIR="${XDG_CACHE_HOME:-"$HOME"/.cache}/dotnet_bundle_extract" diff --git a/packages/dotnet9.0/netstandard-targeting-pack-2.1-9.0.subpackage.sh b/packages/dotnet9.0/netstandard-targeting-pack-2.1-9.0.subpackage.sh new file mode 100644 index 00000000000000..263f988ac93252 --- /dev/null +++ b/packages/dotnet9.0/netstandard-targeting-pack-2.1-9.0.subpackage.sh @@ -0,0 +1,5 @@ +TERMUX_SUBPKG_DESCRIPTION="NETStandard.Library 2.1 Targeting Pack (.NET 9.0)" +TERMUX_SUBPKG_DEPEND_ON_PARENT=false +TERMUX_SUBPKG_DEPENDS="dotnet-host" +TERMUX_SUBPKG_CONFLICTS="netstandard-targeting-pack-2.1-8.0" +TERMUX_SUBPKG_INCLUDE=$(cat "${TERMUX_PKG_TMPDIR}"/netstandard-targeting-pack-2.1.txt) diff --git a/packages/netstandard-targeting-pack-2.1/build.sh b/packages/netstandard-targeting-pack-2.1/build.sh index 839831fd97d6a8..768107bfee9d3b 100644 --- a/packages/netstandard-targeting-pack-2.1/build.sh +++ b/packages/netstandard-targeting-pack-2.1/build.sh @@ -2,10 +2,9 @@ TERMUX_PKG_HOMEPAGE=https://dotnet.microsoft.com/en-us/ TERMUX_PKG_DESCRIPTION="A metapackage for NETStandard.Library 2.1 Targeting Pack" TERMUX_PKG_LICENSE="Public Domain" TERMUX_PKG_MAINTAINER="@truboxl" -TERMUX_PKG_VERSION="8.0" -TERMUX_PKG_REVISION=1 -TERMUX_PKG_DEPENDS="netstandard-targeting-pack-2.1-8.0" -TERMUX_PKG_ANTI_BUILD_DEPENDS="netstandard-targeting-pack-2.1-8.0" +TERMUX_PKG_VERSION="9.0" +TERMUX_PKG_DEPENDS="netstandard-targeting-pack-2.1-9.0 | netstandard-targeting-pack-2.1-8.0" +TERMUX_PKG_ANTI_BUILD_DEPENDS="netstandard-targeting-pack-2.1-9.0, netstandard-targeting-pack-2.1-8.0" TERMUX_PKG_AUTO_UPDATE=false TERMUX_PKG_METAPACKAGE=true TERMUX_PKG_PLATFORM_INDEPENDENT=true diff --git a/scripts/big-pkgs.list b/scripts/big-pkgs.list index 0552d431dc6b99..074e9f4f08ccc8 100644 --- a/scripts/big-pkgs.list +++ b/scripts/big-pkgs.list @@ -3,6 +3,7 @@ bionic-host clvk dart dotnet8.0 +dotnet9.0 firefox grafana libllvm