Skip to content

Commit

Permalink
Merge pull request #5200 from duplicati/feature/add-missing-executables
Browse files Browse the repository at this point in the history
Added executables for `SharpAESCrypt` and `Snapshots`
  • Loading branch information
kenkendk committed May 21, 2024
2 parents aaf1067 + 9d43685 commit db79b8e
Show file tree
Hide file tree
Showing 14 changed files with 162 additions and 37 deletions.
11 changes: 11 additions & 0 deletions .vscode/launch.json
Original file line number Diff line number Diff line change
Expand Up @@ -48,6 +48,17 @@
"stopAtEntry": false,
"console": "internalConsole"
},
{
"name": "Launch ConfigurationImporter executable",
"type": "coreclr",
"request": "launch",
"preLaunchTask": "build",
"program": "${workspaceFolder}/Executables/net8/Duplicati.CommandLine.ConfigurationImporter/bin/Debug/net8.0/Duplicati.CommandLine.ConfigurationImporter",
"args": [],
"cwd": "${workspaceFolder}",
"stopAtEntry": false,
"console": "internalConsole"
},
{
"name": "Launch RecoveryTool executable",
"type": "coreclr",
Expand Down
16 changes: 15 additions & 1 deletion Duplicati.sln
Original file line number Diff line number Diff line change
Expand Up @@ -109,7 +109,7 @@ Project("{2150E333-8FDC-42A3-9474-1A3956D46DE8}") = "net8", "net8", "{6B46F6B1-1
EndProject
Project("{9A19103F-16F7-4668-BE54-9A1E7A4F7556}") = "Duplicati.CommandLine.AutoUpdater", "Executables\net8\Duplicati.CommandLine.AutoUpdater\Duplicati.CommandLine.AutoUpdater.csproj", "{95B7DD83-2C5A-4F1E-8EA7-39654B2B236A}"
EndProject
Project("{9A19103F-16F7-4668-BE54-9A1E7A4F7556}") = "Duplicati.Service", "Executables\net8\Duplicati_Service\Duplicati.Service.csproj", "{34149709-F3ED-4FB5-A087-43EB195C948B}"
Project("{9A19103F-16F7-4668-BE54-9A1E7A4F7556}") = "Duplicati.Service", "Executables\net8\Duplicati.Service\Duplicati.Service.csproj", "{34149709-F3ED-4FB5-A087-43EB195C948B}"
EndProject
Project("{9A19103F-16F7-4668-BE54-9A1E7A4F7556}") = "Duplicati.CommandLine.BackendTester", "Executables\net8\Duplicati.CommandLine.BackendTester\Duplicati.CommandLine.BackendTester.csproj", "{2F1C0C8D-5C15-4BC0-811F-87F2C98D9790}"
EndProject
Expand Down Expand Up @@ -148,6 +148,10 @@ Project("{FAE04EC0-301F-11D3-BF4B-00C04F79EFBC}") = "Duplicati.Library.RestAPI",
EndProject
Project("{9A19103F-16F7-4668-BE54-9A1E7A4F7556}") = "Duplicati.Library.Backend.AliyunOSS", "Duplicati\Library\Backend\AliyunOSS\Duplicati.Library.Backend.AliyunOSS.csproj", "{4EB3DABC-D412-4C12-8876-41A1427A389E}"
EndProject
Project("{FAE04EC0-301F-11D3-BF4B-00C04F79EFBC}") = "Duplicati.CommandLine.SharpAESCrypt", "Executables\net8\Duplicati.CommandLine.SharpAESCrypt\Duplicati.CommandLine.SharpAESCrypt.csproj", "{FE6FD36C-E171-4599-8D55-62DA579C0864}"
EndProject
Project("{FAE04EC0-301F-11D3-BF4B-00C04F79EFBC}") = "Duplicati.CommandLine.Snapshots", "Executables\net8\Duplicati.CommandLine.Snapshots\Duplicati.CommandLine.Snapshots.csproj", "{0364E724-1929-445E-9145-90A70B01DDC0}"
EndProject
Global
GlobalSection(SolutionConfigurationPlatforms) = preSolution
Debug|Any CPU = Debug|Any CPU
Expand Down Expand Up @@ -414,6 +418,14 @@ Global
{C1D4D665-23A3-4216-9CD1-D67AE9AAAA4C}.Debug|Any CPU.Build.0 = Debug|Any CPU
{C1D4D665-23A3-4216-9CD1-D67AE9AAAA4C}.Release|Any CPU.ActiveCfg = Release|Any CPU
{C1D4D665-23A3-4216-9CD1-D67AE9AAAA4C}.Release|Any CPU.Build.0 = Release|Any CPU
{FE6FD36C-E171-4599-8D55-62DA579C0864}.Debug|Any CPU.ActiveCfg = Debug|Any CPU
{FE6FD36C-E171-4599-8D55-62DA579C0864}.Debug|Any CPU.Build.0 = Debug|Any CPU
{FE6FD36C-E171-4599-8D55-62DA579C0864}.Release|Any CPU.ActiveCfg = Release|Any CPU
{FE6FD36C-E171-4599-8D55-62DA579C0864}.Release|Any CPU.Build.0 = Release|Any CPU
{0364E724-1929-445E-9145-90A70B01DDC0}.Debug|Any CPU.ActiveCfg = Debug|Any CPU
{0364E724-1929-445E-9145-90A70B01DDC0}.Debug|Any CPU.Build.0 = Debug|Any CPU
{0364E724-1929-445E-9145-90A70B01DDC0}.Release|Any CPU.ActiveCfg = Release|Any CPU
{0364E724-1929-445E-9145-90A70B01DDC0}.Release|Any CPU.Build.0 = Release|Any CPU
EndGlobalSection
GlobalSection(SolutionProperties) = preSolution
HideSolutionNode = FALSE
Expand Down Expand Up @@ -467,6 +479,8 @@ Global
{0F5A1F4E-25FA-4D02-920D-CA2138498081} = {6B46F6B1-1898-49B8-ADA7-5CAF68EB77E3}
{6B594D23-B629-465C-B799-70EE9E56C218} = {E1A9B303-F281-45C5-A4F6-CADD9DE3F3C4}
{D19A38DD-68F1-4EF5-BF5F-8966CE0D9A5B} = {FA88A246-EF8E-46E3-90AF-539B8C0A6ADE}
{FE6FD36C-E171-4599-8D55-62DA579C0864} = {6B46F6B1-1898-49B8-ADA7-5CAF68EB77E3}
{0364E724-1929-445E-9145-90A70B01DDC0} = {6B46F6B1-1898-49B8-ADA7-5CAF68EB77E3}
EndGlobalSection
GlobalSection(ExtensibilityGlobals) = postSolution
SolutionGuid = {8B40BAFE-D862-4397-9495-8F5EAF5CE80C}
Expand Down
15 changes: 11 additions & 4 deletions Duplicati/CommandLine/ConfigurationImporter/Program.cs
Original file line number Diff line number Diff line change
Expand Up @@ -19,6 +19,7 @@
// FROM, OUT OF OR IN CONNECTION WITH THE SOFTWARE OR THE USE OR OTHER
// DEALINGS IN THE SOFTWARE.

using Duplicati.Library.AutoUpdater;
using Duplicati.Server.Serializable;
using Duplicati.Server.WebServer.RESTMethods;
using System;
Expand All @@ -29,26 +30,32 @@ namespace Duplicati.CommandLine.ConfigurationImporter
{
public static class ConfigurationImporter
{
private static readonly string usageString = $"Usage: {nameof(ConfigurationImporter)}.exe <configuration-file> --import-metadata=(true | false) --server-datafolder=<folder containing Duplicati-server.sqlite>";
private static readonly string UsageString = $"Usage: {PackageHelper.GetExecutableName(PackageHelper.NamedExecutable.ConfigurationImporter)} <configuration-file> --import-metadata=(true | false) --server-datafolder=<folder containing Duplicati-server.sqlite>";

public static int Main(string[] args)
{
if (args.Length != 3)
{
throw new ArgumentException($"Incorrect number of input arguments. {ConfigurationImporter.usageString}");
Console.WriteLine($"Incorrect number of input arguments.");
Console.WriteLine(UsageString);
return 1;
}

string configurationFile = args[0];
Dictionary<string, string> importOptions = Duplicati.Library.Utility.CommandLineParser.ExtractOptions(args.Skip(1).ToList());
if (!importOptions.TryGetValue("import-metadata", out string importMetadataString))
{
throw new ArgumentException($"Invalid import-metadata argument. {ConfigurationImporter.usageString}");
Console.WriteLine($"Missing import-metadata argument.");
Console.WriteLine(UsageString);
return 1;
}
bool importMetadata = Duplicati.Library.Utility.Utility.ParseBool(importMetadataString, false);

if (!importOptions.TryGetValue("server-datafolder", out string serverDatafolder))
{
throw new ArgumentException($"Invalid server-datafolder argument. {ConfigurationImporter.usageString}");
Console.WriteLine($"Missing server-datafolder argument.");
Console.WriteLine(UsageString);
return 1;
}

Dictionary<string, string> advancedOptions = new Dictionary<string, string>
Expand Down
20 changes: 18 additions & 2 deletions Duplicati/GUI/Duplicati.GUI.TrayIcon/AvaloniaRunner.cs
Original file line number Diff line number Diff line change
Expand Up @@ -27,6 +27,7 @@
using Avalonia;
using Avalonia.Controls;
using Avalonia.Controls.ApplicationLifetimes;
using Avalonia.Logging;
using Avalonia.Media.Imaging;
using Avalonia.Platform;
using Avalonia.Themes.Fluent;
Expand Down Expand Up @@ -98,9 +99,9 @@ protected override void Run(string[] args)
builder = builder.LogToTrace();
#else
if (Environment.GetEnvironmentVariable("DEBUG_AVALONIA") == "1")
builder = builder.LogToTrace();
Logger.Sink = new ConsoleLogSink(LogEventLevel.Information);
else if (Environment.GetEnvironmentVariable("DEBUG_AVALONIA") == "2")
builder = builder.LogToTrace(Avalonia.Logging.LogEventLevel.Verbose);
Logger.Sink = new ConsoleLogSink(LogEventLevel.Verbose);
#endif

application = builder.Instance as AvaloniaApp;
Expand Down Expand Up @@ -402,4 +403,19 @@ public override void OnFrameworkInitializationCompleted()
base.OnFrameworkInitializationCompleted();
}
}

internal class ConsoleLogSink(LogEventLevel minLevel) : ILogSink
{
private readonly LogEventLevel _minLevel = minLevel;

public bool IsEnabled(LogEventLevel level, string area)
=> level >= _minLevel;

public void Log(LogEventLevel level, string area, object source, string messageTemplate)
=> Log(level, area, source, messageTemplate, null);

public void Log(LogEventLevel level, string area, object source, string messageTemplate, params object[] propertyValues)
=> Console.WriteLine($"Avalonia [{level}]: {source} {messageTemplate} {string.Join(" ", propertyValues)}");
}

}
20 changes: 18 additions & 2 deletions Duplicati/Library/AutoUpdater/PackageHelper.cs
Original file line number Diff line number Diff line change
Expand Up @@ -48,7 +48,20 @@ public enum NamedExecutable
/// <summary>
/// The backend testing tool
/// </summary>
BackendTester
BackendTester,
/// <summary>
/// The SharpAESCrypt tool
/// </summary>
SharpAESCrypt,
/// <summary>
/// The snapshot tool
/// </summary>
Snapshots,
/// <summary>
/// The configuration importer
/// </summary>
ConfigurationImporter

}

/// <summary>
Expand All @@ -66,8 +79,11 @@ public static string GetExecutableName(NamedExecutable exe)
NamedExecutable.Server => Platform.IsClientWindows ? "Duplicati.Server.exe" : "duplicati-server",
NamedExecutable.WindowsService => "Duplicati.WindowsServer.exe",
NamedExecutable.BackendTool => Platform.IsClientWindows ? "Duplicati.CommandLine.BackendTool.exe" : "duplicati-backend-tool",
NamedExecutable.RecoveryTool => Platform.IsClientWindows ? "Duplicati.Command.RecoveryTool.exe" : "duplicati-recovery-tool",
NamedExecutable.RecoveryTool => Platform.IsClientWindows ? "Duplicati.CommandLine.RecoveryTool.exe" : "duplicati-recovery-tool",
NamedExecutable.BackendTester => Platform.IsClientWindows ? "Duplicati.CommandLine.BackendTester.exe" : "duplicati-backend-tester",
NamedExecutable.SharpAESCrypt => Platform.IsClientWindows ? "Duplicati.CommandLine.SharpAESCrypt.exe" : "duplicati-aescrypt",
NamedExecutable.Snapshots => Platform.IsClientWindows ? "Duplicati.CommandLine.Snapshots.exe" : "duplicati-snapshots",
NamedExecutable.ConfigurationImporter => Platform.IsClientWindows ? "Duplicati.CommandLine.ConfigurationImporter.exe" : "duplicati-configuration-importer",
_ => throw new ArgumentException($"Named executable not known: {exe}", nameof(exe))
};

Expand Down
50 changes: 25 additions & 25 deletions Duplicati/Library/Snapshots/Program.cs
Original file line number Diff line number Diff line change
@@ -1,32 +1,32 @@
// Copyright (C) 2024, The Duplicati Team
// https://duplicati.com, hello@duplicati.com
//
// Permission is hereby granted, free of charge, to any person obtaining a
// copy of this software and associated documentation files (the "Software"),
// to deal in the Software without restriction, including without limitation
// the rights to use, copy, modify, merge, publish, distribute, sublicense,
// and/or sell copies of the Software, and to permit persons to whom the
// Software is furnished to do so, subject to the following conditions:
//
// The above copyright notice and this permission notice shall be included in
// all copies or substantial portions of the Software.
//
// THE SOFTWARE IS PROVIDED "AS IS", WITHOUT WARRANTY OF ANY KIND, EXPRESS
// OR IMPLIED, INCLUDING BUT NOT LIMITED TO THE WARRANTIES OF MERCHANTABILITY,
// FITNESS FOR A PARTICULAR PURPOSE AND NONINFRINGEMENT. IN NO EVENT SHALL THE
// AUTHORS OR COPYRIGHT HOLDERS BE LIABLE FOR ANY CLAIM, DAMAGES OR OTHER
// LIABILITY, WHETHER IN AN ACTION OF CONTRACT, TORT OR OTHERWISE, ARISING
// FROM, OUT OF OR IN CONNECTION WITH THE SOFTWARE OR THE USE OR OTHER
// DEALINGS IN THE SOFTWARE.
// Copyright (C) 2024, The Duplicati Team
// https://duplicati.com, hello@duplicati.com
//
// Permission is hereby granted, free of charge, to any person obtaining a
// copy of this software and associated documentation files (the "Software"),
// to deal in the Software without restriction, including without limitation
// the rights to use, copy, modify, merge, publish, distribute, sublicense,
// and/or sell copies of the Software, and to permit persons to whom the
// Software is furnished to do so, subject to the following conditions:
//
// The above copyright notice and this permission notice shall be included in
// all copies or substantial portions of the Software.
//
// THE SOFTWARE IS PROVIDED "AS IS", WITHOUT WARRANTY OF ANY KIND, EXPRESS
// OR IMPLIED, INCLUDING BUT NOT LIMITED TO THE WARRANTIES OF MERCHANTABILITY,
// FITNESS FOR A PARTICULAR PURPOSE AND NONINFRINGEMENT. IN NO EVENT SHALL THE
// AUTHORS OR COPYRIGHT HOLDERS BE LIABLE FOR ANY CLAIM, DAMAGES OR OTHER
// LIABILITY, WHETHER IN AN ACTION OF CONTRACT, TORT OR OTHERWISE, ARISING
// FROM, OUT OF OR IN CONNECTION WITH THE SOFTWARE OR THE USE OR OTHER
// DEALINGS IN THE SOFTWARE.

using System;
using System.Collections.Generic;
using System.Text;
using Duplicati.Library.AutoUpdater;
using Duplicati.Library.Common;

namespace Duplicati.Library.Snapshots
{
static class Program
public static class Program
{
private static Dictionary<string, string> ExtractOptions(List<string> args)
{
Expand Down Expand Up @@ -68,14 +68,14 @@ public static void Main(string[] _args)
{
List<string> args = new List<string>(_args);
Dictionary<string, string> options = ExtractOptions(args);

if (args.Count == 0)
args = new List<string> { System.IO.Path.GetDirectoryName(System.Reflection.Assembly.GetExecutingAssembly().Location) };

if (args.Count != 1)
{
Console.WriteLine(@"Usage:
Duplicati.Library.Snapshots.exe [test-folder]
Console.WriteLine(@$"Usage:
{PackageHelper.GetExecutableName(PackageHelper.NamedExecutable.Snapshots)} [test-folder]
Where <test-folder> is the folder where files will be locked/created etc");
return;
Expand Down
Original file line number Diff line number Diff line change
@@ -0,0 +1,21 @@
<Project Sdk="Microsoft.NET.Sdk">

<PropertyGroup>
<OutputType>Exe</OutputType>
<TargetFramework>net8.0</TargetFramework>
<Description>The Server SharpAESCrypt implementation</Description>
<AssemblyName>Duplicati.CommandLine.SharpAESCrypt</AssemblyName>
</PropertyGroup>

<ItemGroup>
<PackageReference Include="Microsoft.DotNet.Analyzers.Compatibility" Version="0.2.12-alpha">
<PrivateAssets>all</PrivateAssets>
<IncludeAssets>runtime; build; native; contentfiles; analyzers; buildtransitive</IncludeAssets>
</PackageReference>
</ItemGroup>

<ItemGroup>
<ProjectReference Include="..\..\..\Duplicati\Library\Encryption\Duplicati.Library.Encryption.csproj" />
</ItemGroup>

</Project>
Original file line number Diff line number Diff line change
@@ -0,0 +1,9 @@
namespace Duplicati.CommandLine.SharpAESCrypt.Net8
{
// Wrapper class to keep code independent
public static class Program
{
public static void Main(string[] args)
=> global::SharpAESCrypt.SharpAESCrypt.CommandLineMain(args);
}
}
Original file line number Diff line number Diff line change
@@ -0,0 +1,21 @@
<Project Sdk="Microsoft.NET.Sdk">

<PropertyGroup>
<OutputType>Exe</OutputType>
<TargetFramework>net8.0</TargetFramework>
<Description>The Server Snapshots implementation</Description>
<AssemblyName>Duplicati.CommandLine.Snapshots</AssemblyName>
</PropertyGroup>

<ItemGroup>
<PackageReference Include="Microsoft.DotNet.Analyzers.Compatibility" Version="0.2.12-alpha">
<PrivateAssets>all</PrivateAssets>
<IncludeAssets>runtime; build; native; contentfiles; analyzers; buildtransitive</IncludeAssets>
</PackageReference>
</ItemGroup>

<ItemGroup>
<ProjectReference Include="..\..\..\Duplicati\Library\Snapshots\Duplicati.Library.Snapshots.csproj" />
</ItemGroup>

</Project>
9 changes: 9 additions & 0 deletions Executables/net8/Duplicati.CommandLine.Snapshots/Program.cs
Original file line number Diff line number Diff line change
@@ -0,0 +1,9 @@
namespace Duplicati.CommandLine.Snapshots.Net8
{
// Wrapper class to keep code independent
public static class Program
{
public static void Main(string[] args)
=> Duplicati.Library.Snapshots.Program.Main(args);
}
}
3 changes: 1 addition & 2 deletions Executables/net8/Duplicati.Server/Duplicati.Server.csproj
Original file line number Diff line number Diff line change
Expand Up @@ -3,8 +3,7 @@
<PropertyGroup>
<OutputType>Exe</OutputType>
<TargetFramework>net8.0</TargetFramework>
<Description>The Server Duplicati implementation</Description>
<AssemblyName>Duplicati.Server</AssemblyName>
<Description>The Duplicati Server implementation</Description>
</PropertyGroup>

<ItemGroup>
Expand Down
Original file line number Diff line number Diff line change
@@ -1,8 +1,8 @@
<Project Sdk="Microsoft.NET.Sdk">

<PropertyGroup>
<TargetFramework>net8.0</TargetFramework>
<OutputType>Exe</OutputType>
<TargetFramework>net8.0</TargetFramework>
<Description>Service controller for Duplicati</Description>
</PropertyGroup>

Expand Down
2 changes: 2 additions & 0 deletions ReleaseBuilder/Build/Command.cs
Original file line number Diff line number Diff line change
Expand Up @@ -43,6 +43,8 @@ public static partial class Command
{ "Duplicati.CommandLine.BackendTool", "duplicati-backend-tool" },
{ "Duplicati.CommandLine.RecoveryTool", "duplicati-recovery-tool" },
{ "Duplicati.CommandLine.AutoUpdater", "duplicati-autoupdater" },
{ "Duplicati.CommandLine.SharpAESCrypt", "duplicati-aescrypt" },
{ "Duplicati.CommandLine.Snapshots", "duplicati-snapshots" },
{ "Duplicati.CommandLine.ConfigurationImporter", "duplicati-configuration-importer" },
{ "Duplicati.CommandLine", "duplicati-cli" },
{ "Duplicati.Server", "duplicati-server"},
Expand Down

0 comments on commit db79b8e

Please sign in to comment.