New: .NET 5 support for FreeBSD 11+

(cherry picked from commit 760de88e7c1835affe184fed16bc3895ceca9358)
This commit is contained in:
ta264 2021-04-26 21:56:39 +01:00 committed by Qstick
parent b800b17c8a
commit f12ae15ffb
14 changed files with 224 additions and 43 deletions

View file

@ -1,9 +1,12 @@
<?xml version="1.0" encoding="utf-8"?>
<configuration>
<packageSources>
<clear />
<add key="nuget.org" value="https://api.nuget.org/v3/index.json" />
<add key="Taglib" value="https://pkgs.dev.azure.com/Lidarr/Lidarr/_packaging/Taglib/nuget/v3/index.json" />
<add key="MyFeed" value="https://pkgs.dev.azure.com/Servarr/Servarr/_packaging/SQLite/nuget/v3/index.json" />
<add key="FluentMigrator" value="https://pkgs.dev.azure.com/fluentmigrator/fluentmigrator/_packaging/fluentmigrator/nuget/v3/index.json" />
<add key="dotnet-bsd-crossbuild" value="https://pkgs.dev.azure.com/Servarr/Servarr/_packaging/dotnet-bsd-crossbuild/nuget/v3/index.json" />
<add key="Mono.Posix.NETStandard" value="https://pkgs.dev.azure.com/Servarr/Servarr/_packaging/Mono.Posix.NETStandard/nuget/v3/index.json" />
<add key="SQLite" value="https://pkgs.dev.azure.com/Servarr/Servarr/_packaging/SQLite/nuget/v3/index.json" />
</packageSources>
</configuration>

View file

@ -25,11 +25,11 @@ namespace NzbDrone.Core.Test.UpdateTests
}
[Test]
[Platform(Exclude = "NetCore")]
public void finds_update_when_version_lower()
{
NotBsd();
UseRealHttp();
Subject.GetLatestUpdate("nightly", new Version(0, 2)).Should().NotBeNull();
Subject.GetLatestUpdate("nightly", new Version(0, 1)).Should().NotBeNull();
}
[Test]
@ -43,9 +43,11 @@ namespace NzbDrone.Core.Test.UpdateTests
[Test]
public void should_get_recent_updates()
{
NotBsd();
const string branch = "nightly";
UseRealHttp();
var recent = Subject.GetRecentUpdates(branch, new Version(0, 2));
var recent = Subject.GetRecentUpdates(branch, new Version(0, 1));
recent.Should().NotBeEmpty();
recent.Should().OnlyContain(c => c.Hash.IsNotNullOrWhiteSpace());

View file

@ -8,6 +8,7 @@ using Mono.Unix.Native;
using Moq;
using NUnit.Framework;
using NzbDrone.Common.Disk;
using NzbDrone.Common.EnvironmentInfo;
using NzbDrone.Common.Test.DiskTests;
using NzbDrone.Mono.Disk;
@ -80,7 +81,11 @@ namespace NzbDrone.Mono.Test.DiskProviderTests
if (stat.st_mode != mode)
{
Syscall.chmod(path, mode);
if (Syscall.chmod(path, mode) < 0)
{
var error = Stdlib.GetLastError();
throw new LinuxPermissionsException("Error setting group: " + error);
}
}
}
@ -221,9 +226,13 @@ namespace NzbDrone.Mono.Test.DiskProviderTests
Syscall.stat(tempFile, out fileStat);
NativeConvert.ToOctalPermissionString(fileStat.st_mode).Should().Be("0644");
Subject.SetPermissions(tempFile, "1775", null);
Syscall.stat(tempFile, out fileStat);
NativeConvert.ToOctalPermissionString(fileStat.st_mode).Should().Be("1664");
if (OsInfo.Os != Os.Bsd)
{
// This is not allowed on BSD
Subject.SetPermissions(tempFile, "1775", null);
Syscall.stat(tempFile, out fileStat);
NativeConvert.ToOctalPermissionString(fileStat.st_mode).Should().Be("1664");
}
}
[Test]

View file

@ -0,0 +1,34 @@
using FluentAssertions;
using NUnit.Framework;
using NzbDrone.Common.EnvironmentInfo;
using NzbDrone.Common.Processes;
using NzbDrone.Mono.EnvironmentInfo.VersionAdapters;
using NzbDrone.Test.Common;
namespace NzbDrone.Mono.Test.EnvironmentInfo
{
[TestFixture]
[Platform("Linux")]
public class FreebsdVersionAdapterFixture : TestBase<FreebsdVersionAdapter>
{
[SetUp]
public void Setup()
{
if (OsInfo.Os != Os.Bsd)
{
throw new IgnoreException("BSD Only");
}
Mocker.SetConstant<IProcessProvider>(Mocker.Resolve<ProcessProvider>());
}
[Test]
public void should_get_version_info()
{
var info = Subject.Read();
info.FullName.Should().NotBeNullOrWhiteSpace();
info.Name.Should().NotBeNullOrWhiteSpace();
info.Version.Should().NotBeNullOrWhiteSpace();
}
}
}

View file

@ -14,6 +14,8 @@ namespace NzbDrone.Mono.Test.EnvironmentInfo
[SetUp]
public void Setup()
{
NotBsd();
Mocker.SetConstant<IDiskProvider>(Mocker.Resolve<DiskProvider>());
}

View file

@ -18,6 +18,8 @@ namespace NzbDrone.Mono.Test.EnvironmentInfo.VersionAdapters
[Platform("Linux")]
public void should_get_version_info_from_actual_linux()
{
NotBsd();
Mocker.SetConstant<IDiskProvider>(Mocker.Resolve<DiskProvider>());
var info = Subject.Read();
info.FullName.Should().NotBeNullOrWhiteSpace();

View file

@ -10,7 +10,7 @@
See https://github.com/xamarin/XamarinComponents/issues/282
-->
<ItemGroup Condition="'$(TargetFramework)' == 'net5.0'">
<PackageReference Include="Mono.Posix.NETStandard" Version="5.20.1-preview" />
<PackageReference Include="Mono.Posix.NETStandard" Version="5.20.1-servarr1" />
</ItemGroup>
<ItemGroup>
<ProjectReference Include="..\NzbDrone.Common.Test\Lidarr.Common.Test.csproj" />

View file

@ -0,0 +1,27 @@
using System.Linq;
using NzbDrone.Common.EnvironmentInfo;
using NzbDrone.Common.Processes;
namespace NzbDrone.Mono.EnvironmentInfo.VersionAdapters
{
public class FreebsdVersionAdapter : IOsVersionAdapter
{
private readonly IProcessProvider _processProvider;
public FreebsdVersionAdapter(IProcessProvider processProvider)
{
_processProvider = processProvider;
}
public OsVersionModel Read()
{
var output = _processProvider.StartAndCapture("freebsd-version");
var version = output.Standard.First().Content;
return new OsVersionModel("FreeBSD", version, $"FreeBSD {version}");
}
public bool Enabled => OsInfo.Os == Os.Bsd;
}
}

View file

@ -14,7 +14,7 @@
See https://github.com/xamarin/XamarinComponents/issues/282
-->
<ItemGroup Condition="'$(TargetFramework)' == 'net5.0'">
<PackageReference Include="Mono.Posix.NETStandard" Version="5.20.1-preview" />
<PackageReference Include="Mono.Posix.NETStandard" Version="5.20.1-servarr1" />
</ItemGroup>
<ItemGroup>
<ProjectReference Include="..\NzbDrone.Common\Lidarr.Common.csproj" />

View file

@ -174,6 +174,14 @@ namespace NzbDrone.Test.Common
}
}
protected void NotBsd()
{
if (OsInfo.Os == Os.Bsd)
{
throw new IgnoreException("Ignored on BSD");
}
}
protected void WithTempAsAppPath()
{
Mocker.GetMock<IAppFolderInfo>()