82 lines
No EOL
3.2 KiB
C#
82 lines
No EOL
3.2 KiB
C#
using System.Collections.Generic;
|
|
using System.IO;
|
|
using System.Linq;
|
|
using TeaBox.Code;
|
|
using System.Xml;
|
|
using TeaBox.Macros;
|
|
|
|
namespace TeaBox.BuildVersion
|
|
{
|
|
internal class MakePs5PatchCommand : MakePs5PackageCommand
|
|
{
|
|
protected override void PrePackageImpl()
|
|
{
|
|
UpdateChunkMappingForPatch();
|
|
base.PrePackageImpl();
|
|
}
|
|
|
|
protected override void PackageDataAssemblyImpl(IStep stepcontext)
|
|
{
|
|
CopyExecutableFromOutput(stepcontext);
|
|
|
|
CopyDataMasterToDiscWorkingDirectory(stepcontext);
|
|
CopyPatchDataToDiscWorkingDirectory(stepcontext);
|
|
}
|
|
|
|
protected void UpdateChunkMappingForPatch()
|
|
{
|
|
// Values of attribute for file Element Of gp5
|
|
const string packageName = "patch_prospero.ipk";
|
|
const string chunkNumber = "0";
|
|
|
|
// Instantiate New XmlDocument And Load XML From File
|
|
var xmlDocument = new XmlDocument();
|
|
xmlDocument.Load(LayoutPath);
|
|
|
|
// Create file Element
|
|
var fileElement = xmlDocument.CreateElement("file");
|
|
// Set file Attributes
|
|
// destination path Attribute
|
|
var dstpathAttribute = xmlDocument.CreateAttribute("dst_path");
|
|
dstpathAttribute.Value = packageName;
|
|
fileElement.Attributes.Append(dstpathAttribute);
|
|
// source path Attribute
|
|
var srcpathAttribute = xmlDocument.CreateAttribute("src_path");
|
|
srcpathAttribute.Value = packageName;
|
|
fileElement.Attributes.Append(srcpathAttribute);
|
|
// chunk Attribute
|
|
var chunkAttribute = xmlDocument.CreateAttribute("chunk");
|
|
chunkAttribute.Value = chunkNumber;
|
|
fileElement.Attributes.Append(chunkAttribute);
|
|
|
|
// Insert file As Node Of files
|
|
var projectNode = xmlDocument.SelectSingleNode("psproject");
|
|
var filesNode = projectNode.SelectSingleNode("files");
|
|
filesNode.InsertAfter(fileElement, filesNode.LastChild);
|
|
|
|
// Save the XmlDocument
|
|
xmlDocument.Save(LayoutPath);
|
|
}
|
|
|
|
protected override void GeneratePackageImpl()
|
|
{
|
|
Context.AddStep("Creation output folder...", stepcontext =>
|
|
{
|
|
if (!System.IO.Directory.Exists(OutputDirectory))
|
|
{
|
|
System.IO.Directory.CreateDirectory(OutputDirectory);
|
|
}
|
|
});
|
|
|
|
var packageName = $"{UAFConstants.GameName}_pkg_{DataChangelist}_{Variant}.pkg";
|
|
var isoName = $"{UAFConstants.GameName}_iso_{DataChangelist}_{Variant}.iso";
|
|
|
|
PkgTool = Ps5Constants.GetPackageTool();
|
|
var directoryInfo = new System.IO.DirectoryInfo(GameConstants.GetMasterPackage(Platform, Region, Variant));
|
|
var masterPkgName = directoryInfo.GetFiles("*.pkg", SearchOption.AllDirectories).FirstOrDefault().FullName;
|
|
|
|
Context.AddStep("Creating package",
|
|
new GenericCommand(PkgTool, $"img_create --skip_digest --no_progress_bar --oformat {PkgFormat} --ref_pkg_path \"{masterPkgName}\" \"{LayoutPath}\" \"{Path.Combine(OutputDirectory, packageName)}\"").Execute);
|
|
}
|
|
}
|
|
} |