addpkg(main): dotnet8.0 (#22792)

This commit is contained in:
termux-pacman-bot
2025-01-19 02:47:35 +00:00
parent 73fb213f04
commit edc672faff
24 changed files with 701 additions and 0 deletions

View File

@@ -0,0 +1,11 @@
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_DEPENDS="dotnet-host-8.0"
TERMUX_PKG_ANTI_BUILD_DEPENDS="dotnet-host-8.0"
TERMUX_PKG_AUTO_UPDATE=false
TERMUX_PKG_METAPACKAGE=true
TERMUX_PKG_PLATFORM_INDEPENDENT=true
TERMUX_PKG_SKIP_SRC_EXTRACT=true

View File

@@ -0,0 +1,26 @@
--- a/src/runtime/src/native/libs/CMakeLists.txt
+++ b/src/runtime/src/native/libs/CMakeLists.txt
@@ -115,7 +115,7 @@ add_subdirectory(System.IO.Compression.Native)
if (CLR_CMAKE_TARGET_UNIX OR CLR_CMAKE_TARGET_BROWSER OR CLR_CMAKE_TARGET_WASI)
include(configure.cmake)
- if (NOT CLR_CMAKE_TARGET_BROWSER AND NOT CLR_CMAKE_TARGET_WASI AND NOT CLR_CMAKE_TARGET_MACCATALYST AND NOT CLR_CMAKE_TARGET_IOS AND NOT CLR_CMAKE_TARGET_TVOS AND NOT CLR_CMAKE_TARGET_ANDROID)
+ if (NOT CLR_CMAKE_TARGET_BROWSER AND NOT CLR_CMAKE_TARGET_WASI AND NOT CLR_CMAKE_TARGET_MACCATALYST AND NOT CLR_CMAKE_TARGET_IOS AND NOT CLR_CMAKE_TARGET_TVOS)
add_subdirectory(System.IO.Ports.Native)
endif ()
@@ -152,13 +152,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)

View File

@@ -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 <assert.h>
#include <limits.h>
#include <errno.h>
-#if defined(TARGET_LINUX) && !defined(MFD_CLOEXEC)
+#if (defined(TARGET_LINUX) && !defined(MFD_CLOEXEC)) || defined(TARGET_ANDROID)
#include <linux/memfd.h>
#include <sys/syscall.h> // __NR_memfd_create
#define memfd_create(...) syscall(__NR_memfd_create, __VA_ARGS__)

View File

@@ -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
@@ -64,7 +64,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)
+ if (NOT CLR_CMAKE_TARGET_MACCATALYST AND NOT CLR_CMAKE_TARGET_IOS AND NOT CLR_CMAKE_TARGET_TVOS)
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})
@@ -122,7 +122,7 @@ else ()
)
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
@@ -5,7 +5,7 @@ macro(append_extra_compression_libs NativeLibsExtra)
# nothing special to link
elseif (CLR_CMAKE_TARGET_ANDROID OR HOST_ANDROID)
# need special case here since we want to link against libz.so but find_package() would resolve libz.a
- set(ZLIB_LIBRARIES z)
+ set(ZLIB_LIBRARIES z m)
elseif (CLR_CMAKE_TARGET_SUNOS OR HOST_SOLARIS)
set(ZLIB_LIBRARIES z m)
else ()

92
packages/dotnet8.0/0004-ndk-r26.patch vendored Normal file
View File

@@ -0,0 +1,92 @@
https://github.com/dotnet/runtime/commit/be5c2a28cc4a61e271d8e2c340ced5923dc7e9c1
From be5c2a28cc4a61e271d8e2c340ced5923dc7e9c1 Mon Sep 17 00:00:00 2001
From: Filip Navara <filip.navara@gmail.com>
Date: Mon, 12 Feb 2024 12:29:14 +0100
Subject: [PATCH] Fix build with Android 26 NDK (which has some nullability
annotations) (#97976)
* Fix build with Android 26 NDK (which has some nullability annotations)
* One more error in System.Security.Cryptography.Native.Android
---
.../System.Native/pal_interfaceaddresses.c | 23 +++++++++++++------
.../pal_cipher.c | 2 +-
2 files changed, 17 insertions(+), 8 deletions(-)
--- a/src/runtime/src/native/libs/System.Native/pal_interfaceaddresses.c
+++ b/src/runtime/src/native/libs/System.Native/pal_interfaceaddresses.c
@@ -117,7 +117,7 @@ static inline uint8_t mask2prefix(uint8_t* mask, int length)
static int (*getifaddrs)(struct ifaddrs**) = NULL;
static void (*freeifaddrs)(struct ifaddrs*) = NULL;
-static void try_loading_getifaddrs()
+static void try_loading_getifaddrs(void)
{
if (android_get_device_api_level() >= 24)
{
@@ -139,7 +139,7 @@ static void try_loading_getifaddrs()
}
}
-static bool ensure_getifaddrs_is_loaded()
+static bool ensure_getifaddrs_is_loaded(void)
{
static pthread_once_t getifaddrs_is_loaded = PTHREAD_ONCE_INIT;
pthread_once(&getifaddrs_is_loaded, try_loading_getifaddrs);
@@ -169,11 +169,12 @@ int32_t SystemNative_EnumerateInterfaceAddresses(void* context,
for (struct ifaddrs* current = headAddr; current != NULL; current = current->ifa_next)
{
- if (current->ifa_addr == NULL)
+ char *ifa_name = current->ifa_name;
+ if (current->ifa_addr == NULL || ifa_name == NULL)
{
continue;
}
- uint32_t interfaceIndex = if_nametoindex(current->ifa_name);
+ uint32_t interfaceIndex = if_nametoindex(ifa_name);
// ifa_name may be an aliased interface name.
// Use if_indextoname to map back to the true device name.
char actualName[IF_NAMESIZE];
@@ -376,9 +377,17 @@ int32_t SystemNative_GetNetworkInterfaces(int32_t * interfaceCount, NetworkInter
while (ifaddrsEntry != NULL)
{
+ char *ifa_name = ifaddrsEntry->ifa_name;
+
+ if (ifa_name == NULL)
+ {
+ ifaddrsEntry = ifaddrsEntry->ifa_next;
+ continue;
+ }
+
//current = NULL;
nii = NULL;
- uint ifindex = if_nametoindex(ifaddrsEntry->ifa_name);
+ uint ifindex = if_nametoindex(ifa_name);
for (index = 0; index < (int)ifcount; index ++)
{
if (((NetworkInterfaceInfo*)memoryBlock)[index].InterfaceIndex == ifindex)
@@ -393,8 +402,8 @@ int32_t SystemNative_GetNetworkInterfaces(int32_t * interfaceCount, NetworkInter
// We git new interface.
nii = &((NetworkInterfaceInfo*)memoryBlock)[ifcount++];
- memcpy(nii->Name, ifaddrsEntry->ifa_name, sizeof(nii->Name));
- nii->InterfaceIndex = if_nametoindex(ifaddrsEntry->ifa_name);
+ memcpy(nii->Name, ifa_name, sizeof(nii->Name));
+ nii->InterfaceIndex = ifindex;
nii->Speed = -1;
nii->HardwareType = ((ifaddrsEntry->ifa_flags & IFF_LOOPBACK) == IFF_LOOPBACK) ? NetworkInterfaceType_Loopback : NetworkInterfaceType_Unknown;
--- a/src/runtime/src/native/libs/System.Security.Cryptography.Native.Android/pal_cipher.c
+++ b/src/runtime/src/native/libs/System.Security.Cryptography.Native.Android/pal_cipher.c
@@ -20,7 +20,7 @@ typedef struct CipherInfo
} CipherInfo;
#define DEFINE_CIPHER(cipherId, width, javaName, flags) \
-CipherInfo* AndroidCryptoNative_ ## cipherId() \
+CipherInfo* AndroidCryptoNative_ ## cipherId(void) \
{ \
static CipherInfo info = { flags, width, javaName }; \
return &info; \

View File

@@ -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

View File

@@ -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

View File

@@ -0,0 +1,20 @@
https://git.alpinelinux.org/aports/plain/community/dotnet8-runtime/aspire_fix-gitinfo-target.patch
--- a/src/aspire/Directory.Build.targets.orig
+++ b/src/aspire/Directory.Build.targets
@@ -6,13 +6,12 @@
<PackageReadmeFile Condition="'$(PackageReadmeFile)' == '' And '$(ReadMeExists)' == 'true'">README.md</PackageReadmeFile>
</PropertyGroup>
- <Import Condition="'$(SampleProject)' == 'true' or '$(CI)' != 'true' " Project="eng\Versions.dev.targets" />
- <Import Condition="'$(SampleProject)' != 'true' and '$(CI)' == 'true' " Project="eng\Versions.targets" />
+ <Import Project="eng\Versions.dev.targets" />
<Import Project="Sdk.targets" Sdk="Microsoft.DotNet.Arcade.Sdk" />
<ItemGroup Condition="'$(ReadMeExists)' == 'true'">
<None Include="$(ReadMePath)" Pack="true" PackagePath="\" />
</ItemGroup>
-
+
</Project>

View File

@@ -0,0 +1,4 @@
TERMUX_SUBPKG_DESCRIPTION="ASP.NET Core 8.0 Runtime"
TERMUX_SUBPKG_DEPEND_ON_PARENT=false
TERMUX_SUBPKG_DEPENDS="dotnet-runtime-8.0"
TERMUX_SUBPKG_INCLUDE=$(cat "${TERMUX_PKG_TMPDIR}"/aspnetcore-runtime.txt)

View File

@@ -0,0 +1,4 @@
TERMUX_SUBPKG_DESCRIPTION="ASP.NET Core 8.0 Runtime Managed Debug Symbols"
TERMUX_SUBPKG_DEPEND_ON_PARENT=false
TERMUX_SUBPKG_DEPENDS="aspnetcore-runtime-8.0"
TERMUX_SUBPKG_INCLUDE=$(cat "${TERMUX_PKG_TMPDIR}"/aspnetcore-runtime-dbg.txt)

View File

@@ -0,0 +1,4 @@
TERMUX_SUBPKG_DESCRIPTION="ASP.NET Core 8.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)

337
packages/dotnet8.0/build.sh vendored Normal file
View File

@@ -0,0 +1,337 @@
TERMUX_PKG_HOMEPAGE=https://dotnet.microsoft.com/en-us/
TERMUX_PKG_DESCRIPTION=".NET 8.0"
TERMUX_PKG_LICENSE="MIT"
TERMUX_PKG_MAINTAINER="@truboxl"
TERMUX_PKG_VERSION="8.0.12"
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-8.0"
TERMUX_PKG_BUILD_IN_SRC=true
TERMUX_PKG_NO_STATICSPLIT=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.sh
}
termux_step_pre_configure() {
# this is a workaround for build-all.sh
TERMUX_PKG_DEPENDS="aspnetcore-runtime-8.0, dotnet-host, dotnet-runtime-8.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 \
-- \
/p:Configuration=${CONFIG} \
/p:OverrideTargetRid=linux-bionic-${arch}
}
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/x64" -type f \( -name "*.tar.gz" -o -name "*.zip" \) -exec cp -fv "{}" "${TERMUX_PREFIX}/opt/${TERMUX_PKG_NAME}" \;
# TODO fix hardcode in source, fixed in dotnet9.0
# extract tarball
tar -xf "${TERMUX_PKG_BUILDDIR}/artifacts/x64/${CONFIG}"/dotnet-sdk-*.tar.gz -C "${_DOTNET_ROOT}"
tar -xf "${TERMUX_PKG_BUILDDIR}/artifacts/x64/${CONFIG}"/dotnet-symbols-sdk-*.tar.gz -C "${_DOTNET_ROOT}"
# TODO fix hardcode in source, fixed in dotnet9.0
# needed to fix default build target
echo "INFO: Patching Microsoft.NETCoreSdk.BundledVersions.props"
grep "<NETCoreSdkRuntimeIdentifier>" -nH "${_DOTNET_ROOT}"/sdk/*/Microsoft.NETCoreSdk.BundledVersions.props
grep "<NETCoreSdkPortableRuntimeIdentifier>" -nH "${_DOTNET_ROOT}"/sdk/*/Microsoft.NETCoreSdk.BundledVersions.props
sed \
-e "s|<NETCoreSdkRuntimeIdentifier>.*|<NETCoreSdkRuntimeIdentifier>linux-bionic-${arch}</NETCoreSdkRuntimeIdentifier>|" \
-e "s|<NETCoreSdkPortableRuntimeIdentifier>.*|<NETCoreSdkPortableRuntimeIdentifier>linux-bionic-${arch}</NETCoreSdkPortableRuntimeIdentifier>|" \
-i "${_DOTNET_ROOT}"/sdk/*/Microsoft.NETCoreSdk.BundledVersions.props
grep "<NETCoreSdkRuntimeIdentifier>" -nH "${_DOTNET_ROOT}"/sdk/*/Microsoft.NETCoreSdk.BundledVersions.props
grep "<NETCoreSdkPortableRuntimeIdentifier>" -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/dotnet8.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/8.0.* \
\( -type f -o -type l \) ! -name "*.pdb" | sort \
> "${TERMUX_PKG_TMPDIR}"/aspnetcore-runtime.txt
find \
lib/dotnet/shared/Microsoft.AspNetCore.App/8.0.* \
\( -type f -o -type l \) -name "*.pdb" | sort \
> "${TERMUX_PKG_TMPDIR}"/aspnetcore-runtime-dbg.txt
find \
lib/dotnet/packs/Microsoft.AspNetCore.App.Ref/8.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}/8.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/8.0.* \
\( -type f -o -type l \) | sort \
> "${TERMUX_PKG_TMPDIR}"/dotnet-hostfxr.txt
find \
lib/dotnet/shared/Microsoft.NETCore.App/8.0.* \
\( -type f -o -type l \) ! -name "*.pdb" | sort \
> "${TERMUX_PKG_TMPDIR}"/dotnet-runtime.txt
find \
lib/dotnet/shared/Microsoft.NETCore.App/8.0.* \
\( -type f -o -type l \) -name "*.pdb" | sort \
> "${TERMUX_PKG_TMPDIR}"/dotnet-runtime-dbg.txt
find \
lib/dotnet/metadata/workloads/8.0.* \
lib/dotnet/packs/Microsoft.AspNetCore.App.Runtime.linux-bionic-${arch}/8.0.* \
lib/dotnet/packs/Microsoft.NETCore.App.Runtime.linux-bionic-${arch}/8.0.* \
lib/dotnet/sdk/8.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}/8.0.* \
lib/dotnet/packs/Microsoft.NETCore.App.Runtime.linux-bionic-${arch}/8.0.* \
lib/dotnet/sdk/8.0.* \
\( -type f -o -type l \) -name "*.pdb" | sort \
> "${TERMUX_PKG_TMPDIR}"/dotnet-sdk-dbg.txt
find \
lib/dotnet/packs/Microsoft.NETCore.App.Ref/8.0.* \
\( -type f -o -type l \) | sort \
> "${TERMUX_PKG_TMPDIR}"/dotnet-targeting-pack.txt
find \
lib/dotnet/templates/8.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/dotnet8-stage0/APKBUILD
# https://git.alpinelinux.org/aports/tree/community/dotnet8-runtime/APKBUILD
# https://git.alpinelinux.org/aports/tree/community/dotnet8-sdk/APKBUILD
# https://src.fedoraproject.org/rpms/dotnet8.0/blob/rawhide/f/dotnet8.0.spec
# https://git.launchpad.net/ubuntu/+source/dotnet8/tree/debian/rules
# https://gitlab.archlinux.org/archlinux/packaging/packages/dotnet-core/-/blob/main/PKGBUILD

View File

@@ -0,0 +1,3 @@
TERMUX_SUBPKG_DESCRIPTION=".NET 8.0 Targeting Pack"
TERMUX_SUBPKG_DEPEND_ON_PARENT=false
TERMUX_SUBPKG_INCLUDE=$(cat "${TERMUX_PKG_TMPDIR}"/dotnet-apphost-pack.txt)

View File

@@ -0,0 +1,3 @@
TERMUX_SUBPKG_DESCRIPTION=".NET 8.0 Host"
TERMUX_SUBPKG_DEPEND_ON_PARENT=false
TERMUX_SUBPKG_INCLUDE=$(cat "${TERMUX_PKG_TMPDIR}"/dotnet-host.txt)

View File

@@ -0,0 +1,4 @@
TERMUX_SUBPKG_DESCRIPTION=".NET 8.0 Host Resolver"
TERMUX_SUBPKG_DEPEND_ON_PARENT=false
TERMUX_SUBPKG_DEPENDS="dotnet-host"
TERMUX_SUBPKG_INCLUDE=$(cat "${TERMUX_PKG_TMPDIR}"/dotnet-hostfxr.txt)

View File

@@ -0,0 +1,4 @@
TERMUX_SUBPKG_DESCRIPTION=".NET 8.0 Runtime"
TERMUX_SUBPKG_DEPEND_ON_PARENT=false
TERMUX_SUBPKG_DEPENDS="dotnet-hostfxr-8.0, libicu, openssl, zlib"
TERMUX_SUBPKG_INCLUDE=$(cat "${TERMUX_PKG_TMPDIR}"/dotnet-runtime.txt)

View File

@@ -0,0 +1,4 @@
TERMUX_SUBPKG_DESCRIPTION=".NET 8.0 Runtime Managed Debug Symbols"
TERMUX_SUBPKG_DEPEND_ON_PARENT=false
TERMUX_SUBPKG_DEPENDS="dotnet-runtime-8.0"
TERMUX_SUBPKG_INCLUDE=$(cat "${TERMUX_PKG_TMPDIR}"/dotnet-runtime-dbg.txt)

View File

@@ -0,0 +1,31 @@
TERMUX_SUBPKG_DESCRIPTION=".NET 8.0 SDK"
TERMUX_SUBPKG_DEPEND_ON_PARENT=false
TERMUX_SUBPKG_DEPENDS="aspnetcore-runtime-8.0, aspnetcore-targeting-pack-8.0, dotnet-apphost-pack-8.0, dotnet-runtime-8.0, dotnet-targeting-pack-8.0, dotnet-templates-8.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
}

View File

@@ -0,0 +1,4 @@
TERMUX_SUBPKG_DESCRIPTION=".NET 8.0 SDK Managed Debug Symbols"
TERMUX_SUBPKG_DEPEND_ON_PARENT=false
TERMUX_SUBPKG_DEPENDS="dotnet-sdk-8.0"
TERMUX_SUBPKG_INCLUDE=$(cat "${TERMUX_PKG_TMPDIR}"/dotnet-sdk-dbg.txt)

View File

@@ -0,0 +1,4 @@
TERMUX_SUBPKG_DESCRIPTION=".NET 8.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)

View File

@@ -0,0 +1,4 @@
TERMUX_SUBPKG_DESCRIPTION=".NET 8.0 Templates"
TERMUX_SUBPKG_DEPEND_ON_PARENT=false
TERMUX_SUBPKG_DEPENDS="dotnet-host"
TERMUX_SUBPKG_INCLUDE=$(cat "${TERMUX_PKG_TMPDIR}"/dotnet-templates.txt)

13
packages/dotnet8.0/dotnet.sh.in vendored Normal file
View File

@@ -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"

View File

@@ -0,0 +1,4 @@
TERMUX_SUBPKG_DESCRIPTION="NETStandard.Library 2.1 Targeting Pack (.NET 8.0)"
TERMUX_SUBPKG_DEPEND_ON_PARENT=false
TERMUX_SUBPKG_DEPENDS="dotnet-host"
TERMUX_SUBPKG_INCLUDE=$(cat "${TERMUX_PKG_TMPDIR}"/netstandard-targeting-pack-2.1.txt)

View File

@@ -0,0 +1,11 @@
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_DEPENDS="netstandard-targeting-pack-2.1-8.0"
TERMUX_PKG_ANTI_BUILD_DEPENDS="netstandard-targeting-pack-2.1-8.0"
TERMUX_PKG_AUTO_UPDATE=false
TERMUX_PKG_METAPACKAGE=true
TERMUX_PKG_PLATFORM_INDEPENDENT=true
TERMUX_PKG_SKIP_SRC_EXTRACT=true