mirror of
https://github.com/lidarr/lidarr.git
synced 2025-08-19 21:13:28 -07:00
New: Musl (alpine linux) compatibility
This commit is contained in:
parent
f8afe65f7e
commit
ff8d671c8b
7 changed files with 109 additions and 34 deletions
|
@ -6,8 +6,8 @@
|
|||
|
||||
<PlatformTarget>AnyCPU</PlatformTarget>
|
||||
<TargetLatestRuntimePatch>true</TargetLatestRuntimePatch>
|
||||
<RuntimeIdentifiers>win-x64;osx-x64;linux-x64;linux-arm;linux-arm64</RuntimeIdentifiers>
|
||||
<ExcludedRuntimeFrameworkPairs>win-x64:net462;osx-x64:net462;linux-arm:net462;linux-arm64:net462</ExcludedRuntimeFrameworkPairs>
|
||||
<RuntimeIdentifiers>win-x64;osx-x64;linux-x64;linux-musl-x64;linux-arm;linux-arm64;linux-musl-arm64</RuntimeIdentifiers>
|
||||
<ExcludedRuntimeFrameworkPairs>win-x64:net462;osx-x64:net462;linux-arm:net462;linux-arm64:net462;linux-musl-x64:net462;linux-musl-arm64:net462</ExcludedRuntimeFrameworkPairs>
|
||||
|
||||
<LidarrRootDir>$(MSBuildThisFileDirectory)..\</LidarrRootDir>
|
||||
|
||||
|
|
|
@ -1,5 +1,6 @@
|
|||
using System;
|
||||
using System.Collections.Generic;
|
||||
using System.Diagnostics;
|
||||
using System.IO;
|
||||
using System.Linq;
|
||||
using NLog;
|
||||
|
@ -11,7 +12,7 @@ namespace NzbDrone.Common.EnvironmentInfo
|
|||
public static Os Os { get; }
|
||||
|
||||
public static bool IsNotWindows => !IsWindows;
|
||||
public static bool IsLinux => Os == Os.Linux;
|
||||
public static bool IsLinux => Os == Os.Linux || Os == Os.LinuxMusl || Os == Os.Bsd;
|
||||
public static bool IsOsx => Os == Os.Osx;
|
||||
public static bool IsWindows => Os == Os.Windows;
|
||||
|
||||
|
@ -37,18 +38,7 @@ namespace NzbDrone.Common.EnvironmentInfo
|
|||
case PlatformID.MacOSX:
|
||||
case PlatformID.Unix:
|
||||
{
|
||||
// Sometimes Mac OS reports itself as Unix
|
||||
if (Directory.Exists("/System/Library/CoreServices/") &&
|
||||
(File.Exists("/System/Library/CoreServices/SystemVersion.plist") ||
|
||||
File.Exists("/System/Library/CoreServices/ServerVersion.plist")))
|
||||
{
|
||||
Os = Os.Osx;
|
||||
}
|
||||
else
|
||||
{
|
||||
Os = Os.Linux;
|
||||
}
|
||||
|
||||
Os = GetPosixFlavour();
|
||||
break;
|
||||
}
|
||||
}
|
||||
|
@ -92,6 +82,48 @@ namespace NzbDrone.Common.EnvironmentInfo
|
|||
IsDocker = true;
|
||||
}
|
||||
}
|
||||
|
||||
private static Os GetPosixFlavour()
|
||||
{
|
||||
var output = RunAndCapture("uname", "-s");
|
||||
|
||||
if (output.StartsWith("Darwin"))
|
||||
{
|
||||
return Os.Osx;
|
||||
}
|
||||
else if (output.Contains("BSD"))
|
||||
{
|
||||
return Os.Bsd;
|
||||
}
|
||||
else
|
||||
{
|
||||
return IsMusl() ? Os.LinuxMusl : Os.Linux;
|
||||
}
|
||||
}
|
||||
|
||||
private static bool IsMusl()
|
||||
{
|
||||
var output = RunAndCapture("ldd", "/bin/ls");
|
||||
return output.Contains("libc.musl");
|
||||
}
|
||||
|
||||
private static string RunAndCapture(string filename, string args)
|
||||
{
|
||||
Process p = new Process();
|
||||
p.StartInfo.FileName = filename;
|
||||
p.StartInfo.Arguments = args;
|
||||
p.StartInfo.UseShellExecute = false;
|
||||
p.StartInfo.CreateNoWindow = true;
|
||||
p.StartInfo.RedirectStandardOutput = true;
|
||||
|
||||
p.Start();
|
||||
|
||||
// To avoid deadlocks, always read the output stream first and then wait.
|
||||
string output = p.StandardOutput.ReadToEnd();
|
||||
p.WaitForExit(1000);
|
||||
|
||||
return output;
|
||||
}
|
||||
}
|
||||
|
||||
public interface IOsInfo
|
||||
|
@ -107,6 +139,8 @@ namespace NzbDrone.Common.EnvironmentInfo
|
|||
{
|
||||
Windows,
|
||||
Linux,
|
||||
Osx
|
||||
Osx,
|
||||
LinuxMusl,
|
||||
Bsd
|
||||
}
|
||||
}
|
||||
|
|
|
@ -16,7 +16,7 @@
|
|||
See https://github.com/xamarin/XamarinComponents/issues/282
|
||||
-->
|
||||
<ItemGroup Condition="'$(TargetFramework)' == 'netcoreapp3.1'">
|
||||
<PackageReference Include="Mono.Posix.NETStandard" Version="1.0.0" />
|
||||
<PackageReference Include="Mono.Posix.NETStandard" Version="5.20.1-preview" />
|
||||
<PackageReference Include="coverlet.collector" Version="1.2.1" PrivateAssets="all" />
|
||||
</ItemGroup>
|
||||
<ItemGroup>
|
||||
|
|
|
@ -14,7 +14,7 @@
|
|||
See https://github.com/xamarin/XamarinComponents/issues/282
|
||||
-->
|
||||
<ItemGroup Condition="'$(TargetFramework)' == 'netcoreapp3.1'">
|
||||
<PackageReference Include="Mono.Posix.NETStandard" Version="1.0.0" />
|
||||
<PackageReference Include="Mono.Posix.NETStandard" Version="5.20.1-preview" />
|
||||
</ItemGroup>
|
||||
<ItemGroup>
|
||||
<ProjectReference Include="..\NzbDrone.Common\Lidarr.Common.csproj" />
|
||||
|
|
BIN
src/Runtimes/linux-musl-x64/libMonoPosixHelper.so
Normal file
BIN
src/Runtimes/linux-musl-x64/libMonoPosixHelper.so
Normal file
Binary file not shown.
Loading…
Add table
Add a link
Reference in a new issue