// Copyright (C) 2025, 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.Globalization;
using System.Formats.Tar;
using System.IO.Compression;
using System.Text;
namespace ReleaseBuilder.Build;
public static partial class Command
{
///
/// Implementations for the package builds
///
private static class CreatePackage
{
///
/// Representation of a build package
///
/// The target package
/// The created package file path
public record BuiltPackage(PackageTarget Target, string CreatedFile);
///
/// Generates the metainfo content with the releases block injected
///
/// The base directory
/// The path to the source metainfo file
/// The modified metainfo content
public static string GetMetainfoWithReleases(string baseDir, string metainfoPath)
{
var versionPath = Path.Combine(baseDir, "ReleaseBuilder", "build_version.txt");
var changelogPath = Path.Combine(baseDir, "ReleaseBuilder", "changelog-news.txt");
var version = File.ReadAllText(versionPath).Trim();
var changelog = File.ReadAllText(changelogPath).Trim();
var metainfo = File.ReadAllText(metainfoPath);
var sb = new StringBuilder();
sb.AppendLine(" ");
sb.AppendLine($" ");
sb.AppendLine(" ");
sb.AppendLine($"