diff --git a/packages/dotnet-host/build.sh b/packages/dotnet-host/build.sh index 9db4d805a58..b31598c441d 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="9.0" -TERMUX_PKG_REVISION=2 -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_VERSION="10.0" +TERMUX_PKG_DEPENDS="dotnet-host-10.0 | dotnet-host-9.0 | dotnet-host-8.0" +TERMUX_PKG_ANTI_BUILD_DEPENDS="dotnet-host-10.0, dotnet-host-9.0, dotnet-host-8.0" TERMUX_PKG_AUTO_UPDATE=false TERMUX_PKG_METAPACKAGE=true TERMUX_PKG_SKIP_SRC_EXTRACT=true diff --git a/packages/dotnet10.0/0001-build-all-libs.patch b/packages/dotnet10.0/0001-build-all-libs.patch new file mode 100644 index 00000000000..a89fccbad6e --- /dev/null +++ b/packages/dotnet10.0/0001-build-all-libs.patch @@ -0,0 +1,18 @@ +diff --git a/src/runtime/src/native/libs/CMakeLists.txt b/src/runtime/src/native/libs/CMakeLists.txt +index cf8b2b47f..2aee2d51d 100644 +--- a/src/runtime/src/native/libs/CMakeLists.txt ++++ b/src/runtime/src/native/libs/CMakeLists.txt +@@ -156,12 +156,9 @@ if (CLR_CMAKE_TARGET_UNIX OR CLR_CMAKE_TARGET_BROWSER OR CLR_CMAKE_TARGET_WASI) + endif () + + add_subdirectory(System.Security.Cryptography.Native.Apple) +- 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 () + endif () diff --git a/packages/dotnet10.0/0002-define-memfd_create.patch b/packages/dotnet10.0/0002-define-memfd_create.patch new file mode 100644 index 00000000000..c7fe4979131 --- /dev/null +++ b/packages/dotnet10.0/0002-define-memfd_create.patch @@ -0,0 +1,30 @@ +Always provide memfd_create syscall fallback on Linux/Android. + +The iltools/cdac host build in .NET 10 compiles doublemapping.cpp with +TARGET_LINUX defined but not TARGET_ANDROID. When the host glibc defines +MFD_CLOEXEC (glibc 2.27+), the original fallback branch doesn't fire, +and memfd_create may not be available as a function if the build uses +the Bionic sysroot. This ensures the syscall wrapper is always provided. + +diff --git a/src/runtime/src/coreclr/minipal/Unix/doublemapping.cpp b/src/runtime/src/coreclr/minipal/Unix/doublemapping.cpp +index 205a2cac7..973a696b3 100644 +--- a/src/runtime/src/coreclr/minipal/Unix/doublemapping.cpp ++++ b/src/runtime/src/coreclr/minipal/Unix/doublemapping.cpp +@@ -16,13 +16,12 @@ + #include + #include + #include +-#if defined(TARGET_LINUX) && !defined(MFD_CLOEXEC) ++#if defined(TARGET_LINUX) || defined(TARGET_ANDROID) ++#if !defined(MFD_CLOEXEC) + #include ++#endif + #include // __NR_memfd_create + #define memfd_create(...) syscall(__NR_memfd_create, __VA_ARGS__) +-#elif defined(TARGET_ANDROID) +-#include // __NR_memfd_create +-#define memfd_create(...) syscall(__NR_memfd_create, __VA_ARGS__) +-#endif // TARGET_LINUX && !MFD_CLOEXEC ++#endif // TARGET_LINUX || TARGET_ANDROID + #include "minipal.h" + #include "minipal/cpufeatures.h" diff --git a/packages/dotnet10.0/0003-runtime-src-native-libs-System.IO.Compression.Native.patch b/packages/dotnet10.0/0003-runtime-src-native-libs-System.IO.Compression.Native.patch new file mode 100644 index 00000000000..ee011a47191 --- /dev/null +++ b/packages/dotnet10.0/0003-runtime-src-native-libs-System.IO.Compression.Native.patch @@ -0,0 +1,35 @@ +diff --git a/src/runtime/src/native/libs/System.IO.Compression.Native/CMakeLists.txt b/src/runtime/src/native/libs/System.IO.Compression.Native/CMakeLists.txt +index 0adecdad8..7e6a29704 100644 +--- a/src/runtime/src/native/libs/System.IO.Compression.Native/CMakeLists.txt ++++ b/src/runtime/src/native/libs/System.IO.Compression.Native/CMakeLists.txt +@@ -73,7 +73,7 @@ if (CLR_CMAKE_TARGET_UNIX OR CLR_CMAKE_TARGET_BROWSER OR CLR_CMAKE_TARGET_WASI) + target_include_directories(System.IO.Compression.Native PRIVATE ${BROTLI_INCLUDE_DIRS}) + target_link_libraries(System.IO.Compression.Native PRIVATE ${BROTLI_LIBRARIES}) + +- 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}) +@@ -153,7 +153,7 @@ else () + target_link_libraries(System.IO.Compression.Native PUBLIC ${BROTLI_LIBRARIES}) + 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 () + +diff --git 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 +index 03b40533e..6c9d6c1be 100644 +--- 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/dotnet10.0/0004-disable-lttng-fatal-error.patch b/packages/dotnet10.0/0004-disable-lttng-fatal-error.patch new file mode 100644 index 00000000000..a80b0eb0277 --- /dev/null +++ b/packages/dotnet10.0/0004-disable-lttng-fatal-error.patch @@ -0,0 +1,24 @@ +Make lttng-ust optional instead of required. + +The iltools/cdac host build in .NET 10 goes through coreclr PAL +which checks for lttng-ust-dev. This is not available in the Termux +build container nor on Android. Convert the FATAL_ERROR to a WARNING +so the build can proceed without tracing support. + +diff --git a/src/runtime/src/coreclr/pal/src/configure.cmake b/src/runtime/src/coreclr/pal/src/configure.cmake +index 3d89ba2f5..dbce1ce32 100644 +--- a/src/runtime/src/coreclr/pal/src/configure.cmake ++++ b/src/runtime/src/coreclr/pal/src/configure.cmake +@@ -926,9 +926,10 @@ elseif(CLR_CMAKE_TARGET_BROWSER) + else() # Anything else is Linux + # LTTNG is not available on Android, so don't error out + if(FEATURE_EVENTSOURCE_XPLAT AND NOT HAVE_LTTNG_TRACEPOINT_H) +- unset(HAVE_LTTNG_TRACEPOINT_H CACHE) +- message(FATAL_ERROR "Cannot find liblttng-ust-dev. Try installing liblttng-ust-dev (or the appropriate packages for your platform)") ++ message(WARNING "Cannot find liblttng-ust-dev, disabling FEATURE_EVENTSOURCE_XPLAT") ++ set(FEATURE_EVENTSOURCE_XPLAT 0) + endif() ++ + set(DEADLOCK_WHEN_THREAD_IS_SUSPENDED_WHILE_BLOCKED_ON_MUTEX 0) + set(PAL_PTRACE "ptrace((cmd), (pid), (void*)(addr), (data))") + set(HAVE_SCHED_OTHER_ASSIGNABLE 1) diff --git a/packages/dotnet10.0/0005-runtime-src-native-libs-System.Security.Cryptography.Native-opensslshim.c.patch b/packages/dotnet10.0/0005-runtime-src-native-libs-System.Security.Cryptography.Native-opensslshim.c.patch new file mode 100644 index 00000000000..2e2fcb3f1aa --- /dev/null +++ b/packages/dotnet10.0/0005-runtime-src-native-libs-System.Security.Cryptography.Native-opensslshim.c.patch @@ -0,0 +1,19 @@ +diff --git a/src/runtime/src/native/libs/System.Security.Cryptography.Native/opensslshim.c b/src/runtime/src/native/libs/System.Security.Cryptography.Native/opensslshim.c +index d99f9fd91..0caae26d3 100644 +--- a/src/runtime/src/native/libs/System.Security.Cryptography.Native/opensslshim.c ++++ b/src/runtime/src/native/libs/System.Security.Cryptography.Native/opensslshim.c +@@ -89,14 +89,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/dotnet10.0/0006-runtime-eng-common-cross-toolchain.cmake.patch b/packages/dotnet10.0/0006-runtime-eng-common-cross-toolchain.cmake.patch new file mode 100644 index 00000000000..e414d9b1989 --- /dev/null +++ b/packages/dotnet10.0/0006-runtime-eng-common-cross-toolchain.cmake.patch @@ -0,0 +1,57 @@ +diff --git a/src/runtime/eng/common/cross/toolchain.cmake b/src/runtime/eng/common/cross/toolchain.cmake +index 0ff85cf03..875df5c47 100644 +--- 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) +@@ -85,6 +89,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") + if(TIZEN) +@@ -102,6 +108,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) +@@ -118,6 +126,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() +@@ -230,6 +240,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/dotnet10.0/0007-set-TargetsLinuxBionic-from-TargetRid.patch b/packages/dotnet10.0/0007-set-TargetsLinuxBionic-from-TargetRid.patch new file mode 100644 index 00000000000..93891303f0a --- /dev/null +++ b/packages/dotnet10.0/0007-set-TargetsLinuxBionic-from-TargetRid.patch @@ -0,0 +1,35 @@ +Description: Set TargetsLinuxBionic from TargetRid and override DefaultSubsets for source-build + When building for linux-bionic via the VMR, TargetOS is 'linux' (not + 'linux-bionic'), so TargetsLinuxBionic is never set. This causes two + problems: (1) The Mono native build uses cross/toolchain.cmake which + targets linux-gnu instead of the Android NDK toolchain, causing CRT + link failures (Scrt1.o, crti.o, -lgcc_s not found). (2) The default + subset includes NativeAOT components that set RuntimeFlavor=CoreCLR, + mismatching PrimaryRuntimeFlavor=Mono and breaking tarball packaging. + Fix by deriving TargetsLinuxBionic from TargetRid and adding a + source-build override that uses mono+libs+host+packs (no NativeAOT). + +diff --git a/src/runtime/eng/Subsets.props b/src/runtime/eng/Subsets.props +index 5770eec31..a1b2c3d4e 100644 +--- a/src/runtime/eng/Subsets.props ++++ b/src/runtime/eng/Subsets.props +@@ -26,6 +26,10 @@ + platforms (like s390x) where only Mono is supported. The primary runtime + flavor is used to decide when to build the hosts and installers. --> + ++ ++ true ++ + + <_CoreCLRSupportedOS Condition="'$(TargetsMobile)' != 'true' and '$(TargetsLinuxBionic)' != 'true'">true + +@@ -77,6 +81,8 @@ + clr.nativeaotruntime+clr.nativeaotlibs+libs+packs + + clr+libs+tools+host+packs ++ ++ mono+libs+tools.illink+host+packs + mono+packs + + diff --git a/packages/dotnet10.0/0008-add-prebuilt-baseline-for-mono-llvm.patch b/packages/dotnet10.0/0008-add-prebuilt-baseline-for-mono-llvm.patch new file mode 100644 index 00000000000..d5b3850992b --- /dev/null +++ b/packages/dotnet10.0/0008-add-prebuilt-baseline-for-mono-llvm.patch @@ -0,0 +1,19 @@ +Description: Add prebuilt baseline for Mono LLVM packages + When TargetsLinuxBionic is set, the Mono build initializes LLVM + which downloads prebuilt LLVM packages. The source-build validation + in finish-source-only.proj flags these as new prebuilts not in the + baseline. Add a prebuilt-baseline.xml to whitelist them. + +diff --git a/eng/tools/prebuilt-baseline.xml b/eng/tools/prebuilt-baseline.xml +new file mode 100644 +index 000000000..000000001 +--- /dev/null ++++ b/eng/tools/prebuilt-baseline.xml +@@ -0,0 +1,7 @@ ++ ++ ++ ++ ++ ++ ++ diff --git a/packages/dotnet10.0/0010-revert-stop-setting-separate-properties-BUNDLE_PROP-HOSTPOLICY_EMBEDDED-PINVOKE_OVERRIDE.patch b/packages/dotnet10.0/0010-revert-stop-setting-separate-properties-BUNDLE_PROP-HOSTPOLICY_EMBEDDED-PINVOKE_OVERRIDE.patch new file mode 100644 index 00000000000..4d2ad05ef30 --- /dev/null +++ b/packages/dotnet10.0/0010-revert-stop-setting-separate-properties-BUNDLE_PROP-HOSTPOLICY_EMBEDDED-PINVOKE_OVERRIDE.patch @@ -0,0 +1,253 @@ +Revert https://github.com/dotnet/runtime/commit/da5bd2bc91c78a457c4bf28c09759f368e0f3238 +Workaround https://github.com/dotnet/runtime/issues/111071 + +diff --git a/src/runtime/docs/design/features/host-runtime-information.md b/src/runtime/docs/design/features/host-runtime-information.md +index b42102930..e6557a1e0 100644 +--- a/src/runtime/docs/design/features/host-runtime-information.md ++++ b/src/runtime/docs/design/features/host-runtime-information.md +@@ -88,16 +88,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. +diff --git a/src/runtime/src/coreclr/dlls/mscoree/exports.cpp b/src/runtime/src/coreclr/dlls/mscoree/exports.cpp +index 151542344..71aae1573 100644 +--- a/src/runtime/src/coreclr/dlls/mscoree/exports.cpp ++++ b/src/runtime/src/coreclr/dlls/mscoree/exports.cpp +@@ -136,6 +136,7 @@ static void ConvertConfigPropertiesToUnicode( + LPCWSTR** propertyValuesWRef, + BundleProbeFn** bundleProbe, + PInvokeOverrideFn** pinvokeOverride, ++ bool* hostPolicyEmbedded, + host_runtime_contract** hostContract) + { + LPCWSTR* propertyKeysW = new (nothrow) LPCWSTR[propertyCount]; +@@ -167,6 +168,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). +@@ -244,6 +250,7 @@ int coreclr_initialize( + LPCWSTR* propertyKeysW; + LPCWSTR* propertyValuesW; + BundleProbeFn* bundleProbe = nullptr; ++ bool hostPolicyEmbedded = false; + PInvokeOverrideFn* pinvokeOverride = nullptr; + host_runtime_contract* hostContract = nullptr; + +@@ -259,6 +266,7 @@ int coreclr_initialize( + &propertyValuesW, + &bundleProbe, + &pinvokeOverride, ++ &hostPolicyEmbedded, + &hostContract); + + #ifdef TARGET_UNIX +@@ -273,6 +281,8 @@ int coreclr_initialize( + } + #endif + ++ g_hostpolicy_embedded = hostPolicyEmbedded; ++ + if (hostContract != nullptr) + { + HostInformation::SetContract(hostContract); +diff --git a/src/runtime/src/coreclr/vm/ceemain.cpp b/src/runtime/src/coreclr/vm/ceemain.cpp +index 4be75dc91..bb1f922fd 100644 +--- a/src/runtime/src/coreclr/vm/ceemain.cpp ++++ b/src/runtime/src/coreclr/vm/ceemain.cpp +@@ -228,12 +228,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. +diff --git a/src/runtime/src/mono/mono/mini/monovm.c b/src/runtime/src/mono/mono/mini/monovm.c +index 9d9b1ae39..7541bc315 100644 +--- 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; + } + +diff --git a/src/runtime/src/native/corehost/apphost/static/CMakeLists.txt b/src/runtime/src/native/corehost/apphost/static/CMakeLists.txt +index 7187162d6..cb2420489 100644 +--- a/src/runtime/src/native/corehost/apphost/static/CMakeLists.txt ++++ b/src/runtime/src/native/corehost/apphost/static/CMakeLists.txt +@@ -36,6 +36,7 @@ set(HEADERS + ../../fxr_resolver.h + ) + ++add_compile_definitions(HOSTPOLICY_EMBEDDED) + # TODO: https://github.com/dotnet/runtime/issues/111523 + if (NOT CLR_CMAKE_TARGET_ANDROID) + add_compile_definitions(NATIVE_LIBS_EMBEDDED) +diff --git a/src/runtime/src/native/corehost/host_runtime_contract.h b/src/runtime/src/native/corehost/host_runtime_contract.h +index 65bc3c746..1c93b192e 100644 +--- a/src/runtime/src/native/corehost/host_runtime_contract.h ++++ b/src/runtime/src/native/corehost/host_runtime_contract.h +@@ -19,6 +19,7 @@ + #define HOST_PROPERTY_BUNDLE_PROBE "BUNDLE_PROBE" + #define HOST_PROPERTY_BUNDLE_EXTRACTION_PATH "BUNDLE_EXTRACTION_PATH" + #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" +diff --git a/src/runtime/src/native/corehost/hostpolicy/coreclr.cpp b/src/runtime/src/native/corehost/hostpolicy/coreclr.cpp +index 8f71aa18c..a2d436f47 100644 +--- 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"); +diff --git a/src/runtime/src/native/corehost/hostpolicy/coreclr.h b/src/runtime/src/native/corehost/hostpolicy/coreclr.h +index 1ee29ba7e..c007e67fe 100644 +--- 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 + }; +diff --git a/src/runtime/src/native/corehost/hostpolicy/hostpolicy_context.cpp b/src/runtime/src/native/corehost/hostpolicy/hostpolicy_context.cpp +index e51347221..b6715c2fa 100644 +--- a/src/runtime/src/native/corehost/hostpolicy/hostpolicy_context.cpp ++++ b/src/runtime/src/native/corehost/hostpolicy/hostpolicy_context.cpp +@@ -343,6 +343,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/dotnet10.0/0011-fix-paths.patch b/packages/dotnet10.0/0011-fix-paths.patch new file mode 100644 index 00000000000..ec8cf780c34 --- /dev/null +++ b/packages/dotnet10.0/0011-fix-paths.patch @@ -0,0 +1,346 @@ +diff --git a/src/msbuild/src/Shared/NamedPipeUtil.cs b/src/msbuild/src/Shared/NamedPipeUtil.cs +index 0b85b05ba..9d7312db7 100644 +--- a/src/msbuild/src/Shared/NamedPipeUtil.cs ++++ b/src/msbuild/src/Shared/NamedPipeUtil.cs +@@ -31,7 +31,7 @@ namespace Microsoft.Build.Shared + // '/tmp' is mandated by POSIX to always be a valid temp directory, so we can use that + // instead. + #if !CLR2COMPATIBILITY +- return Path.Combine("/tmp", pipeName); ++ return Path.Combine("@TERMUX_PREFIX@/tmp", pipeName); + #else + // We should never get here. This would be a net35 task host running on unix. + ErrorUtilities.ThrowInternalError("Task host used on unix in retrieving the pipe name."); +diff --git a/src/runtime/src/coreclr/debug/createdump/createdumpmain.cpp b/src/runtime/src/coreclr/debug/createdump/createdumpmain.cpp +index b3426a31d..d4ef29cdb 100644 +--- a/src/runtime/src/coreclr/debug/createdump/createdumpmain.cpp ++++ b/src/runtime/src/coreclr/debug/createdump/createdumpmain.cpp +@@ -8,7 +8,7 @@ + #define DEFAULT_DUMP_PATH "%TEMP%\\" + #define DEFAULT_DUMP_TEMPLATE "dump.%p.dmp" + #else +-#define DEFAULT_DUMP_PATH "/tmp/" ++#define DEFAULT_DUMP_PATH "@TERMUX_PREFIX@/tmp/" + #define DEFAULT_DUMP_TEMPLATE "coredump.%p" + #endif + +diff --git a/src/runtime/src/coreclr/debug/createdump/createdumppal.cpp b/src/runtime/src/coreclr/debug/createdump/createdumppal.cpp +index 94e4606ea..8a6405b71 100644 +--- a/src/runtime/src/coreclr/debug/createdump/createdumppal.cpp ++++ b/src/runtime/src/coreclr/debug/createdump/createdumppal.cpp +@@ -95,7 +95,7 @@ UninitializePAL( + } + } + +-#define TEMP_DIRECTORY_PATH "/tmp/" ++#define TEMP_DIRECTORY_PATH "@TERMUX_PREFIX@/tmp/" + + DWORD + PALAPI +diff --git a/src/runtime/src/coreclr/nativeaot/Runtime/eventpipe/ep-rt-aot.h b/src/runtime/src/coreclr/nativeaot/Runtime/eventpipe/ep-rt-aot.h +index 78d6578dc..ec46cd2ac 100644 +--- a/src/runtime/src/coreclr/nativeaot/Runtime/eventpipe/ep-rt-aot.h ++++ b/src/runtime/src/coreclr/nativeaot/Runtime/eventpipe/ep-rt-aot.h +@@ -1074,7 +1074,7 @@ ep_rt_temp_path_get ( + if (path == NULL){ + path = getenv ("TEMP"); + if (path == NULL) +- path = "/tmp/"; ++ path = "@TERMUX_PREFIX@/tmp/"; + } + } + +diff --git a/src/runtime/src/coreclr/pal/src/include/pal/palinternal.h b/src/runtime/src/coreclr/pal/src/include/pal/palinternal.h +index 603ea73b0..e1006d883 100644 +--- a/src/runtime/src/coreclr/pal/src/include/pal/palinternal.h ++++ b/src/runtime/src/coreclr/pal/src/include/pal/palinternal.h +@@ -229,7 +229,7 @@ function_name() to call the system's implementation + #else + // On Android, "/tmp/" doesn't exist; temporary files should go to + // /data/local/tmp/ +-#define TEMP_DIRECTORY_PATH "/data/local/tmp/" ++#define TEMP_DIRECTORY_PATH "@TERMUX_PREFIX@/tmp/" + #endif + + #define PROCESS_PIPE_NAME_PREFIX ".dotnet-pal-processpipe" +diff --git a/src/runtime/src/coreclr/vm/perfmap.cpp b/src/runtime/src/coreclr/vm/perfmap.cpp +index df46fe9c1..d3f634825 100644 +--- a/src/runtime/src/coreclr/vm/perfmap.cpp ++++ b/src/runtime/src/coreclr/vm/perfmap.cpp +@@ -23,7 +23,7 @@ + #else + // On Android, "/tmp/" doesn't exist; temporary files should go to + // /data/local/tmp/ +-#define TEMP_DIRECTORY_PATH "/data/local/tmp" ++#define TEMP_DIRECTORY_PATH "@TERMUX_PREFIX@/tmp" + #endif + + Volatile PerfMap::s_enabled = false; +diff --git a/src/runtime/src/libraries/Common/src/System/Net/NetworkInformation/UnixCommandLinePing.cs b/src/runtime/src/libraries/Common/src/System/Net/NetworkInformation/UnixCommandLinePing.cs +index c6918cf12..6f58afd3c 100644 +--- a/src/runtime/src/libraries/Common/src/System/Net/NetworkInformation/UnixCommandLinePing.cs ++++ b/src/runtime/src/libraries/Common/src/System/Net/NetworkInformation/UnixCommandLinePing.cs +@@ -10,7 +10,7 @@ namespace System.Net.NetworkInformation + internal static class UnixCommandLinePing + { + // Ubuntu has ping under /bin, OSX under /sbin, ArchLinux under /usr/bin, Android under /system/bin, NixOS under /run/current-system/sw/bin. +- private static readonly string[] s_binFolders = { "/bin", "/sbin", "/usr/bin", "/system/bin", "/run/current-system/sw/bin" }; ++ private static readonly string[] s_binFolders = { "@TERMUX_PREFIX@/bin", "/bin", "/sbin", "/usr/bin", "/system/bin", "/run/current-system/sw/bin" }; + + private const string s_ipv4PingFile = "ping4"; + private const string s_ipv4v6PingFile = "ping"; +diff --git a/src/runtime/src/libraries/Microsoft.Extensions.DependencyModel/src/Resolution/DotNetReferenceAssembliesPathResolver.cs b/src/runtime/src/libraries/Microsoft.Extensions.DependencyModel/src/Resolution/DotNetReferenceAssembliesPathResolver.cs +index ead221a3f..f1a279e6f 100644 +--- a/src/runtime/src/libraries/Microsoft.Extensions.DependencyModel/src/Resolution/DotNetReferenceAssembliesPathResolver.cs ++++ b/src/runtime/src/libraries/Microsoft.Extensions.DependencyModel/src/Resolution/DotNetReferenceAssembliesPathResolver.cs +@@ -49,6 +49,11 @@ public class DotNetReferenceAssembliesPathResolver + return "/Library/Frameworks/Mono.framework/Versions/Current/lib/mono/xbuild-frameworks"; + } + ++ if (fileSystem.Directory.Exists("@TERMUX_PREFIX@/lib/mono/xbuild-frameworks")) ++ { ++ return "@TERMUX_PREFIX@/lib/mono/xbuild-frameworks"; ++ } ++ + if (fileSystem.Directory.Exists("/usr/local/lib/mono/xbuild-frameworks")) + { + return "/usr/local/lib/mono/xbuild-frameworks"; +diff --git a/src/runtime/src/libraries/System.Console/src/System/TermInfo.DatabaseFactory.cs b/src/runtime/src/libraries/System.Console/src/System/TermInfo.DatabaseFactory.cs +index 7ae7cc51e..c012c6131 100644 +--- a/src/runtime/src/libraries/System.Console/src/System/TermInfo.DatabaseFactory.cs ++++ b/src/runtime/src/libraries/System.Console/src/System/TermInfo.DatabaseFactory.cs +@@ -16,11 +16,11 @@ internal sealed class DatabaseFactory + /// This is the ordering of well-known locations used by ncurses. + /// + internal static readonly string[] SystemTermInfoLocations = { +- "/etc/terminfo", +- "/lib/terminfo", +- "/usr/share/terminfo", +- "/usr/share/misc/terminfo", +- "/usr/local/share/terminfo" ++ "@TERMUX_PREFIX@/etc/terminfo", ++ "@TERMUX_PREFIX@/lib/terminfo", ++ "@TERMUX_PREFIX@/share/terminfo", ++ "@TERMUX_PREFIX@/share/misc/terminfo", ++ "@TERMUX_PREFIX@/local/share/terminfo" + }; + + internal static string? HomeTermInfoLocation +diff --git a/src/runtime/src/libraries/System.Formats.Tar/src/System/Formats/Tar/TarHeader.Write.cs b/src/runtime/src/libraries/System.Formats.Tar/src/System/Formats/Tar/TarHeader.Write.cs +index df33b14d3..350ec795a 100644 +--- a/src/runtime/src/libraries/System.Formats.Tar/src/System/Formats/Tar/TarHeader.Write.cs ++++ b/src/runtime/src/libraries/System.Formats.Tar/src/System/Formats/Tar/TarHeader.Write.cs +@@ -1218,7 +1218,7 @@ private static string GenerateGlobalExtendedAttributeName(int globalExtendedAttr + + string result = $"{tmp}/GlobalHead.{Environment.ProcessId}.{globalExtendedAttributesEntryNumber}"; + return result.Length >= FieldLengths.Name ? +- string.Concat("/tmp", result.AsSpan(tmp.Length)) : ++ string.Concat("@TERMUX_PREFIX@/tmp", result.AsSpan(tmp.Length)) : + result; + } + +diff --git a/src/runtime/src/libraries/System.Net.NetworkInformation/src/System/Net/NetworkInformation/NetworkFiles.cs b/src/runtime/src/libraries/System.Net.NetworkInformation/src/System/Net/NetworkInformation/NetworkFiles.cs +index bc31a9fab..675d524d3 100644 +--- a/src/runtime/src/libraries/System.Net.NetworkInformation/src/System/Net/NetworkInformation/NetworkFiles.cs ++++ b/src/runtime/src/libraries/System.Net.NetworkInformation/src/System/Net/NetworkInformation/NetworkFiles.cs +@@ -17,15 +17,15 @@ internal static class NetworkFiles + public const string SockstatFile = "/proc/net/sockstat"; + public const string Sockstat6File = "/proc/net/sockstat6"; + public const string SysClassNetFolder = "/sys/class/net"; +- public const string EtcResolvConfFile = "/etc/resolv.conf"; ++ public const string EtcResolvConfFile = "@TERMUX_PREFIX@/etc/resolv.conf"; + public const string Tcp4ConnectionsFile = "/proc/net/tcp"; + public const string Tcp6ConnectionsFile = "/proc/net/tcp6"; + public const string Udp4ConnectionsFile = "/proc/net/udp"; + public const string Udp6ConnectionsFile = "/proc/net/udp6"; +- public const string DHClientLeasesFile = "/var/lib/dhcp/dhclient.leases"; +- public const string DHClientInterfaceLeasesFile = "/var/lib/dhcp/dhclient.{0}.leases"; +- public const string DHClientSecondaryInterfaceLeasesFile = "/var/lib/dhcp/dhclient6.{0}.leases"; +- public const string SmbConfFile = "/etc/samba/smb.conf"; ++ public const string DHClientLeasesFile = "@TERMUX_PREFIX@/var/lib/dhcp/dhclient.leases"; ++ public const string DHClientInterfaceLeasesFile = "@TERMUX_PREFIX@/var/lib/dhcp/dhclient.{0}.leases"; ++ public const string DHClientSecondaryInterfaceLeasesFile = "@TERMUX_PREFIX@/var/lib/dhcp/dhclient6.{0}.leases"; ++ public const string SmbConfFile = "@TERMUX_PREFIX@/etc/samba/smb.conf"; + + // Individual file names + public const string AllNetworkInterfaceFileName = "all"; +diff --git a/src/runtime/src/libraries/System.Private.CoreLib/src/System/Environment.Android.cs b/src/runtime/src/libraries/System.Private.CoreLib/src/System/Environment.Android.cs +index 23499bfc2..76dddcc99 100644 +--- a/src/runtime/src/libraries/System.Private.CoreLib/src/System/Environment.Android.cs ++++ b/src/runtime/src/libraries/System.Private.CoreLib/src/System/Environment.Android.cs +@@ -82,7 +82,7 @@ private static string GetFolderPathCore(SpecialFolder folder, SpecialFolderOptio + return Path.Combine(home, "Videos"); + + case SpecialFolder.CommonTemplates: +- return "/usr/share/templates"; ++ return "@TERMUX_PREFIX@/share/templates"; + + case SpecialFolder.Fonts: + return Path.Combine(home, ".fonts"); +@@ -91,7 +91,7 @@ private static string GetFolderPathCore(SpecialFolder folder, SpecialFolderOptio + return home; + + case SpecialFolder.CommonApplicationData: +- return "/usr/share"; ++ return "@TERMUX_PREFIX@/share"; + + default: + if (!Enum.IsDefined(folder)) +diff --git a/src/runtime/src/libraries/System.Private.CoreLib/src/System/Environment.GetFolderPathCore.Unix.cs b/src/runtime/src/libraries/System.Private.CoreLib/src/System/Environment.GetFolderPathCore.Unix.cs +index 9d7cf66b2..ccdb772c6 100644 +--- a/src/runtime/src/libraries/System.Private.CoreLib/src/System/Environment.GetFolderPathCore.Unix.cs ++++ b/src/runtime/src/libraries/System.Private.CoreLib/src/System/Environment.GetFolderPathCore.Unix.cs +@@ -52,8 +52,8 @@ private static string GetFolderPathCore(SpecialFolder folder, SpecialFolderOptio + // https://www.freedesktop.org/software/systemd/man/file-hierarchy.html + switch (folder) + { +- case SpecialFolder.CommonApplicationData: return "/usr/share"; +- case SpecialFolder.CommonTemplates: return "/usr/share/templates"; ++ case SpecialFolder.CommonApplicationData: return "@TERMUX_PREFIX@/share"; ++ case SpecialFolder.CommonTemplates: return "@TERMUX_PREFIX@/share/templates"; + #if TARGET_OSX + case SpecialFolder.ProgramFiles: return "/Applications"; + case SpecialFolder.System: return "/System"; +diff --git a/src/runtime/src/libraries/System.Private.CoreLib/src/System/IO/Path.Unix.NoniOS.cs b/src/runtime/src/libraries/System.Private.CoreLib/src/System/IO/Path.Unix.NoniOS.cs +index b2a9a4b06..44e3c1df6 100644 +--- a/src/runtime/src/libraries/System.Private.CoreLib/src/System/IO/Path.Unix.NoniOS.cs ++++ b/src/runtime/src/libraries/System.Private.CoreLib/src/System/IO/Path.Unix.NoniOS.cs +@@ -5,6 +5,6 @@ namespace System.IO + { + public static partial class Path + { +- private static string DefaultTempPath => "/tmp/"; ++ private static string DefaultTempPath => "@TERMUX_PREFIX@/tmp/"; + } + } +diff --git a/src/runtime/src/libraries/System.Private.CoreLib/src/System/TimeZoneInfo.Unix.cs b/src/runtime/src/libraries/System.Private.CoreLib/src/System/TimeZoneInfo.Unix.cs +index 89ce9d7be..0fcf9838b 100644 +--- a/src/runtime/src/libraries/System.Private.CoreLib/src/System/TimeZoneInfo.Unix.cs ++++ b/src/runtime/src/libraries/System.Private.CoreLib/src/System/TimeZoneInfo.Unix.cs +@@ -19,7 +19,7 @@ public sealed partial class TimeZoneInfo + #if TARGET_ILLUMOS || TARGET_SOLARIS + private const string DefaultTimeZoneDirectory = "/usr/share/lib/zoneinfo/"; + #else +- private const string DefaultTimeZoneDirectory = "/usr/share/zoneinfo/"; ++ private const string DefaultTimeZoneDirectory = "@TERMUX_PREFIX@/share/zoneinfo/"; + #endif + + // Set fallback values using abbreviations, base offset, and id +diff --git a/src/runtime/src/libraries/System.Security.Cryptography/src/System/Security/Cryptography/X509Certificates/OpenSslCachedSystemStoreProvider.cs b/src/runtime/src/libraries/System.Security.Cryptography/src/System/Security/Cryptography/X509Certificates/OpenSslCachedSystemStoreProvider.cs +index 9c3fa0252..9c97e21e5 100644 +--- a/src/runtime/src/libraries/System.Security.Cryptography/src/System/Security/Cryptography/X509Certificates/OpenSslCachedSystemStoreProvider.cs ++++ b/src/runtime/src/libraries/System.Security.Cryptography/src/System/Security/Cryptography/X509Certificates/OpenSslCachedSystemStoreProvider.cs +@@ -181,7 +181,7 @@ private static Tuple LoadMachineStores + + if (firstLoad && !hasStoreData && s_defaultRootDir) + { +- const string DefaultCertDir = "/etc/ssl/certs"; ++ const string DefaultCertDir = "@TERMUX_PREFIX@/etc/ssl/certs"; + hasStoreData = ProcessDir(DefaultCertDir, out DateTime lastModified); + if (hasStoreData) + { +diff --git a/src/runtime/src/mono/mono/eglib/gmisc-unix.c b/src/runtime/src/mono/mono/eglib/gmisc-unix.c +index 09557680a..4d8ead8d1 100644 +--- a/src/runtime/src/mono/mono/eglib/gmisc-unix.c ++++ b/src/runtime/src/mono/mono/eglib/gmisc-unix.c +@@ -121,7 +121,7 @@ g_get_tmp_dir (void) + if (tmp_dir == NULL){ + tmp_dir = g_getenv ("TEMP"); + if (tmp_dir == NULL) +- tmp_dir = "/tmp"; ++ tmp_dir = "@TERMUX_PREFIX@/tmp"; + } + } + } +diff --git a/src/runtime/src/mono/mono/mini/graph.c b/src/runtime/src/mono/mono/mini/graph.c +index 0ebc434c3..55035809c 100644 +--- a/src/runtime/src/mono/mono/mini/graph.c ++++ b/src/runtime/src/mono/mono/mini/graph.c +@@ -203,7 +203,7 @@ mono_draw_graph (MonoCompile *cfg, MonoGraphOptions draw_options) + const char *fn; + FILE *fp; + +- fn = "/tmp/minidtree.graph"; ++ fn = "@TERMUX_PREFIX@/tmp/minidtree.graph"; + fp = fopen (fn, "w+"); + g_assert (fp); + +diff --git a/src/runtime/src/mono/mono/mini/mini-posix.c b/src/runtime/src/mono/mono/mini/mini-posix.c +index 4c36fd6b3..c42cedbfa 100644 +--- a/src/runtime/src/mono/mono/mini/mini-posix.c ++++ b/src/runtime/src/mono/mono/mini/mini-posix.c +@@ -979,7 +979,7 @@ mono_gdb_render_native_backtraces (pid_t crashed_pid) + + char commands_filename [100]; + commands_filename [0] = '\0'; +- g_snprintf (commands_filename, sizeof (commands_filename), "/tmp/mono-gdb-commands.%d", crashed_pid); ++ g_snprintf (commands_filename, sizeof (commands_filename), "@TERMUX_PREFIX@/tmp/mono-gdb-commands.%d", crashed_pid); + + // Create this file, overwriting if it already exists + int commands_handle = g_open (commands_filename, O_TRUNC | O_WRONLY | O_CREAT, S_IWUSR | S_IRUSR | S_IRGRP | S_IROTH); +diff --git a/src/runtime/src/mono/mono/mini/mini-runtime.c b/src/runtime/src/mono/mono/mini/mini-runtime.c +index 7cf63847f..839708288 100644 +--- a/src/runtime/src/mono/mono/mini/mini-runtime.c ++++ b/src/runtime/src/mono/mono/mini/mini-runtime.c +@@ -1985,7 +1985,7 @@ mono_enable_jit_map (void) + { + if (!perf_map_file) { + char name [64]; +- g_snprintf (name, sizeof (name), "/tmp/perf-%d.map", getpid ()); ++ g_snprintf (name, sizeof (name), "@TERMUX_PREFIX@/tmp/perf-%d.map", getpid ()); + unlink (name); + perf_map_file = fopen (name, "w"); + } +@@ -2110,7 +2110,7 @@ mono_enable_jit_dump (void) + mono_os_mutex_init (&perf_dump_mutex); + mono_os_mutex_lock (&perf_dump_mutex); + +- g_snprintf (name, sizeof (name), "/tmp/jit-%d.dump", perf_dump_pid); ++ g_snprintf (name, sizeof (name), "@TERMUX_PREFIX@/tmp/jit-%d.dump", perf_dump_pid); + unlink (name); + perf_dump_file = fopen (name, "w+"); + +diff --git a/src/runtime/src/mono/mono/mini/viewstat.pl b/src/runtime/src/mono/mono/mini/viewstat.pl +index 50bd05b67..4f1ce2ca6 100644 +--- a/src/runtime/src/mono/mono/mini/viewstat.pl ++++ b/src/runtime/src/mono/mono/mini/viewstat.pl +@@ -75,7 +75,7 @@ if ($stattitle ne "") { + $outfile = $Opts{'o'}; + + if ($outfile eq "") { +- $tmp = $outfile = "/tmp/viewstat" . $$ . ".png"; ++ $tmp = $outfile = "@TERMUX_PREFIX@/tmp/viewstat" . $$ . ".png"; + } + + $graph->plot(\@data); +diff --git a/src/runtime/src/native/corehost/hostmisc/pal.unix.cpp b/src/runtime/src/native/corehost/hostmisc/pal.unix.cpp +index 4a6197f54..1c6f160c8 100644 +--- a/src/runtime/src/native/corehost/hostmisc/pal.unix.cpp ++++ b/src/runtime/src/native/corehost/hostmisc/pal.unix.cpp +@@ -421,7 +421,7 @@ bool pal::get_global_dotnet_dirs(std::vector* recv) + + pal::string_t pal::get_dotnet_self_registered_config_location(pal::architecture arch) + { +- pal::string_t config_location = _X("/etc/dotnet"); ++ pal::string_t config_location = _X("@TERMUX_PREFIX@/etc/dotnet"); + + // ***Used only for testing*** + pal::string_t environment_install_location_override; +@@ -613,7 +613,7 @@ bool pal::get_default_installation_dir_for_arch(pal::architecture arch, pal::str + recv->assign(_X("/usr/local/share/dotnet")); + } + #else +- recv->assign(_X("/usr/share/dotnet")); ++ recv->assign(_X("@TERMUX_PREFIX@/share/dotnet")); + #endif + return true; + } +@@ -818,7 +818,7 @@ pal::string_t normalize_linux_rid(pal::string_t rid) + pal::string_t pal::get_current_os_rid_platform() + { + pal::string_t ridOS; +- pal::string_t versionFile(_X("/etc/os-release")); ++ pal::string_t versionFile(_X("@TERMUX_PREFIX@/etc/os-release")); + + if (pal::file_exists(versionFile)) + { diff --git a/packages/dotnet10.0/0012-runtime-fix-runpath-issues.patch b/packages/dotnet10.0/0012-runtime-fix-runpath-issues.patch new file mode 100644 index 00000000000..bf24b8c7830 --- /dev/null +++ b/packages/dotnet10.0/0012-runtime-fix-runpath-issues.patch @@ -0,0 +1,38 @@ +System.Security.Cryptography.Native needs libssl.so and libcrypto.so, both of which are provided by Termux +System.Net.Security.Native needs libgssapi_krb5.so.2 +Mono CoreCLR needs to be able to find libraries in "$TERMUX_PREFIX/lib" +This sets rpath to help the linker find them during runtime + +diff --git a/src/runtime/src/mono/mono/mini/CMakeLists.txt b/src/runtime/src/mono/mono/mini/CMakeLists.txt +index 23b8d15bf..05e513546 100644 +--- a/src/runtime/src/mono/mono/mini/CMakeLists.txt ++++ b/src/runtime/src/mono/mono/mini/CMakeLists.txt +@@ -1,4 +1,5 @@ + project(mini C) ++add_link_options("-Wl,-rpath,@TERMUX_PREFIX@/lib") + + if(ENABLE_LLVM OR ENABLE_LLVM_RUNTIME OR HOST_BROWSER) + enable_language(CXX) +diff --git a/src/runtime/src/native/libs/System.Net.Security.Native/CMakeLists.txt b/src/runtime/src/native/libs/System.Net.Security.Native/CMakeLists.txt +index 4a19c74da..0af603cb4 100644 +--- a/src/runtime/src/native/libs/System.Net.Security.Native/CMakeLists.txt ++++ b/src/runtime/src/native/libs/System.Net.Security.Native/CMakeLists.txt +@@ -1,5 +1,6 @@ + project(System.Net.Security.Native C) + ++add_link_options("-Wl,-rpath,@TERMUX_PREFIX@/lib") + add_compile_options(-Wno-incompatible-pointer-types-discards-qualifiers) + + include(${CMAKE_CURRENT_LIST_DIR}/extra_libs.cmake) +diff --git a/src/runtime/src/native/libs/System.Security.Cryptography.Native/CMakeLists.txt b/src/runtime/src/native/libs/System.Security.Cryptography.Native/CMakeLists.txt +index c875413ed..734f0d95b 100644 +--- a/src/runtime/src/native/libs/System.Security.Cryptography.Native/CMakeLists.txt ++++ b/src/runtime/src/native/libs/System.Security.Cryptography.Native/CMakeLists.txt +@@ -4,6 +4,7 @@ cmake_minimum_required(VERSION 3.10..3.20) + project(System.Security.Cryptography.Native C) + + # These are happening inside of OpenSSL-defined macros out of our control ++add_link_options("-Wl,-rpath,@TERMUX_PREFIX@/lib") + add_compile_options(-Wno-cast-align) + add_compile_options(-Wno-reserved-id-macro) + add_compile_options(-Wno-documentation) diff --git a/packages/dotnet10.0/aspnetcore-runtime-10.0.subpackage.sh b/packages/dotnet10.0/aspnetcore-runtime-10.0.subpackage.sh new file mode 100644 index 00000000000..77c7e88ef64 --- /dev/null +++ b/packages/dotnet10.0/aspnetcore-runtime-10.0.subpackage.sh @@ -0,0 +1,4 @@ +TERMUX_SUBPKG_DESCRIPTION="ASP.NET Core 10.0 Runtime" +TERMUX_SUBPKG_DEPEND_ON_PARENT=false +TERMUX_SUBPKG_DEPENDS="dotnet-runtime-10.0" +TERMUX_SUBPKG_INCLUDE=$(cat "${TERMUX_PKG_TMPDIR}"/aspnetcore-runtime.txt) diff --git a/packages/dotnet10.0/aspnetcore-runtime-dbg-10.0.subpackage.sh b/packages/dotnet10.0/aspnetcore-runtime-dbg-10.0.subpackage.sh new file mode 100644 index 00000000000..404fe16c75d --- /dev/null +++ b/packages/dotnet10.0/aspnetcore-runtime-dbg-10.0.subpackage.sh @@ -0,0 +1,4 @@ +TERMUX_SUBPKG_DESCRIPTION="ASP.NET Core 10.0 Runtime Managed Debug Symbols" +TERMUX_SUBPKG_DEPEND_ON_PARENT=false +TERMUX_SUBPKG_DEPENDS="aspnetcore-runtime-10.0" +TERMUX_SUBPKG_INCLUDE=$(cat "${TERMUX_PKG_TMPDIR}"/aspnetcore-runtime-dbg.txt) diff --git a/packages/dotnet10.0/aspnetcore-targeting-pack-10.0.subpackage.sh b/packages/dotnet10.0/aspnetcore-targeting-pack-10.0.subpackage.sh new file mode 100644 index 00000000000..e15f9c6fc79 --- /dev/null +++ b/packages/dotnet10.0/aspnetcore-targeting-pack-10.0.subpackage.sh @@ -0,0 +1,4 @@ +TERMUX_SUBPKG_DESCRIPTION="ASP.NET Core 10.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/dotnet10.0/build.sh b/packages/dotnet10.0/build.sh new file mode 100644 index 00000000000..d7e6aca2fed --- /dev/null +++ b/packages/dotnet10.0/build.sh @@ -0,0 +1,409 @@ +TERMUX_PKG_HOMEPAGE=https://dotnet.microsoft.com/en-us/ +TERMUX_PKG_DESCRIPTION=".NET 10.0" +TERMUX_PKG_LICENSE="MIT" +TERMUX_PKG_MAINTAINER="@truboxl" +TERMUX_PKG_VERSION="10.0.3" +_DOTNET_SDK_VERSION="10.0.103" +TERMUX_PKG_SRCURL=git+https://github.com/dotnet/dotnet +TERMUX_PKG_GIT_BRANCH="v${_DOTNET_SDK_VERSION}" +TERMUX_PKG_BUILD_DEPENDS="krb5, libicu, openssl, zlib" +TERMUX_PKG_SUGGESTS="dotnet-sdk-10.0" +TERMUX_PKG_CONFLICTS="dotnet8.0, dotnet9.0" +TERMUX_PKG_BUILD_IN_SRC=true +TERMUX_PKG_NO_STATICSPLIT=true +TERMUX_PKG_AUTO_UPDATE=true +# https://github.com/dotnet/runtime/issues/7335 +# linux-x86 is not officially supported but works +# TODO linux-bionic-arm is broken +TERMUX_PKG_EXCLUDED_ARCHES="arm" + +termux_pkg_auto_update() { + local api_url="https://api.github.com/repos/dotnet/core/git/refs/tags" + local latest_refs_tags + latest_refs_tags="$(curl -s "${api_url}" | jq .[].ref | sed -ne "s|.*v\(10.0.*\)\"|\1|p")" + if [[ -z "${latest_refs_tags}" ]]; then + echo "WARN: Unable to get latest refs tags from upstream. Try again later." >&2 + return + fi + + local latest_version + latest_version=$(echo "${latest_refs_tags}" | sort -V | tail -n1) + if [[ "${latest_version}" == "${TERMUX_PKG_VERSION}" ]]; then + echo "INFO: No update needed. Already at version '${TERMUX_PKG_VERSION}'." + return + fi + + if [[ "${BUILD_PACKAGES}" == "false" ]]; then + echo "INFO: package needs to be updated to ${latest_version}." + return + fi + + sed \ + -e "s|^_DOTNET_SDK_VERSION=.*|_DOTNET_SDK_VERSION=\"10.0.$((100 + ${latest_version##*.}))\"|" \ + -i "${TERMUX_PKG_BUILDER_DIR}/build.sh" + + termux_pkg_upgrade_version "${latest_version}" +} + +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-10.0, dotnet-host, dotnet-runtime-10.0" + + termux_setup_cmake + termux_setup_ninja + + # aspnetcore needs nodejs <= 19, but nodejs 18.x and 19.x are EOL + local NODEJS_VERSION=18.20.8 + local NODEJS_SHA256=5467ee62d6af1411d46b6a10e3fb5cacc92734dbcef465fea14e7b90993001c9 + 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) + # .NET 10 changed lttng check to use FEATURE_EVENTSOURCE_XPLAT + set(FEATURE_EVENTSOURCE_XPLAT 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}" + # Strip -rpath from LDFLAGS; the 0012 CMake patch adds it correctly. + # Keeping it here causes duplicate RUNPATH entries. + export EXTRA_LDFLAGS="$(echo "${LDFLAGS}" | sed 's/-Wl,-rpath[=,][^ ]*//')" + + 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 + if ! time ./build.sh \ + --clean-while-building \ + --use-mono-runtime \ + --online \ + --source-build \ + -m:${TERMUX_PKG_MAKE_PROCESSES} \ + -- \ + /p:Configuration=${CONFIG} \ + /p:TargetArchitecture=${arch} \ + /p:TargetRid=linux-bionic-${arch} \ + /p:SkipErrorOnPrebuilts=true; then + echo "ERROR: Build failed" >&2 + termux_dotnet_kill + termux_step_post_make_install + termux_error_exit + fi + "${TERMUX_PKG_BUILDDIR}/.dotnet/dotnet" build-server shutdown + termux_dotnet_kill +} + +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/dotnet10.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}" + # https://github.com/dotnet/sdk/pull/50354 + # NETStandard.Library.Ref is no longer shipped in .NET 10 SDK + rm -fr lib/dotnet/packs/NETStandard.Library.Ref + + # 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/10.0.* \ + \( -type f -o -type l \) ! -name "*.pdb" | sort \ + > "${TERMUX_PKG_TMPDIR}"/aspnetcore-runtime.txt + + find \ + lib/dotnet/shared/Microsoft.AspNetCore.App/10.0.* \ + \( -type f -o -type l \) -name "*.pdb" | sort \ + > "${TERMUX_PKG_TMPDIR}"/aspnetcore-runtime-dbg.txt + + find \ + lib/dotnet/packs/Microsoft.AspNetCore.App.Ref/10.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}/10.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/10.0.* \ + \( -type f -o -type l \) | sort \ + > "${TERMUX_PKG_TMPDIR}"/dotnet-hostfxr.txt + + find \ + lib/dotnet/shared/Microsoft.NETCore.App/10.0.* \ + \( -type f -o -type l \) ! -name "*.pdb" | sort \ + > "${TERMUX_PKG_TMPDIR}"/dotnet-runtime.txt + + find \ + lib/dotnet/shared/Microsoft.NETCore.App/10.0.* \ + \( -type f -o -type l \) -name "*.pdb" | sort \ + > "${TERMUX_PKG_TMPDIR}"/dotnet-runtime-dbg.txt + + find \ + lib/dotnet/metadata/workloads/10.0.* \ + lib/dotnet/packs/Microsoft.AspNetCore.App.Runtime.linux-bionic-${arch}/10.0.* \ + lib/dotnet/packs/Microsoft.NETCore.App.Runtime.linux-bionic-${arch}/10.0.* \ + lib/dotnet/sdk/10.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}/10.0.* \ + lib/dotnet/packs/Microsoft.NETCore.App.Runtime.linux-bionic-${arch}/10.0.* \ + lib/dotnet/sdk/10.0.* \ + \( -type f -o -type l \) -name "*.pdb" | sort \ + > "${TERMUX_PKG_TMPDIR}"/dotnet-sdk-dbg.txt + + find \ + lib/dotnet/packs/Microsoft.NETCore.App.Ref/10.0.* \ + \( -type f -o -type l \) | sort \ + > "${TERMUX_PKG_TMPDIR}"/dotnet-targeting-pack.txt + + find \ + lib/dotnet/templates/10.0.* \ + \( -type f -o -type l \) | sort \ + > "${TERMUX_PKG_TMPDIR}"/dotnet-templates.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 +} + +termux_step_post_massage() { + local _microsoft_netcore_app_dir="${TERMUX_PREFIX}/lib/dotnet/shared/Microsoft.NETCore.App" + local _files_to_check=" + libSystem.Net.Security.Native.so + libSystem.Security.Cryptography.Native.OpenSsl.so + libcoreclr.so + " + local _rpath_check_file + for _rpath_check_file in ${_files_to_check}; do + if [[ ! -f "${_microsoft_netcore_app_dir}/${TERMUX_PKG_VERSION}/${_rpath_check_file}" ]]; then + echo "ERROR: ${_microsoft_netcore_app_dir}/${TERMUX_PKG_VERSION}/${_rpath_check_file} does not exist!" + echo "ERROR: Finding '${_rpath_check_file}' in '${_microsoft_netcore_app_dir}':" + find "${_microsoft_netcore_app_dir}" -name "${_rpath_check_file}" | sort || : + termux_error_exit "Please review error above!" + fi + local _rpath_check_readelf=$("$READELF" -d "${_microsoft_netcore_app_dir}/${TERMUX_PKG_VERSION}/${_rpath_check_file}") + local _rpath=$(echo "${_rpath_check_readelf}" | sed -ne "s|.*RUNPATH.*\[\(.*\)\].*|\1|p") + if [[ "${_rpath}" != "${TERMUX_PREFIX}/lib" ]]; then + termux_error_exit " + Excessive RUNPATH found. Check readelf output below: + ${_rpath_check_readelf} + " + fi + done +} + +# 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/dotnet10-stage0/APKBUILD +# https://git.alpinelinux.org/aports/tree/community/dotnet10-runtime/APKBUILD +# https://git.alpinelinux.org/aports/tree/community/dotnet10-sdk/APKBUILD +# https://src.fedoraproject.org/rpms/dotnet10.0/blob/rawhide/f/dotnet10.0.spec +# https://git.launchpad.net/ubuntu/+source/dotnet10/tree/debian/rules diff --git a/packages/dotnet10.0/dotnet-apphost-pack-10.0.subpackage.sh b/packages/dotnet10.0/dotnet-apphost-pack-10.0.subpackage.sh new file mode 100644 index 00000000000..49180376803 --- /dev/null +++ b/packages/dotnet10.0/dotnet-apphost-pack-10.0.subpackage.sh @@ -0,0 +1,3 @@ +TERMUX_SUBPKG_DESCRIPTION=".NET 10.0 Targeting Pack" +TERMUX_SUBPKG_DEPEND_ON_PARENT=false +TERMUX_SUBPKG_INCLUDE=$(cat "${TERMUX_PKG_TMPDIR}"/dotnet-apphost-pack.txt) diff --git a/packages/dotnet10.0/dotnet-host-10.0.subpackage.sh b/packages/dotnet10.0/dotnet-host-10.0.subpackage.sh new file mode 100644 index 00000000000..caecfbcfb19 --- /dev/null +++ b/packages/dotnet10.0/dotnet-host-10.0.subpackage.sh @@ -0,0 +1,4 @@ +TERMUX_SUBPKG_DESCRIPTION=".NET 10.0 Host" +TERMUX_SUBPKG_DEPEND_ON_PARENT=false +TERMUX_SUBPKG_CONFLICTS="dotnet-host-8.0, dotnet-host-9.0" +TERMUX_SUBPKG_INCLUDE=$(cat "${TERMUX_PKG_TMPDIR}"/dotnet-host.txt) diff --git a/packages/dotnet10.0/dotnet-hostfxr-10.0.subpackage.sh b/packages/dotnet10.0/dotnet-hostfxr-10.0.subpackage.sh new file mode 100644 index 00000000000..df218804a3f --- /dev/null +++ b/packages/dotnet10.0/dotnet-hostfxr-10.0.subpackage.sh @@ -0,0 +1,4 @@ +TERMUX_SUBPKG_DESCRIPTION=".NET 10.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/dotnet10.0/dotnet-runtime-10.0.subpackage.sh b/packages/dotnet10.0/dotnet-runtime-10.0.subpackage.sh new file mode 100644 index 00000000000..d18ac2b172a --- /dev/null +++ b/packages/dotnet10.0/dotnet-runtime-10.0.subpackage.sh @@ -0,0 +1,4 @@ +TERMUX_SUBPKG_DESCRIPTION=".NET 10.0 Runtime" +TERMUX_SUBPKG_DEPEND_ON_PARENT=false +TERMUX_SUBPKG_DEPENDS="dotnet-hostfxr-10.0, libicu, openssl, zlib" +TERMUX_SUBPKG_INCLUDE=$(cat "${TERMUX_PKG_TMPDIR}"/dotnet-runtime.txt) diff --git a/packages/dotnet10.0/dotnet-runtime-dbg-10.0.subpackage.sh b/packages/dotnet10.0/dotnet-runtime-dbg-10.0.subpackage.sh new file mode 100644 index 00000000000..8c5ef1ade20 --- /dev/null +++ b/packages/dotnet10.0/dotnet-runtime-dbg-10.0.subpackage.sh @@ -0,0 +1,4 @@ +TERMUX_SUBPKG_DESCRIPTION=".NET 10.0 Runtime Managed Debug Symbols" +TERMUX_SUBPKG_DEPEND_ON_PARENT=false +TERMUX_SUBPKG_DEPENDS="dotnet-runtime-10.0" +TERMUX_SUBPKG_INCLUDE=$(cat "${TERMUX_PKG_TMPDIR}"/dotnet-runtime-dbg.txt) diff --git a/packages/dotnet10.0/dotnet-sdk-10.0.subpackage.sh b/packages/dotnet10.0/dotnet-sdk-10.0.subpackage.sh new file mode 100644 index 00000000000..916df3ab56b --- /dev/null +++ b/packages/dotnet10.0/dotnet-sdk-10.0.subpackage.sh @@ -0,0 +1,27 @@ +TERMUX_SUBPKG_DESCRIPTION=".NET 10.0 SDK" +TERMUX_SUBPKG_DEPEND_ON_PARENT=false +TERMUX_SUBPKG_DEPENDS="aspnetcore-runtime-10.0, aspnetcore-targeting-pack-10.0, dotnet-apphost-pack-10.0, dotnet-runtime-10.0, dotnet-targeting-pack-10.0, dotnet-templates-10.0" +TERMUX_SUBPKG_INCLUDE=$(cat "${TERMUX_PKG_TMPDIR}"/dotnet-sdk.txt) + +termux_step_create_subpkg_debscripts() { + cat <<- EOF > ./postinst + #!${TERMUX_PREFIX}/bin/sh + cat <<- EOL + + ==================== + NET SDK known issues + ==================== + + 'export MSBuildDebugEngine=1' + variable to capture more build logs. + + 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/dotnet10.0/dotnet-sdk-dbg-10.0.subpackage.sh b/packages/dotnet10.0/dotnet-sdk-dbg-10.0.subpackage.sh new file mode 100644 index 00000000000..1a0d46b8af1 --- /dev/null +++ b/packages/dotnet10.0/dotnet-sdk-dbg-10.0.subpackage.sh @@ -0,0 +1,4 @@ +TERMUX_SUBPKG_DESCRIPTION=".NET 10.0 SDK Managed Debug Symbols" +TERMUX_SUBPKG_DEPEND_ON_PARENT=false +TERMUX_SUBPKG_DEPENDS="dotnet-sdk-10.0" +TERMUX_SUBPKG_INCLUDE=$(cat "${TERMUX_PKG_TMPDIR}"/dotnet-sdk-dbg.txt) diff --git a/packages/dotnet10.0/dotnet-targeting-pack-10.0.subpackage.sh b/packages/dotnet10.0/dotnet-targeting-pack-10.0.subpackage.sh new file mode 100644 index 00000000000..406e935c03f --- /dev/null +++ b/packages/dotnet10.0/dotnet-targeting-pack-10.0.subpackage.sh @@ -0,0 +1,4 @@ +TERMUX_SUBPKG_DESCRIPTION=".NET 10.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/dotnet10.0/dotnet-templates-10.0.subpackage.sh b/packages/dotnet10.0/dotnet-templates-10.0.subpackage.sh new file mode 100644 index 00000000000..9b8f3e85600 --- /dev/null +++ b/packages/dotnet10.0/dotnet-templates-10.0.subpackage.sh @@ -0,0 +1,4 @@ +TERMUX_SUBPKG_DESCRIPTION=".NET 10.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/dotnet10.0/dotnet.sh.in b/packages/dotnet10.0/dotnet.sh.in new file mode 100644 index 00000000000..424b5ebf25d --- /dev/null +++ b/packages/dotnet10.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/build.sh b/packages/dotnet9.0/build.sh index 5878f374e51..9ce9953bae7 100644 --- a/packages/dotnet9.0/build.sh +++ b/packages/dotnet9.0/build.sh @@ -3,6 +3,7 @@ TERMUX_PKG_DESCRIPTION=".NET 9.0" TERMUX_PKG_LICENSE="MIT" TERMUX_PKG_MAINTAINER="@truboxl" TERMUX_PKG_VERSION="9.0.12" +TERMUX_PKG_REVISION=1 _DOTNET_SDK_VERSION="9.0.113" TERMUX_PKG_SRCURL=git+https://github.com/dotnet/dotnet TERMUX_PKG_GIT_BRANCH="v${_DOTNET_SDK_VERSION}" @@ -190,6 +191,7 @@ termux_step_make() { termux_error_exit fi "${TERMUX_PKG_BUILDDIR}/.dotnet/dotnet" build-server shutdown + termux_dotnet_kill } termux_step_make_install() { diff --git a/packages/netstandard-targeting-pack-2.1/build.sh b/packages/netstandard-targeting-pack-2.1/build.sh index 98e43b0a73d..70d9709b7fb 100644 --- a/packages/netstandard-targeting-pack-2.1/build.sh +++ b/packages/netstandard-targeting-pack-2.1/build.sh @@ -3,7 +3,6 @@ TERMUX_PKG_DESCRIPTION="A metapackage for NETStandard.Library 2.1 Targeting Pack TERMUX_PKG_LICENSE="Public Domain" TERMUX_PKG_MAINTAINER="@truboxl" TERMUX_PKG_VERSION="9.0" -TERMUX_PKG_REVISION=2 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 diff --git a/scripts/build/setup/termux_setup_dotnet.sh b/scripts/build/setup/termux_setup_dotnet.sh index 057d2ba45b5..c4091e3c8f5 100644 --- a/scripts/build/setup/termux_setup_dotnet.sh +++ b/scripts/build/setup/termux_setup_dotnet.sh @@ -112,13 +112,9 @@ termux_setup_dotnet() { termux_dotnet_kill() { # when "dotnet build-server shutdown" is not enough - local dotnet_process=$(pgrep dotnet) - if [[ -n "$dotnet_process" ]]; then - echo "WARN: Dangling process, forcibly killing" - local pid - for pid in ${dotnet_process}; do - echo "${pid}: $(cat /proc/${pid}/cmdline | tr '\0' ' ')" - kill "${pid}" - done - fi + local dotnet_process + dotnet_process="$(pgrep -a dotnet)" || return 0 + echo "WARN: Dangling process, forcibly killing" + echo "${dotnet_process}" + pkill -9 dotnet || : }