78 lines
No EOL
3.6 KiB
C#
78 lines
No EOL
3.6 KiB
C#
using System;
|
|
using System.IO;
|
|
using System.Linq;
|
|
using BetaVersionLauncher;
|
|
using TeaBox.Code;
|
|
using TeaBox.Macros;
|
|
|
|
namespace TeaBox.BuildVersion
|
|
{
|
|
internal class MakeNxPatchCommand : MakeNxPackageCommand
|
|
{
|
|
internal string OutputPatch => Path.Combine(OutputDirectory, PatchName);
|
|
internal string MasterPackagePath => GameConstants.GetMasterPackage(Platform, Region, Variant);
|
|
internal string LastTuPackagePath => GameConstants.GetLastTuPackage(Platform, Region, Variant);
|
|
internal string MasterPackageName => GameConstants.GetPackageName(MasterPackagePath);
|
|
internal string TuPackageName => GameConstants.GetPackageName(LastTuPackagePath);
|
|
|
|
protected override void PackageDataAssemblyImpl(IStep stepcontext)
|
|
{
|
|
CopyExecutableFromOutput(stepcontext);
|
|
|
|
CopyDataMasterToDiscWorkingDirectory(stepcontext);
|
|
CopyPatchDataToDiscWorkingDirectory(stepcontext);
|
|
CopyMasterPackageToDiscWorkingDirectory(stepcontext);
|
|
}
|
|
|
|
protected override void GeneratePackageImpl()
|
|
{
|
|
base.GeneratePackageImpl();
|
|
GeneratePatchImpl();
|
|
}
|
|
|
|
protected void GeneratePatchImpl()
|
|
{
|
|
var masterPackage = Path.Combine(WorkingDirectory, "orginal_master", MasterPackageName);
|
|
var commandLine = $"makepatch -o {OutputPatch} --meta {MetaFile} --desc {DescFile} --original {masterPackage} --current {OutputGame}";
|
|
|
|
// We need to update the command by adding a new parameter in case of a patch has already been approved
|
|
if (! string.IsNullOrEmpty(TuPackageName))
|
|
{
|
|
Context.AddStep("Copy Master Patched package", CopyMasterTuPackageToDiscWorkingDirectory);
|
|
var lastTuPackage = Path.Combine(WorkingDirectory, "last_tu", TuPackageName);
|
|
// Update the command line
|
|
commandLine += $" --previous {lastTuPackage}";
|
|
}
|
|
|
|
Context.AddStep("Creating patched package", stepcontext =>
|
|
{
|
|
stepcontext.LogMessage($"Orginal master package = {masterPackage}");
|
|
stepcontext.LogMessage($"Current generated master package = {OutputGame}");
|
|
stepcontext.LogMessage($"Generated Patch package = {OutputPatch}");
|
|
|
|
new GenericCommand(PkgTool, commandLine)
|
|
.Execute(stepcontext);
|
|
});
|
|
}
|
|
|
|
protected void CopyMasterPackageToDiscWorkingDirectory(IStep stepcontext)
|
|
{
|
|
// Copy master's package to the working disc's directory
|
|
stepcontext.LogMessage("== Master package copy step ==");
|
|
var fromPackage = MasterPackagePath;
|
|
var toPackage = Path.Combine(WorkingDirectory, "orginal_master");
|
|
stepcontext.LogMessage($"Starting to copy master package from {fromPackage} to {toPackage}");
|
|
RoboCopy.ReplicateDirectory(fromPackage, toPackage, stepcontext, deleteMissingFiles: false);
|
|
}
|
|
|
|
protected void CopyMasterTuPackageToDiscWorkingDirectory(IStep stepcontext)
|
|
{
|
|
// Copy master TU package to the working disc's directory
|
|
stepcontext.LogMessage("== Master TU package copy step ==");
|
|
var fromPackage = LastTuPackagePath;
|
|
var toPackage = Path.Combine(WorkingDirectory, "last_tu");
|
|
stepcontext.LogMessage($"Starting to copy master TU package from {fromPackage} to {toPackage}");
|
|
RoboCopy.ReplicateDirectory(fromPackage, toPackage, stepcontext, deleteMissingFiles: false);
|
|
}
|
|
}
|
|
} |