From 46a671c2afe098eb84888398a9f777cb578f76fc Mon Sep 17 00:00:00 2001
From: ChanTsune <41658782+ChanTsune@users.noreply.github.com>
Date: Thu, 17 Oct 2024 23:19:42 +0900
Subject: [PATCH] Initial support for FreeBSD
#385
---
src/Directory.Build.props | 7 +++++++
src/Runner.Common/Constants.cs | 5 ++++-
src/Runner.Common/Runner.Common.csproj | 2 +-
src/Runner.Listener/Configuration/ConfigurationManager.cs | 2 +-
src/Runner.Listener/Configuration/RSAFileKeyManager.cs | 2 +-
src/Runner.Listener/Configuration/ServiceControlManager.cs | 2 +-
src/Runner.Listener/Runner.Listener.csproj | 2 +-
src/Runner.Listener/SelfUpdater.cs | 2 +-
src/Runner.Listener/SelfUpdaterV2.cs | 2 +-
src/Runner.PluginHost/Runner.PluginHost.csproj | 2 +-
src/Runner.Plugins/Runner.Plugins.csproj | 2 +-
src/Runner.Sdk/Runner.Sdk.csproj | 2 +-
src/Runner.Worker/Runner.Worker.csproj | 2 +-
src/Sdk/Sdk.csproj | 2 +-
src/Test/Test.csproj | 2 +-
src/dev.sh | 6 ++++--
src/global.json | 2 +-
17 files changed, 29 insertions(+), 17 deletions(-)
diff --git a/src/Directory.Build.props b/src/Directory.Build.props
index 9db5faca37a..d43bb90a1d4 100644
--- a/src/Directory.Build.props
+++ b/src/Directory.Build.props
@@ -4,6 +4,7 @@
Windows
OSX
Linux
+ FreeBSD
@@ -16,6 +17,9 @@
$(DefineConstants);OS_LINUX
+
+ $(DefineConstants);OS_FREEBSD
+
@@ -44,6 +48,9 @@
$(DefineConstants);ARM64
+
+ $(DefineConstants);X64
+
diff --git a/src/Runner.Common/Constants.cs b/src/Runner.Common/Constants.cs
index 2c20d1b16fe..7fe21e4ffc2 100644
--- a/src/Runner.Common/Constants.cs
+++ b/src/Runner.Common/Constants.cs
@@ -50,7 +50,8 @@ public enum OSPlatform
{
OSX,
Linux,
- Windows
+ Windows,
+ FreeBSD
}
public enum Architecture
@@ -69,6 +70,8 @@ public static class Runner
public static readonly OSPlatform Platform = OSPlatform.OSX;
#elif OS_WINDOWS
public static readonly OSPlatform Platform = OSPlatform.Windows;
+#elif OS_FREEBSD
+ public static readonly OSPlatform Platform = OSPlatform.FreeBSD;
#else
public static readonly OSPlatform Platform = OSPlatform.Linux;
#endif
diff --git a/src/Runner.Common/Runner.Common.csproj b/src/Runner.Common/Runner.Common.csproj
index 6c4635626a2..ff4dc1b99ff 100644
--- a/src/Runner.Common/Runner.Common.csproj
+++ b/src/Runner.Common/Runner.Common.csproj
@@ -3,7 +3,7 @@
net8.0
Library
- win-x64;win-x86;linux-x64;linux-arm64;linux-arm;osx-x64;osx-arm64;win-arm64
+ win-x64;win-x86;linux-x64;linux-arm64;linux-arm;osx-x64;osx-arm64;win-arm64;freebsd-x64
true
NU1701;NU1603;SYSLIB0050;SYSLIB0051
$(Version)
diff --git a/src/Runner.Listener/Configuration/ConfigurationManager.cs b/src/Runner.Listener/Configuration/ConfigurationManager.cs
index 05b93cb58bb..7dea9868d60 100644
--- a/src/Runner.Listener/Configuration/ConfigurationManager.cs
+++ b/src/Runner.Listener/Configuration/ConfigurationManager.cs
@@ -427,7 +427,7 @@ public async Task ConfigureAsync(CommandSettings command)
serviceControlManager.ConfigureService(runnerSettings, command);
}
-#elif OS_LINUX || OS_OSX
+#elif OS_LINUX || OS_OSX || OS_FREEBSD
// generate service config script for OSX and Linux, GenerateScripts() will no-opt on windows.
var serviceControlManager = HostContext.GetService();
serviceControlManager.GenerateScripts(runnerSettings);
diff --git a/src/Runner.Listener/Configuration/RSAFileKeyManager.cs b/src/Runner.Listener/Configuration/RSAFileKeyManager.cs
index 532128a5700..3562cfb67b8 100644
--- a/src/Runner.Listener/Configuration/RSAFileKeyManager.cs
+++ b/src/Runner.Listener/Configuration/RSAFileKeyManager.cs
@@ -1,4 +1,4 @@
-#if OS_LINUX || OS_OSX
+#if OS_LINUX || OS_OSX || OS_FREEBSD
using System;
using System.IO;
using System.Security.Cryptography;
diff --git a/src/Runner.Listener/Configuration/ServiceControlManager.cs b/src/Runner.Listener/Configuration/ServiceControlManager.cs
index 6129034eb31..1b8e500838f 100644
--- a/src/Runner.Listener/Configuration/ServiceControlManager.cs
+++ b/src/Runner.Listener/Configuration/ServiceControlManager.cs
@@ -76,7 +76,7 @@ public void CalculateServiceName(RunnerSettings settings, string serviceNamePatt
Trace.Info($"Service name '{serviceName}' display name '{serviceDisplayName}' will be used for service configuration.");
}
-#if (OS_LINUX || OS_OSX)
+#if (OS_LINUX || OS_OSX || OS_FREEBSD)
const int MaxServiceNameLength = 150;
const int MaxRepoOrgCharacters = 70;
#elif OS_WINDOWS
diff --git a/src/Runner.Listener/Runner.Listener.csproj b/src/Runner.Listener/Runner.Listener.csproj
index afd528128a5..ad86bb70dbc 100644
--- a/src/Runner.Listener/Runner.Listener.csproj
+++ b/src/Runner.Listener/Runner.Listener.csproj
@@ -3,7 +3,7 @@
net8.0
Exe
- win-x64;win-x86;linux-x64;linux-arm64;linux-arm;osx-x64;osx-arm64;win-arm64
+ win-x64;win-x86;linux-x64;linux-arm64;linux-arm;osx-x64;osx-arm64;win-arm64;freebsd-x64
true
true
NU1701;NU1603;SYSLIB0050;SYSLIB0051
diff --git a/src/Runner.Listener/SelfUpdater.cs b/src/Runner.Listener/SelfUpdater.cs
index 6ebeebd8270..6cdd9b757db 100644
--- a/src/Runner.Listener/SelfUpdater.cs
+++ b/src/Runner.Listener/SelfUpdater.cs
@@ -103,7 +103,7 @@ public async Task SelfUpdate(AgentRefreshMessage updateMessage, IJobDispat
#if OS_WINDOWS
invokeScript.StartInfo.FileName = WhichUtil.Which("cmd.exe", trace: Trace);
invokeScript.StartInfo.Arguments = $"/c \"{updateScript}\"";
-#elif (OS_OSX || OS_LINUX)
+#elif (OS_OSX || OS_LINUX || OS_FREEBSD)
invokeScript.StartInfo.FileName = WhichUtil.Which("bash", trace: Trace);
invokeScript.StartInfo.Arguments = $"\"{updateScript}\"";
#endif
diff --git a/src/Runner.Listener/SelfUpdaterV2.cs b/src/Runner.Listener/SelfUpdaterV2.cs
index b64619b69e5..25c6d27481f 100644
--- a/src/Runner.Listener/SelfUpdaterV2.cs
+++ b/src/Runner.Listener/SelfUpdaterV2.cs
@@ -103,7 +103,7 @@ public async Task SelfUpdate(RunnerRefreshMessage updateMessage, IJobDispa
#if OS_WINDOWS
invokeScript.StartInfo.FileName = WhichUtil.Which("cmd.exe", trace: Trace);
invokeScript.StartInfo.Arguments = $"/c \"{updateScript}\"";
-#elif (OS_OSX || OS_LINUX)
+#elif (OS_OSX || OS_LINUX || OS_FREEBSD)
invokeScript.StartInfo.FileName = WhichUtil.Which("bash", trace: Trace);
invokeScript.StartInfo.Arguments = $"\"{updateScript}\"";
#endif
diff --git a/src/Runner.PluginHost/Runner.PluginHost.csproj b/src/Runner.PluginHost/Runner.PluginHost.csproj
index 81a8d2e4304..b56650819f1 100644
--- a/src/Runner.PluginHost/Runner.PluginHost.csproj
+++ b/src/Runner.PluginHost/Runner.PluginHost.csproj
@@ -3,7 +3,7 @@
net8.0
Exe
- win-x64;win-x86;linux-x64;linux-arm64;linux-arm;osx-x64;osx-arm64;win-arm64
+ win-x64;win-x86;linux-x64;linux-arm64;linux-arm;osx-x64;osx-arm64;win-arm64;freebsd-x64
true
true
NU1701;NU1603;SYSLIB0050;SYSLIB0051
diff --git a/src/Runner.Plugins/Runner.Plugins.csproj b/src/Runner.Plugins/Runner.Plugins.csproj
index a786cf1cd1b..686f2f09102 100644
--- a/src/Runner.Plugins/Runner.Plugins.csproj
+++ b/src/Runner.Plugins/Runner.Plugins.csproj
@@ -3,7 +3,7 @@
net8.0
Library
- win-x64;win-x86;linux-x64;linux-arm64;linux-arm;osx-x64;osx-arm64;win-arm64
+ win-x64;win-x86;linux-x64;linux-arm64;linux-arm;osx-x64;osx-arm64;win-arm64;freebsd-x64
true
true
NU1701;NU1603;SYSLIB0050;SYSLIB0051
diff --git a/src/Runner.Sdk/Runner.Sdk.csproj b/src/Runner.Sdk/Runner.Sdk.csproj
index 55dbf12627c..5a26c7e28f0 100644
--- a/src/Runner.Sdk/Runner.Sdk.csproj
+++ b/src/Runner.Sdk/Runner.Sdk.csproj
@@ -3,7 +3,7 @@
net8.0
Library
- win-x64;win-x86;linux-x64;linux-arm64;linux-arm;osx-x64;osx-arm64;win-arm64
+ win-x64;win-x86;linux-x64;linux-arm64;linux-arm;osx-x64;osx-arm64;win-arm64;freebsd-x64
true
true
NU1701;NU1603;SYSLIB0050;SYSLIB0051
diff --git a/src/Runner.Worker/Runner.Worker.csproj b/src/Runner.Worker/Runner.Worker.csproj
index 53c1610df3e..ff20d8f0229 100644
--- a/src/Runner.Worker/Runner.Worker.csproj
+++ b/src/Runner.Worker/Runner.Worker.csproj
@@ -3,7 +3,7 @@
net8.0
Exe
- win-x64;win-x86;linux-x64;linux-arm64;linux-arm;osx-x64;osx-arm64;win-arm64
+ win-x64;win-x86;linux-x64;linux-arm64;linux-arm;osx-x64;osx-arm64;win-arm64;freebsd-x64
true
true
NU1701;NU1603;SYSLIB0050;SYSLIB0051
diff --git a/src/Sdk/Sdk.csproj b/src/Sdk/Sdk.csproj
index 7ba739498a4..7f79808d9c0 100644
--- a/src/Sdk/Sdk.csproj
+++ b/src/Sdk/Sdk.csproj
@@ -3,7 +3,7 @@
net8.0
Library
- win-x64;win-x86;linux-x64;linux-arm64;linux-arm;osx-x64;osx-arm64;win-arm64
+ win-x64;win-x86;linux-x64;linux-arm64;linux-arm;osx-x64;osx-arm64;win-arm64;freebsd-x64
true
NU1701;NU1603;SYSLIB0050;SYSLIB0051
diff --git a/src/Test/Test.csproj b/src/Test/Test.csproj
index aebe242096f..274a86c478b 100644
--- a/src/Test/Test.csproj
+++ b/src/Test/Test.csproj
@@ -1,7 +1,7 @@
net8.0
- win-x64;win-x86;linux-x64;linux-arm64;linux-arm;osx-x64;osx-arm64;win-arm64
+ win-x64;win-x86;linux-x64;linux-arm64;linux-arm;osx-x64;osx-arm64;win-arm64;freebsd-x64
true
NU1701;NU1603;NU1603;xUnit2013;SYSLIB0050;SYSLIB0051
diff --git a/src/dev.sh b/src/dev.sh
index 795c135a232..378fc31e238 100755
--- a/src/dev.sh
+++ b/src/dev.sh
@@ -35,7 +35,7 @@ if [[ "$DEV_CONFIG" == "Release" ]]; then
fi
CURRENT_PLATFORM="windows"
-if [[ ($(uname) == "Linux") || ($(uname) == "Darwin") ]]; then
+if [[ ($(uname) == "Linux") || ($(uname) == "Darwin") || ($(uname) == "FreeBSD")]]; then
CURRENT_PLATFORM=$(uname | awk '{print tolower($0)}')
fi
@@ -64,6 +64,8 @@ elif [[ "$CURRENT_PLATFORM" == 'darwin' ]]; then
arm64) RUNTIME_ID="osx-arm64";;
esac
fi
+elif [[ "$CURRENT_PLATFORM" == 'freebsd' ]]; then
+ RUNTIME_ID='freebsd-x64'
fi
if [[ -n "$DEV_TARGET_RUNTIME" ]]; then
@@ -183,7 +185,7 @@ function package ()
pushd "$PACKAGE_DIR" > /dev/null
- if [[ ("$CURRENT_PLATFORM" == "linux") || ("$CURRENT_PLATFORM" == "darwin") ]]; then
+ if [[ ("$CURRENT_PLATFORM" == "linux") || ("$CURRENT_PLATFORM" == "darwin") || ("$CURRENT_PLATFORM" == "freebsd")]]; then
tar_name="${runner_pkg_name}.tar.gz"
echo "Creating $tar_name in ${LAYOUT_DIR}"
tar -czf "${tar_name}" -C "${LAYOUT_DIR}" .
diff --git a/src/global.json b/src/global.json
index ff3b5e098b3..70cac788c5a 100644
--- a/src/global.json
+++ b/src/global.json
@@ -1,5 +1,5 @@
{
"sdk": {
- "version": "8.0.403"
+ "version": "8.0.106"
}
}