diff mbox series

[v3] package/dotnet-runtime-prebuilt: new package

Message ID 20240701193420.2119084-1-giulio.benetti@benettiengineering.com
State New
Headers show
Series [v3] package/dotnet-runtime-prebuilt: new package | expand

Commit Message

Giulio Benetti July 1, 2024, 7:34 p.m. UTC
From: Giulio Benetti <giulio.benetti+tekvox@benettiengineering.com>

Add pre-built .NET Core Runtime Prebuilt 8.0.6 binaries to execute .NET
executables on Linux. Version 8.0.6 is the latest LTS version. Let's simply
download and extract specific tarball for aarch64, arm(eabihf) and x64
architectures and glibc/musl libc. Let's also:
* add /etc/dotnet/install_location file to point where dotnet runtime is
* add a script to export 'dotnet' to PATH and native libraries to
  LD_LIBRARY_PATH to avoid missing dependencies on runtime

Cc: Jim Reinhart <jimr@tekvox.com>
Cc: James Autry <jautry@tekvox.com>
Cc: Matthew Maron <matthewm@tekvox.com>
Signed-off-by: Giulio Benetti <giulio.benetti+tekvox@benettiengineering.com>
---
V1->V2:
* add depends on BR2_INSTALL_LIBSTDCPP and drop select BR2_PACKAGE_LTTNG_LIBUST
V2->V3:
* drop DOTNET_RUNTIME_PREBUILT_IDENTIFIER check since it breaks entire Buildroot
building when architecture is supported but package is not selected. Basically
it's a testing leftover
---
 DEVELOPERS                                    |  1 +
 package/Config.in                             |  1 +
 package/dotnet-runtime-prebuilt/Config.in     | 29 ++++++++++
 .../dotnet-runtime-prebuilt.hash              |  8 +++
 .../dotnet-runtime-prebuilt.mk                | 58 +++++++++++++++++++
 .../dotnet-runtime-prebuilt.sh                |  2 +
 6 files changed, 99 insertions(+)
 create mode 100644 package/dotnet-runtime-prebuilt/Config.in
 create mode 100644 package/dotnet-runtime-prebuilt/dotnet-runtime-prebuilt.hash
 create mode 100644 package/dotnet-runtime-prebuilt/dotnet-runtime-prebuilt.mk
 create mode 100644 package/dotnet-runtime-prebuilt/dotnet-runtime-prebuilt.sh
diff mbox series

Patch

diff --git a/DEVELOPERS b/DEVELOPERS
index 551ff2dd0d..291a7e004e 100644
--- a/DEVELOPERS
+++ b/DEVELOPERS
@@ -1243,6 +1243,7 @@  F:	configs/rockpro64_defconfig
 F:	package/at/
 F:	package/binutils/
 F:	package/cryptsetup/
+F:	package/dotnet-runtime-prebuilt/
 F:	package/dotnet6-runtime/
 F:	package/erlang-jiffy/
 F:	package/esp-hosted/
diff --git a/package/Config.in b/package/Config.in
index 59a4512b52..ec7b5ef1f5 100644
--- a/package/Config.in
+++ b/package/Config.in
@@ -662,6 +662,7 @@  menu "Interpreter languages and scripting"
 	source "package/4th/Config.in"
 	source "package/dotnet6-runtime/Config.in"
 	source "package/dotnet8-runtime/Config.in"
+	source "package/dotnet-runtime-prebuilt/Config.in"
 	source "package/enscript/Config.in"
 	source "package/erlang/Config.in"
 if BR2_PACKAGE_ERLANG
diff --git a/package/dotnet-runtime-prebuilt/Config.in b/package/dotnet-runtime-prebuilt/Config.in
new file mode 100644
index 0000000000..2e2b54d0ac
--- /dev/null
+++ b/package/dotnet-runtime-prebuilt/Config.in
@@ -0,0 +1,29 @@ 
+config BR2_PACKAGE_DOTNET_RUNTIME_PREBUILT_ARCH_SUPPORTS
+	bool
+	default y if BR2_aarch64
+	default y if (BR2_arm && BR2_ARM_EABIHF)
+	default y if BR2_x86_64
+	depends on BR2_USE_MMU # fork()
+
+config BR2_PACKAGE_DOTNET_RUNTIME_PREBUILT
+	bool "dotnet-runtime-prebuilt"
+	depends on BR2_TOOLCHAIN_USES_GLIBC || BR2_TOOLCHAIN_USES_MUSL
+	depends on BR2_TOOLCHAIN_HAS_THREADS
+	depends on BR2_INSTALL_LIBSTDCPP
+	depends on !BR2_STATIC_LIBS
+	depends on BR2_PACKAGE_DOTNET_RUNTIME_PREBUILT_ARCH_SUPPORTS
+	select BR2_PACKAGE_HOST_CMAKE
+	select BR2_PACKAGE_ICU
+	select BR2_PACKAGE_LIBCURL
+	select BR2_PACKAGE_LIBKRB5
+	select BR2_PACKAGE_LIBZLIB
+	select BR2_PACKAGE_OPENSSL
+	help
+	  .NET Core 8 Runtime Prebuilt
+
+	  https://dotnet.microsoft.com/download/dotnet-core/8.0
+
+comment "dotnet-runtime needs a toolchain w/ glibc or musl and threads"
+	depends on BR2_PACKAGE_DOTNET8_RUNTIME_PREBUILT_ARCH_SUPPORTS
+	depends on !BR2_TOOLCHAIN_USES_GLIBC && !BR2_TOOLCHAIN_USES_MUSL
+	depends on BR2_STATIC_LIBS || !BR2_TOOLCHAIN_HAS_THREADS
diff --git a/package/dotnet-runtime-prebuilt/dotnet-runtime-prebuilt.hash b/package/dotnet-runtime-prebuilt/dotnet-runtime-prebuilt.hash
new file mode 100644
index 0000000000..6ff15ed121
--- /dev/null
+++ b/package/dotnet-runtime-prebuilt/dotnet-runtime-prebuilt.hash
@@ -0,0 +1,8 @@ 
+# Locally calculated
+sha256  811b3d6d052e0d37c5cb2f6746cb950ae7c87a1c5082897a27bcd9258c94de66  dotnet-runtime-8.0.6-linux-arm.tar.gz
+sha256  0c1355dfba7b0e354294fd202274e4fa1838b93afcc180ecf667e25e5d1b7df6  dotnet-runtime-8.0.6-linux-arm64.tar.gz
+sha256  cfecba75d6497e14a06f04096c0be6bb57938ef23abd3c5ff6639bd999dbb9a1  dotnet-runtime-8.0.6-linux-musl-arm64.tar.gz
+sha256  566c219fb59864c23333a254092c5b9644717164ad047050ccad06b79f710700  dotnet-runtime-8.0.6-linux-musl-arm.tar.gz
+sha256  15c7219c2630d81131c0b47a7c6577f0f76f56ea0ed8dd337748d0b5929834d9  dotnet-runtime-8.0.6-linux-musl-x64.tar.gz
+sha256  b29b4e02b622cf0ff4581b0a96824b74a6690e97b95158a2e3d8fb43342dadfd  dotnet-runtime-8.0.6-linux-x64.tar.gz
+sha256  cfc21f5e8bd655ae997eec916138b707b1d290b83272c02a95c9f821b8c87310  LICENSE.txt
diff --git a/package/dotnet-runtime-prebuilt/dotnet-runtime-prebuilt.mk b/package/dotnet-runtime-prebuilt/dotnet-runtime-prebuilt.mk
new file mode 100644
index 0000000000..13aa9a1741
--- /dev/null
+++ b/package/dotnet-runtime-prebuilt/dotnet-runtime-prebuilt.mk
@@ -0,0 +1,58 @@ 
+################################################################################
+#
+# dotnet-runtime-prebuilt
+#
+################################################################################
+
+DOTNET_RUNTIME_PREBUILT_VERSION = 8.0.6
+DOTNET_RUNTIME_PREBUILT_LICENSE = MIT
+DOTNET_RUNTIME_PREBUILT_LICENSE_FILES = LICENSE.txt
+
+# Set download URL and runtime identifier
+# See https://docs.microsoft.com/en-us/dotnet/core/rid-catalog
+# for the list of supported runtimes
+# download_link="$azure_feed/Runtime/$specific_version/dotnet-runtime-$specific_version-$osname-$normalized_architecture.tar.gz"
+
+AZURE_FEED = https://dotnetcli.azureedge.net/dotnet
+DOTNET_RUNTIME_PREBUILT_SITE = $(AZURE_FEED)/Runtime/$(DOTNET_RUNTIME_PREBUILT_VERSION)
+
+ifeq ($(BR2_aarch64),y)
+ifeq ($(BR2_TOOLCHAIN_USES_MUSL),y)
+DOTNET_RUNTIME_PREBUILT_IDENTIFIER = linux-musl-arm64
+else
+DOTNET_RUNTIME_PREBUILT_IDENTIFIER = linux-arm64
+endif
+else ifeq ($(BR2_arm),y)
+ifeq ($(BR2_TOOLCHAIN_USES_MUSL),y)
+DOTNET_RUNTIME_PREBUILT_IDENTIFIER = linux-musl-arm
+else
+DOTNET_RUNTIME_PREBUILT_IDENTIFIER = linux-arm
+endif
+else ifeq ($(BR2_x86_64),y)
+ifeq ($(BR2_TOOLCHAIN_USES_MUSL),y)
+DOTNET_RUNTIME_PREBUILT_IDENTIFIER = linux-musl-x64
+else
+DOTNET_RUNTIME_PREBUILT_IDENTIFIER = linux-x64
+endif
+endif
+
+DOTNET_RUNTIME_PREBUILT_SOURCE = dotnet-runtime-$(DOTNET_RUNTIME_PREBUILT_VERSION)-$(DOTNET_RUNTIME_PREBUILT_IDENTIFIER).tar.gz
+
+# Runtime could be installed in the global location [/usr/share/dotnet] and
+# will be picked up automatically.
+# As alternative, it is possible to use the DOTNET_ROOT environment variable
+# to specify the runtime location or register the runtime location in
+# [/etc/dotnet/install_location]
+# This script will install runtime to
+# /usr/share/dotnet
+define DOTNET_RUNTIME_PREBUILT_INSTALL_TARGET_CMDS
+	cp -Rf $(@D)/. $(TARGET_DIR)/usr/share/dotnet
+	mkdir -p $(TARGET_DIR)/etc/dotnet
+	echo "/usr/share/dotnet" > $(TARGET_DIR)/etc/dotnet/install_location
+
+	# Export dotnet to PATH and libraries to LD_LIBRARY_PATH
+	$(INSTALL) -m 0755 -D $(DOTNET_RUNTIME_PREBUILT_PKGDIR)/dotnet-runtime-prebuilt.sh \
+		$(TARGET_DIR)/etc/profile.d/dotnet-runtime-prebuilt.sh
+endef
+
+$(eval $(generic-package))
diff --git a/package/dotnet-runtime-prebuilt/dotnet-runtime-prebuilt.sh b/package/dotnet-runtime-prebuilt/dotnet-runtime-prebuilt.sh
new file mode 100644
index 0000000000..b059a9c593
--- /dev/null
+++ b/package/dotnet-runtime-prebuilt/dotnet-runtime-prebuilt.sh
@@ -0,0 +1,2 @@ 
+export PATH=$PATH:/usr/share/dotnet
+export LD_LIBRARY_PATH=/usr/share/dotnet/shared/Microsoft.NETCore.App/8.0.6