core: fix jackett updater in musl builds (#13439)

This commit is contained in:
Diego Heras 2022-08-01 00:21:14 +02:00 committed by GitHub
parent fcfa1a9c89
commit 75a2e25528
No known key found for this signature in database
GPG Key ID: 4AEE18F83AFDEB23
1 changed files with 29 additions and 1 deletions

View File

@ -1,4 +1,7 @@
using System;
#if ISLINUXMUSL
using System.Diagnostics;
#endif
using Jackett.Common.Services.Interfaces;
using Mono.Unix;
using NLog;
@ -16,10 +19,35 @@ namespace Jackett.Server.Services
logger.Debug($"Attempting to give execute permission to: {path}");
try
{
#if ISLINUXMUSL
// Fix this error in Alpine Linux
// Error System.DllNotFoundException: Unable to load shared library 'Mono.Unix' or one of its dependencies.
// In order to help diagnose loading problems, consider setting the LD_DEBUG environment variable:
// Error loading shared library libMono.Unix: No such file or directory
var process = new Process
{
StartInfo = new ProcessStartInfo
{
RedirectStandardError = true,
UseShellExecute = false,
CreateNoWindow = true,
WindowStyle = ProcessWindowStyle.Hidden,
FileName = "chmod",
Arguments = $"+x \"{path}\""
}
};
process.Start();
var stdErr = process.StandardError.ReadToEnd();
process.WaitForExit();
if (process.ExitCode != 0)
throw new Exception(stdErr);
#else
var jackettUpdaterFI = new UnixFileInfo(path)
{
FileAccessPermissions = FileAccessPermissions.UserReadWriteExecute | FileAccessPermissions.GroupRead | FileAccessPermissions.OtherRead
FileAccessPermissions = FileAccessPermissions.UserReadWriteExecute | FileAccessPermissions.GroupRead
| FileAccessPermissions.OtherRead
};
#endif
}
catch (Exception ex)
{