mirror of
https://github.com/btcpayserver/btcpayserver.git
synced 2025-02-22 14:22:40 +01:00
PluginPacker: Shell fallback for macOS/Linux
This commit is contained in:
parent
b1f62f74cd
commit
ff66e66f21
1 changed files with 29 additions and 15 deletions
|
@ -66,31 +66,45 @@ namespace BTCPayServer.PluginPacker
|
|||
File.Delete(sha256dirs);
|
||||
}
|
||||
await File.WriteAllTextAsync(sha256dirs, sha256sums.ToString());
|
||||
|
||||
// try Windows executable first, fall back to macOS/Linux PowerShell
|
||||
try
|
||||
{
|
||||
Process cmd = new();
|
||||
cmd.StartInfo.FileName = "powershell.exe";
|
||||
cmd.StartInfo.RedirectStandardInput = true;
|
||||
cmd.StartInfo.RedirectStandardOutput = true;
|
||||
cmd.StartInfo.CreateNoWindow = false;
|
||||
cmd.StartInfo.UseShellExecute = false;
|
||||
cmd.Start();
|
||||
|
||||
await cmd.StandardInput.WriteLineAsync($"cat {sha256dirs} | gpg -s > {Path.Combine(outputDir, "SHA256SUMS.asc")}");
|
||||
await cmd.StandardInput.FlushAsync();
|
||||
cmd.StandardInput.Close();
|
||||
await cmd.WaitForExitAsync();
|
||||
Console.WriteLine(await cmd.StandardOutput.ReadToEndAsync());
|
||||
|
||||
await CreateShasums("powershell.exe", sha256dirs, outputDir);
|
||||
}
|
||||
catch (Exception e)
|
||||
{
|
||||
Console.WriteLine($"Attempted to sign hashes with gpg but maybe powershell is not installed?\n{e.Message}");
|
||||
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 = exec;
|
||||
cmd.StartInfo.RedirectStandardInput = true;
|
||||
cmd.StartInfo.RedirectStandardOutput = true;
|
||||
cmd.StartInfo.CreateNoWindow = false;
|
||||
cmd.StartInfo.UseShellExecute = false;
|
||||
cmd.Start();
|
||||
|
||||
await cmd.StandardInput.WriteLineAsync($"cat {sha256dirs} | gpg -s > {Path.Combine(outputDir, "SHA256SUMS.asc")}");
|
||||
await cmd.StandardInput.FlushAsync();
|
||||
cmd.StandardInput.Close();
|
||||
await cmd.WaitForExitAsync();
|
||||
Console.WriteLine(await cmd.StandardOutput.ReadToEndAsync());
|
||||
}
|
||||
|
||||
private static Type[] GetAllExtensionTypesFromAssembly(Assembly assembly)
|
||||
{
|
||||
return assembly.GetTypes().Where(type =>
|
||||
|
|
Loading…
Add table
Reference in a new issue