Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

Initial support building the runner on FreeBSD #3512

Open
wants to merge 3 commits into
base: main
Choose a base branch
from
Open
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension


Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
10 changes: 10 additions & 0 deletions src/Directory.Build.props
Original file line number Diff line number Diff line change
@@ -6,6 +6,10 @@
<BUILD_OS Condition="'$([System.Runtime.InteropServices.RuntimeInformation]::IsOSPlatform($([System.Runtime.InteropServices.OSPlatform]::Linux)))' == 'true'">Linux</BUILD_OS>
</PropertyGroup>

<PropertyGroup Condition="'$([System.Runtime.InteropServices.RuntimeInformation]::IsOSPlatform($([System.Runtime.InteropServices.OSPlatform]::Windows)))' == 'false'">
<BUILD_OS Condition="'$([System.Runtime.InteropServices.RuntimeInformation]::IsOSPlatform($([System.Runtime.InteropServices.OSPlatform]::FreeBSD)))' == 'true'">FreeBSD</BUILD_OS>
</PropertyGroup>

<!-- Set OS vars -->
<PropertyGroup Condition="'$(BUILD_OS)' == 'Windows'">
<DefineConstants>$(DefineConstants);OS_WINDOWS</DefineConstants>
@@ -16,6 +20,9 @@
<PropertyGroup Condition="'$(BUILD_OS)' == 'Linux'">
<DefineConstants>$(DefineConstants);OS_LINUX</DefineConstants>
</PropertyGroup>
<PropertyGroup Condition="'$(BUILD_OS)' == 'FreeBSD'">
<DefineConstants>$(DefineConstants);OS_FREEBSD</DefineConstants>
</PropertyGroup>

<!-- Set Platform/bitness vars -->
<PropertyGroup Condition="'$(BUILD_OS)' == 'Windows' AND ('$(PackageRuntime)' == 'win-x64' OR '$(PackageRuntime)' == '')">
@@ -44,6 +51,9 @@
<PropertyGroup Condition="'$(BUILD_OS)' == 'Linux' AND '$(PackageRuntime)' == 'linux-arm64'">
<DefineConstants>$(DefineConstants);ARM64</DefineConstants>
</PropertyGroup>
<PropertyGroup Condition="'$(BUILD_OS)' == 'FreeBSD' AND ('$(PackageRuntime)' == 'freebsd-x64' OR '$(PackageRuntime)' == '')">
<DefineConstants>$(DefineConstants);X64</DefineConstants>
</PropertyGroup>

<!-- Set TRACE/DEBUG vars -->
<PropertyGroup>
5 changes: 4 additions & 1 deletion src/Runner.Common/Constants.cs
Original file line number Diff line number Diff line change
@@ -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
3 changes: 2 additions & 1 deletion src/Runner.Common/Runner.Common.csproj
Original file line number Diff line number Diff line change
@@ -3,7 +3,8 @@
<PropertyGroup>
<TargetFramework>net8.0</TargetFramework>
<OutputType>Library</OutputType>
<RuntimeIdentifiers>win-x64;win-x86;linux-x64;linux-arm64;linux-arm;osx-x64;osx-arm64;win-arm64</RuntimeIdentifiers>
<RuntimeIdentifiers Condition="'$(BUILD_OS)' != 'FreeBSD'">win-x64;win-x86;linux-x64;linux-arm64;linux-arm;osx-x64;osx-arm64;win-arm64</RuntimeIdentifiers>
<RuntimeIdentifiers Condition="'$(BUILD_OS)' == 'FreeBSD'">win-x64;win-x86;linux-x64;linux-arm64;linux-arm;osx-x64;osx-arm64;win-arm64;freebsd-x64</RuntimeIdentifiers>
<TargetLatestRuntimePatch>true</TargetLatestRuntimePatch>
<NoWarn>NU1701;NU1603;SYSLIB0050;SYSLIB0051</NoWarn>
<Version>$(Version)</Version>
3 changes: 3 additions & 0 deletions src/Runner.Common/Util/VarUtil.cs
Original file line number Diff line number Diff line change
@@ -12,6 +12,7 @@ public static StringComparer EnvironmentVariableKeyComparer
{
case Constants.OSPlatform.Linux:
case Constants.OSPlatform.OSX:
case Constants.OSPlatform.FreeBSD:
return StringComparer.Ordinal;
case Constants.OSPlatform.Windows:
return StringComparer.OrdinalIgnoreCase;
@@ -33,6 +34,8 @@ public static string OS
return "macOS";
case Constants.OSPlatform.Windows:
return "Windows";
case Constants.OSPlatform.FreeBSD:
return "FreeBSD";
default:
throw new NotSupportedException(); // Should never reach here.
}
Original file line number Diff line number Diff line change
@@ -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<ILinuxServiceControlManager>();
serviceControlManager.GenerateScripts(runnerSettings);
2 changes: 1 addition & 1 deletion src/Runner.Listener/Configuration/RSAFileKeyManager.cs
Original file line number Diff line number Diff line change
@@ -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;
Original file line number Diff line number Diff line change
@@ -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
7 changes: 7 additions & 0 deletions src/Runner.Listener/Program.cs
Original file line number Diff line number Diff line change
@@ -53,6 +53,13 @@ private async static Task<int> MainAsync(IHostContext context, string[] args)
return Constants.Runner.ReturnCode.TerminatedError;
}
break;
case Constants.OSPlatform.FreeBSD:
if (!RuntimeInformation.IsOSPlatform(OSPlatform.FreeBSD))
{
terminal.WriteLine("This runner version is built for FreeBSD. Please install a correct build for your OS.");
return Constants.Runner.ReturnCode.TerminatedError;
}
break;
case Constants.OSPlatform.Windows:
if (!RuntimeInformation.IsOSPlatform(OSPlatform.Windows))
{
3 changes: 2 additions & 1 deletion src/Runner.Listener/Runner.Listener.csproj
Original file line number Diff line number Diff line change
@@ -3,7 +3,8 @@
<PropertyGroup>
<TargetFramework>net8.0</TargetFramework>
<OutputType>Exe</OutputType>
<RuntimeIdentifiers>win-x64;win-x86;linux-x64;linux-arm64;linux-arm;osx-x64;osx-arm64;win-arm64</RuntimeIdentifiers>
<RuntimeIdentifiers Condition="'$(BUILD_OS)' != 'FreeBSD'">win-x64;win-x86;linux-x64;linux-arm64;linux-arm;osx-x64;osx-arm64;win-arm64</RuntimeIdentifiers>
<RuntimeIdentifiers Condition="'$(BUILD_OS)' == 'FreeBSD'">win-x64;win-x86;linux-x64;linux-arm64;linux-arm;osx-x64;osx-arm64;win-arm64;freebsd-x64</RuntimeIdentifiers>
<SelfContained>true</SelfContained>
<TargetLatestRuntimePatch>true</TargetLatestRuntimePatch>
<NoWarn>NU1701;NU1603;SYSLIB0050;SYSLIB0051</NoWarn>
2 changes: 1 addition & 1 deletion src/Runner.Listener/SelfUpdater.cs
Original file line number Diff line number Diff line change
@@ -103,7 +103,7 @@ public async Task<bool> 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
2 changes: 1 addition & 1 deletion src/Runner.Listener/SelfUpdaterV2.cs
Original file line number Diff line number Diff line change
@@ -103,7 +103,7 @@ public async Task<bool> 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
3 changes: 2 additions & 1 deletion src/Runner.PluginHost/Runner.PluginHost.csproj
Original file line number Diff line number Diff line change
@@ -3,7 +3,8 @@
<PropertyGroup>
<TargetFramework>net8.0</TargetFramework>
<OutputType>Exe</OutputType>
<RuntimeIdentifiers>win-x64;win-x86;linux-x64;linux-arm64;linux-arm;osx-x64;osx-arm64;win-arm64</RuntimeIdentifiers>
<RuntimeIdentifiers Condition="'$(BUILD_OS)' != 'FreeBSD'">win-x64;win-x86;linux-x64;linux-arm64;linux-arm;osx-x64;osx-arm64;win-arm64</RuntimeIdentifiers>
<RuntimeIdentifiers Condition="'$(BUILD_OS)' == 'FreeBSD'">win-x64;win-x86;linux-x64;linux-arm64;linux-arm;osx-x64;osx-arm64;win-arm64;freebsd-x64</RuntimeIdentifiers>
<SelfContained>true</SelfContained>
<TargetLatestRuntimePatch>true</TargetLatestRuntimePatch>
<NoWarn>NU1701;NU1603;SYSLIB0050;SYSLIB0051</NoWarn>
3 changes: 2 additions & 1 deletion src/Runner.Plugins/Runner.Plugins.csproj
Original file line number Diff line number Diff line change
@@ -3,7 +3,8 @@
<PropertyGroup>
<TargetFramework>net8.0</TargetFramework>
<OutputType>Library</OutputType>
<RuntimeIdentifiers>win-x64;win-x86;linux-x64;linux-arm64;linux-arm;osx-x64;osx-arm64;win-arm64</RuntimeIdentifiers>
<RuntimeIdentifiers Condition="'$(BUILD_OS)' != 'FreeBSD'">win-x64;win-x86;linux-x64;linux-arm64;linux-arm;osx-x64;osx-arm64;win-arm64</RuntimeIdentifiers>
<RuntimeIdentifiers Condition="'$(BUILD_OS)' == 'FreeBSD'">win-x64;win-x86;linux-x64;linux-arm64;linux-arm;osx-x64;osx-arm64;win-arm64;freebsd-x64</RuntimeIdentifiers>
<SelfContained>true</SelfContained>
<TargetLatestRuntimePatch>true</TargetLatestRuntimePatch>
<NoWarn>NU1701;NU1603;SYSLIB0050;SYSLIB0051</NoWarn>
3 changes: 2 additions & 1 deletion src/Runner.Sdk/Runner.Sdk.csproj
Original file line number Diff line number Diff line change
@@ -3,7 +3,8 @@
<PropertyGroup>
<TargetFramework>net8.0</TargetFramework>
<OutputType>Library</OutputType>
<RuntimeIdentifiers>win-x64;win-x86;linux-x64;linux-arm64;linux-arm;osx-x64;osx-arm64;win-arm64</RuntimeIdentifiers>
<RuntimeIdentifiers Condition="'$(BUILD_OS)' != 'FreeBSD'">win-x64;win-x86;linux-x64;linux-arm64;linux-arm;osx-x64;osx-arm64;win-arm64</RuntimeIdentifiers>
<RuntimeIdentifiers Condition="'$(BUILD_OS)' == 'FreeBSD'">win-x64;win-x86;linux-x64;linux-arm64;linux-arm;osx-x64;osx-arm64;win-arm64;freebsd-x64</RuntimeIdentifiers>
<SelfContained>true</SelfContained>
<TargetLatestRuntimePatch>true</TargetLatestRuntimePatch>
<NoWarn>NU1701;NU1603;SYSLIB0050;SYSLIB0051</NoWarn>
3 changes: 2 additions & 1 deletion src/Runner.Worker/Runner.Worker.csproj
Original file line number Diff line number Diff line change
@@ -3,7 +3,8 @@
<PropertyGroup>
<TargetFramework>net8.0</TargetFramework>
<OutputType>Exe</OutputType>
<RuntimeIdentifiers>win-x64;win-x86;linux-x64;linux-arm64;linux-arm;osx-x64;osx-arm64;win-arm64</RuntimeIdentifiers>
<RuntimeIdentifiers Condition="'$(BUILD_OS)' != 'FreeBSD'">win-x64;win-x86;linux-x64;linux-arm64;linux-arm;osx-x64;osx-arm64;win-arm64</RuntimeIdentifiers>
<RuntimeIdentifiers Condition="'$(BUILD_OS)' == 'FreeBSD'">win-x64;win-x86;linux-x64;linux-arm64;linux-arm;osx-x64;osx-arm64;win-arm64;freebsd-x64</RuntimeIdentifiers>
<SelfContained>true</SelfContained>
<TargetLatestRuntimePatch>true</TargetLatestRuntimePatch>
<NoWarn>NU1701;NU1603;SYSLIB0050;SYSLIB0051</NoWarn>
3 changes: 2 additions & 1 deletion src/Sdk/Sdk.csproj
Original file line number Diff line number Diff line change
@@ -3,7 +3,8 @@
<PropertyGroup>
<TargetFramework>net8.0</TargetFramework>
<OutputType>Library</OutputType>
<RuntimeIdentifiers>win-x64;win-x86;linux-x64;linux-arm64;linux-arm;osx-x64;osx-arm64;win-arm64</RuntimeIdentifiers>
<RuntimeIdentifiers Condition="'$(BUILD_OS)' != 'FreeBSD'">win-x64;win-x86;linux-x64;linux-arm64;linux-arm;osx-x64;osx-arm64;win-arm64</RuntimeIdentifiers>
<RuntimeIdentifiers Condition="'$(BUILD_OS)' == 'FreeBSD'">win-x64;win-x86;linux-x64;linux-arm64;linux-arm;osx-x64;osx-arm64;win-arm64;freebsd-x64</RuntimeIdentifiers>
<!-- <SelfContained>true</SelfContained> -->
<TargetLatestRuntimePatch>true</TargetLatestRuntimePatch>
<NoWarn>NU1701;NU1603;SYSLIB0050;SYSLIB0051</NoWarn>
3 changes: 2 additions & 1 deletion src/Test/L0/ConstantGenerationL0.cs
Original file line number Diff line number Diff line change
@@ -21,7 +21,8 @@ public void BuildConstantGenerateSucceed()
"linux-arm",
"linux-arm64",
"osx-x64",
"osx-arm64"
"osx-arm64",
"freebsd-x64"
};

Assert.Equal(40, BuildConstants.Source.CommitHash.Length);
3 changes: 2 additions & 1 deletion src/Test/Test.csproj
Original file line number Diff line number Diff line change
@@ -1,7 +1,8 @@
<Project Sdk="Microsoft.NET.Sdk">
<PropertyGroup>
<TargetFramework>net8.0</TargetFramework>
<RuntimeIdentifiers>win-x64;win-x86;linux-x64;linux-arm64;linux-arm;osx-x64;osx-arm64;win-arm64</RuntimeIdentifiers>
<RuntimeIdentifiers Condition="'$(BUILD_OS)' != 'FreeBSD'">win-x64;win-x86;linux-x64;linux-arm64;linux-arm;osx-x64;osx-arm64;win-arm64</RuntimeIdentifiers>
<RuntimeIdentifiers Condition="'$(BUILD_OS)' == 'FreeBSD'">win-x64;win-x86;linux-x64;linux-arm64;linux-arm;osx-x64;osx-arm64;win-arm64;freebsd-x64</RuntimeIdentifiers>
<TargetLatestRuntimePatch>true</TargetLatestRuntimePatch>
<NoWarn>NU1701;NU1603;NU1603;xUnit2013;SYSLIB0050;SYSLIB0051</NoWarn>
</PropertyGroup>
10 changes: 8 additions & 2 deletions src/dev.sh
Original file line number Diff line number Diff line change
@@ -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}" .
@@ -218,6 +220,10 @@ if [[ (! -d "${DOTNETSDK_INSTALLDIR}") || (! -e "${DOTNETSDK_INSTALLDIR}/.${DOTN
sdkinstallwindow_path=${DOTNETSDK_INSTALLDIR:1}
sdkinstallwindow_path=${sdkinstallwindow_path:0:1}:${sdkinstallwindow_path:1}
$POWERSHELL -NoLogo -Sta -NoProfile -NonInteractive -ExecutionPolicy Unrestricted -Command "& \"./Misc/dotnet-install.ps1\" -Version ${DOTNETSDK_VERSION} -InstallDir \"${sdkinstallwindow_path}\" -NoPath; exit \$LastExitCode;" || checkRC dotnet-install.ps1
# FIXME: binary for freebsd is not on https://dotnetcli.azureedge.net
elif [[ ("$CURRENT_PLATFORM" == "freebsd") ]]; then
echo "Skip installing dotnet, use system dotnet"
command -v dotnet
else
bash ./Misc/dotnet-install.sh --version ${DOTNETSDK_VERSION} --install-dir "${DOTNETSDK_INSTALLDIR}" --no-path || checkRC dotnet-install.sh
fi