PluginPacker: Shell fallback for macOS/Linux

This commit is contained in:
Dennis Reimann
2022-05-30 11:36:25 +02:00
committed by Andrew Camilleri
parent b1f62f74cd
commit ff66e66f21

View File

@@ -66,10 +66,32 @@ namespace BTCPayServer.PluginPacker
File.Delete(sha256dirs);
}
await File.WriteAllTextAsync(sha256dirs, sha256sums.ToString());
// try Windows executable first, fall back to macOS/Linux PowerShell
try
{
await CreateShasums("powershell.exe", sha256dirs, outputDir);
}
catch (Exception e)
{
try
{
await CreateShasums("bash", sha256dirs, outputDir);
}
catch (Exception ex)
{
Console.WriteLine(
$"Attempted to sign hashes with gpg but maybe powershell is not installed?\n{ex.Message}");
}
}
Console.WriteLine($"Created {outputFile}.btcpay at {directory}");
}
private static async Task CreateShasums(string exec, string sha256dirs, string outputDir)
{
Process cmd = new();
cmd.StartInfo.FileName = "powershell.exe";
cmd.StartInfo.FileName = exec;
cmd.StartInfo.RedirectStandardInput = true;
cmd.StartInfo.RedirectStandardOutput = true;
cmd.StartInfo.CreateNoWindow = false;
@@ -81,14 +103,6 @@ namespace BTCPayServer.PluginPacker
cmd.StandardInput.Close();
await cmd.WaitForExitAsync();
Console.WriteLine(await cmd.StandardOutput.ReadToEndAsync());
}
catch (Exception e)
{
Console.WriteLine($"Attempted to sign hashes with gpg but maybe powershell is not installed?\n{e.Message}");
}
Console.WriteLine($"Created {outputFile}.btcpay at {directory}");
}
private static Type[] GetAllExtensionTypesFromAssembly(Assembly assembly)