From 18c08b2719e8c6ac146ad6b53fd0ab7257e6e66b Mon Sep 17 00:00:00 2001 From: Deterous <138427222+Deterous@users.noreply.github.com> Date: Thu, 19 Dec 2024 21:29:41 +0900 Subject: [PATCH 01/12] Use Nanook.GrindCore for GZipStream --- IRDKit/IRDKit.csproj | 3 ++- IRDKit/Program.cs | 7 ++++--- LibIRD/IRD.cs | 31 +++++++------------------------ LibIRD/LibIRD.csproj | 10 +++------- 4 files changed, 16 insertions(+), 35 deletions(-) diff --git a/IRDKit/IRDKit.csproj b/IRDKit/IRDKit.csproj index 3ac14b6..20b8d30 100644 --- a/IRDKit/IRDKit.csproj +++ b/IRDKit/IRDKit.csproj @@ -11,7 +11,7 @@ latest true true - 0.9.3 + 0.9.4 Deterous @@ -30,6 +30,7 @@ + diff --git a/IRDKit/Program.cs b/IRDKit/Program.cs index 89ffed9..64c6d4b 100644 --- a/IRDKit/Program.cs +++ b/IRDKit/Program.cs @@ -5,8 +5,9 @@ using System.Linq; using System.Text; using System.Xml.Linq; -using CommandLine; using LibIRD; +using CommandLine; +using GrindCore; using SabreTools.Hashing; using SabreTools.RedumpLib.Web; @@ -1061,7 +1062,7 @@ public static void RenameIRD(string irdPath, XDocument datfile, bool serial = fa } } -#endregion + #endregion #region Helper Functions @@ -1073,7 +1074,7 @@ public static void RenameIRD(string irdPath, XDocument datfile, bool serial = fa static byte[] Decompress(byte[] data) { using var compressedStream = new MemoryStream(data); - using var zipStream = new GZipStream(compressedStream, CompressionMode.Decompress); + using var zipStream = new Nanook.GrindCore.GZip.GZipStream(compressedStream, CompressionMode.Decompress); using var resultStream = new MemoryStream(); zipStream.CopyTo(resultStream); return resultStream.ToArray(); diff --git a/LibIRD/IRD.cs b/LibIRD/IRD.cs index 86713ec..cb46a8c 100644 --- a/LibIRD/IRD.cs +++ b/LibIRD/IRD.cs @@ -7,6 +7,7 @@ using LibIRD.DiscUtils; using LibIRD.DiscUtils.Iso9660; using LibIRD.DiscUtils.Streams; +using GrindCore; using SabreTools.Hashing; namespace LibIRD @@ -788,7 +789,7 @@ private protected void GenerateIRD(string isoPath, bool redump = false) HashISO(fs, redump && UID == 0x00000000); } -#endregion + #endregion #region Reading ISO @@ -854,13 +855,7 @@ private void GetHeader(FileStream fs, CDReader reader) // Begin a GZip stream to write header to using MemoryStream headerStream = new(); -#if NET6_0_OR_GREATER - using (GZipStream gzStream = new(headerStream, CompressionLevel.SmallestSize)) -#elif NETCOREAPP || NET45_OR_GREATER - using (GZipStream gzStream = new(headerStream, CompressionLevel.Optimal)) -#else - using (GZipStream gzStream = new(headerStream, CompressionMode.Compress)) -#endif + using (Nanook.GrindCore.GZip.GZipStream gzStream = new(headerStream, CompressionLevel.SmallestSize)) { // Start reading data from the beginning of the ISO file fs.Seek(0, SeekOrigin.Begin); @@ -888,13 +883,7 @@ private void GetFooter(FileStream fs) { // Begin a GZip stream to write footer to using MemoryStream footerStream = new(); -#if NET6_0_OR_GREATER - using (GZipStream gzStream = new(footerStream, CompressionLevel.SmallestSize)) -#elif NETCOREAPP || NET45_OR_GREATER - using (GZipStream gzStream = new(footerStream, CompressionLevel.Optimal)) -#else - using (GZipStream gzStream = new(footerStream, CompressionMode.Compress)) -#endif + using (Nanook.GrindCore.GZip.GZipStream gzStream = new(footerStream, CompressionLevel.SmallestSize)) { // Start reading data from after last file (PS3UPDAT.PUP) fs.Seek(UpdateEnd, SeekOrigin.Begin); @@ -1427,13 +1416,7 @@ public void Write(string irdPath) // Create the IRD file stream using FileStream fs = new(irdPath, FileMode.Create, FileAccess.Write); // Create a GZipped IRD file stream -#if NET6_0_OR_GREATER - using GZipStream gzStream = new(fs, CompressionLevel.SmallestSize); -#elif NETCOREAPP || NET45_OR_GREATER - using GZipStream gzStream = new(fs, CompressionLevel.Optimal); -#else - using GZipStream gzStream = new(fs, CompressionMode.Compress); -#endif + using Nanook.GrindCore.GZip.GZipStream gzStream = new(fs, CompressionLevel.SmallestSize); // Write entire gzipped IRD stream to file stream.Position = 0; #if NET40_OR_GREATER || NETCOREAPP @@ -1462,7 +1445,7 @@ public static IRD Read(string irdPath) // Open IRD for reading using FileStream fs = new(irdPath, FileMode.Open, FileAccess.Read); - using GZipStream gzs = new(fs, CompressionMode.Decompress); + using Nanook.GrindCore.GZip.GZipStream gzs = new(fs, CompressionMode.Decompress); using BinaryReader br = new(gzs); // Check for IRD file signature @@ -1655,7 +1638,7 @@ public void PrintJson(string jsonPath = null, bool single = true) } } -#endregion + #endregion #region Helper Functions diff --git a/LibIRD/LibIRD.csproj b/LibIRD/LibIRD.csproj index 8a2ff15..f770f61 100644 --- a/LibIRD/LibIRD.csproj +++ b/LibIRD/LibIRD.csproj @@ -7,7 +7,7 @@ latest true true - 0.9.3 + 0.9.4 ../nupkg @@ -30,19 +30,15 @@ - net20;net35;net40;net452;net462;net472;net48;netcoreapp3.1;net5.0;net6.0;net7.0;net8.0;net9.0 + netcoreapp3.1;net5.0;net6.0;net7.0;net8.0;net9.0 - - - - - + From d071d26d4c645cecb8251fac8825e4475f344c24 Mon Sep 17 00:00:00 2001 From: Deterous <138427222+Deterous@users.noreply.github.com> Date: Thu, 19 Dec 2024 21:47:33 +0900 Subject: [PATCH 02/12] GitHub Actions --- .github/workflows/build.yml | 40 +++++++++++++++++++++++++++++++++++++ 1 file changed, 40 insertions(+) create mode 100644 .github/workflows/build.yml diff --git a/.github/workflows/build.yml b/.github/workflows/build.yml new file mode 100644 index 0000000..effb90b --- /dev/null +++ b/.github/workflows/build.yml @@ -0,0 +1,40 @@ +name: Build + +on: + push: {} + +jobs: + build: + runs-on: ubuntu-latest + + strategy: + matrix: + project: [IRDKit] + runtime: [win-x86, win-x64, win-arm64, linux-x64, linux-arm64, osx-x64, osx-arm64] + framework: [net9.0] + conf: [Release] + + steps: + - uses: actions/checkout@v4 + + - name: Setup .NET + uses: actions/setup-dotnet@v4 + with: + dotnet-version: 9.0.x + + - name: Restore dependencies + run: dotnet restore + + - name: Build + run: dotnet publish ${{ matrix.project }}/${{ matrix.project }}.csproj -f ${{ matrix.framework }} -r ${{ matrix.runtime }} -c ${{ 'Release -p:DebugType=None -p:DebugSymbols=false'}} --self-contained true}} + + - name: Archive build + run: | + cd ${{ matrix.project }}/bin/${{ matrix.conf }}/${{ matrix.framework }}/${{ matrix.runtime }}/publish/ + zip -r ${{ github.workspace }}/${{ matrix.project }}_${{ matrix.framework }}_${{ matrix.runtime }}_${{ matrix.conf }}.zip ./ + + - name: Upload build + uses: actions/upload-artifact@v4 + with: + name: ${{ matrix.project }}_${{ matrix.framework }}_${{ matrix.runtime }}_${{ matrix.conf }} + path: ${{ matrix.project }}_${{ matrix.framework }}_${{ matrix.runtime }}_${{ matrix.conf }}.zip From ceeabf346765f600686a56ea2d1b553f8ddbf1fe Mon Sep 17 00:00:00 2001 From: Deterous <138427222+Deterous@users.noreply.github.com> Date: Thu, 19 Dec 2024 21:53:29 +0900 Subject: [PATCH 03/12] Fix GHA --- .github/workflows/build.yml | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/.github/workflows/build.yml b/.github/workflows/build.yml index effb90b..1ac3078 100644 --- a/.github/workflows/build.yml +++ b/.github/workflows/build.yml @@ -26,7 +26,7 @@ jobs: run: dotnet restore - name: Build - run: dotnet publish ${{ matrix.project }}/${{ matrix.project }}.csproj -f ${{ matrix.framework }} -r ${{ matrix.runtime }} -c ${{ 'Release -p:DebugType=None -p:DebugSymbols=false'}} --self-contained true}} + run: dotnet publish ${{ matrix.project }}/${{ matrix.project }}.csproj -f ${{ matrix.framework }} -r ${{ matrix.runtime }} -c Release -p:DebugType=None -p:DebugSymbols=false --self-contained true}} - name: Archive build run: | From 88ba257fa1fe95ac818f5968f72535dba738dd44 Mon Sep 17 00:00:00 2001 From: Deterous <138427222+Deterous@users.noreply.github.com> Date: Thu, 19 Dec 2024 21:57:04 +0900 Subject: [PATCH 04/12] Final GHA --- .github/workflows/build.yml | 11 +++++------ 1 file changed, 5 insertions(+), 6 deletions(-) diff --git a/.github/workflows/build.yml b/.github/workflows/build.yml index 1ac3078..c38ccc9 100644 --- a/.github/workflows/build.yml +++ b/.github/workflows/build.yml @@ -12,7 +12,6 @@ jobs: project: [IRDKit] runtime: [win-x86, win-x64, win-arm64, linux-x64, linux-arm64, osx-x64, osx-arm64] framework: [net9.0] - conf: [Release] steps: - uses: actions/checkout@v4 @@ -26,15 +25,15 @@ jobs: run: dotnet restore - name: Build - run: dotnet publish ${{ matrix.project }}/${{ matrix.project }}.csproj -f ${{ matrix.framework }} -r ${{ matrix.runtime }} -c Release -p:DebugType=None -p:DebugSymbols=false --self-contained true}} + run: dotnet publish ${{ matrix.project }}/${{ matrix.project }}.csproj -f ${{ matrix.framework }} -r ${{ matrix.runtime }} -c Release -p:DebugType=None -p:DebugSymbols=false --self-contained true - name: Archive build run: | - cd ${{ matrix.project }}/bin/${{ matrix.conf }}/${{ matrix.framework }}/${{ matrix.runtime }}/publish/ - zip -r ${{ github.workspace }}/${{ matrix.project }}_${{ matrix.framework }}_${{ matrix.runtime }}_${{ matrix.conf }}.zip ./ + cd ${{ matrix.project }}/bin/Release/${{ matrix.framework }}/${{ matrix.runtime }}/publish/ + zip -r ${{ github.workspace }}/${{ matrix.project }}_${{ matrix.framework }}_${{ matrix.runtime }}.zip ./ - name: Upload build uses: actions/upload-artifact@v4 with: - name: ${{ matrix.project }}_${{ matrix.framework }}_${{ matrix.runtime }}_${{ matrix.conf }} - path: ${{ matrix.project }}_${{ matrix.framework }}_${{ matrix.runtime }}_${{ matrix.conf }}.zip + name: ${{ matrix.project }}_${{ matrix.framework }}_${{ matrix.runtime }} + path: ${{ matrix.project }}_${{ matrix.framework }}_${{ matrix.runtime }}.zip From d4ca7313236e5cd8fe8889a53f48392edc9371c6 Mon Sep 17 00:00:00 2001 From: Deterous <138427222+Deterous@users.noreply.github.com> Date: Thu, 19 Dec 2024 21:59:07 +0900 Subject: [PATCH 05/12] submodules in GHA --- .github/workflows/build.yml | 2 ++ 1 file changed, 2 insertions(+) diff --git a/.github/workflows/build.yml b/.github/workflows/build.yml index c38ccc9..c17bdc0 100644 --- a/.github/workflows/build.yml +++ b/.github/workflows/build.yml @@ -15,6 +15,8 @@ jobs: steps: - uses: actions/checkout@v4 + with: + submodules: 'true' - name: Setup .NET uses: actions/setup-dotnet@v4 From 0e22d2b4d353a6f89912899ff9e0c12bd399449a Mon Sep 17 00:00:00 2001 From: Deterous <138427222+Deterous@users.noreply.github.com> Date: Thu, 19 Dec 2024 22:02:08 +0900 Subject: [PATCH 06/12] Fix using --- IRDKit/Program.cs | 4 ++-- LibIRD/IRD.cs | 2 +- 2 files changed, 3 insertions(+), 3 deletions(-) diff --git a/IRDKit/Program.cs b/IRDKit/Program.cs index 64c6d4b..277fc7f 100644 --- a/IRDKit/Program.cs +++ b/IRDKit/Program.cs @@ -5,9 +5,9 @@ using System.Linq; using System.Text; using System.Xml.Linq; -using LibIRD; using CommandLine; -using GrindCore; +using LibIRD; +using Nanook.GrindCore; using SabreTools.Hashing; using SabreTools.RedumpLib.Web; diff --git a/LibIRD/IRD.cs b/LibIRD/IRD.cs index cb46a8c..81d37a9 100644 --- a/LibIRD/IRD.cs +++ b/LibIRD/IRD.cs @@ -7,7 +7,7 @@ using LibIRD.DiscUtils; using LibIRD.DiscUtils.Iso9660; using LibIRD.DiscUtils.Streams; -using GrindCore; +using Nanook.GrindCore; using SabreTools.Hashing; namespace LibIRD From 6cafb5a48d9699d5f0d68623910fb7fb2ec905eb Mon Sep 17 00:00:00 2001 From: Deterous <138427222+Deterous@users.noreply.github.com> Date: Thu, 19 Dec 2024 22:04:14 +0900 Subject: [PATCH 07/12] Fix namespace --- IRDKit/Program.cs | 2 +- LibIRD/IRD.cs | 8 ++++---- 2 files changed, 5 insertions(+), 5 deletions(-) diff --git a/IRDKit/Program.cs b/IRDKit/Program.cs index 277fc7f..9d53ea1 100644 --- a/IRDKit/Program.cs +++ b/IRDKit/Program.cs @@ -1074,7 +1074,7 @@ public static void RenameIRD(string irdPath, XDocument datfile, bool serial = fa static byte[] Decompress(byte[] data) { using var compressedStream = new MemoryStream(data); - using var zipStream = new Nanook.GrindCore.GZip.GZipStream(compressedStream, CompressionMode.Decompress); + using var zipStream = new Nanook.GrindCore.GZip.GZipStream(compressedStream, Nanook.GrindCore.CompressionMode.Decompress); using var resultStream = new MemoryStream(); zipStream.CopyTo(resultStream); return resultStream.ToArray(); diff --git a/LibIRD/IRD.cs b/LibIRD/IRD.cs index 81d37a9..c293be6 100644 --- a/LibIRD/IRD.cs +++ b/LibIRD/IRD.cs @@ -855,7 +855,7 @@ private void GetHeader(FileStream fs, CDReader reader) // Begin a GZip stream to write header to using MemoryStream headerStream = new(); - using (Nanook.GrindCore.GZip.GZipStream gzStream = new(headerStream, CompressionLevel.SmallestSize)) + using (Nanook.GrindCore.GZip.GZipStream gzStream = new(headerStream, Nanook.GrindCore.CompressionLevel.SmallestSize)) { // Start reading data from the beginning of the ISO file fs.Seek(0, SeekOrigin.Begin); @@ -883,7 +883,7 @@ private void GetFooter(FileStream fs) { // Begin a GZip stream to write footer to using MemoryStream footerStream = new(); - using (Nanook.GrindCore.GZip.GZipStream gzStream = new(footerStream, CompressionLevel.SmallestSize)) + using (Nanook.GrindCore.GZip.GZipStream gzStream = new(footerStream, Nanook.GrindCore.CompressionLevel.SmallestSize)) { // Start reading data from after last file (PS3UPDAT.PUP) fs.Seek(UpdateEnd, SeekOrigin.Begin); @@ -1416,7 +1416,7 @@ public void Write(string irdPath) // Create the IRD file stream using FileStream fs = new(irdPath, FileMode.Create, FileAccess.Write); // Create a GZipped IRD file stream - using Nanook.GrindCore.GZip.GZipStream gzStream = new(fs, CompressionLevel.SmallestSize); + using Nanook.GrindCore.GZip.GZipStream gzStream = new(fs, Nanook.GrindCore.CompressionLevel.SmallestSize); // Write entire gzipped IRD stream to file stream.Position = 0; #if NET40_OR_GREATER || NETCOREAPP @@ -1445,7 +1445,7 @@ public static IRD Read(string irdPath) // Open IRD for reading using FileStream fs = new(irdPath, FileMode.Open, FileAccess.Read); - using Nanook.GrindCore.GZip.GZipStream gzs = new(fs, CompressionMode.Decompress); + using Nanook.GrindCore.GZip.GZipStream gzs = new(fs, Nanook.GrindCore.CompressionMode.Decompress); using BinaryReader br = new(gzs); // Check for IRD file signature From 5249e540cc522e0731d43f8a26e233a0883c6c87 Mon Sep 17 00:00:00 2001 From: Deterous <138427222+Deterous@users.noreply.github.com> Date: Thu, 19 Dec 2024 22:10:19 +0900 Subject: [PATCH 08/12] Don't build self contained --- .github/workflows/build.yml | 4 ++-- IRDKit/IRDKit.csproj | 3 ++- LibIRD/LibIRD.csproj | 1 + 3 files changed, 5 insertions(+), 3 deletions(-) diff --git a/.github/workflows/build.yml b/.github/workflows/build.yml index c17bdc0..e88e481 100644 --- a/.github/workflows/build.yml +++ b/.github/workflows/build.yml @@ -11,7 +11,7 @@ jobs: matrix: project: [IRDKit] runtime: [win-x86, win-x64, win-arm64, linux-x64, linux-arm64, osx-x64, osx-arm64] - framework: [net9.0] + framework: [net8.0] steps: - uses: actions/checkout@v4 @@ -27,7 +27,7 @@ jobs: run: dotnet restore - name: Build - run: dotnet publish ${{ matrix.project }}/${{ matrix.project }}.csproj -f ${{ matrix.framework }} -r ${{ matrix.runtime }} -c Release -p:DebugType=None -p:DebugSymbols=false --self-contained true + run: dotnet publish ${{ matrix.project }}/${{ matrix.project }}.csproj -f ${{ matrix.framework }} -r ${{ matrix.runtime }} -c Release -p:DebugType=None -p:DebugSymbols=false - name: Archive build run: | diff --git a/IRDKit/IRDKit.csproj b/IRDKit/IRDKit.csproj index 20b8d30..1ed3ee9 100644 --- a/IRDKit/IRDKit.csproj +++ b/IRDKit/IRDKit.csproj @@ -5,11 +5,12 @@ Exe irdkit irdkit - net6.0;net7.0;net8.0;net9.0 + net6.0;net7.0;net8.0;net9.0 win-x86;win-x64;win-arm64;linux-x64;linux-arm64;osx-x64;osx-arm64 false latest true + true true 0.9.4 diff --git a/LibIRD/LibIRD.csproj b/LibIRD/LibIRD.csproj index f770f61..24d0355 100644 --- a/LibIRD/LibIRD.csproj +++ b/LibIRD/LibIRD.csproj @@ -6,6 +6,7 @@ false latest true + true true 0.9.4 ../nupkg From 4414db49b26aaf155e29ab58f3cdba0f5ded989b Mon Sep 17 00:00:00 2001 From: Deterous <138427222+Deterous@users.noreply.github.com> Date: Thu, 19 Dec 2024 22:23:23 +0900 Subject: [PATCH 09/12] single file build --- IRDKit/IRDKit.csproj | 2 ++ 1 file changed, 2 insertions(+) diff --git a/IRDKit/IRDKit.csproj b/IRDKit/IRDKit.csproj index 1ed3ee9..3c11923 100644 --- a/IRDKit/IRDKit.csproj +++ b/IRDKit/IRDKit.csproj @@ -11,6 +11,8 @@ latest true true + true + false true 0.9.4 From 6f0c5483cbd09a07b2aad9f4decff4bbe94da317 Mon Sep 17 00:00:00 2001 From: Deterous <138427222+Deterous@users.noreply.github.com> Date: Thu, 19 Dec 2024 22:28:31 +0900 Subject: [PATCH 10/12] dont zip --- .github/workflows/build.yml | 7 +------ 1 file changed, 1 insertion(+), 6 deletions(-) diff --git a/.github/workflows/build.yml b/.github/workflows/build.yml index e88e481..1ffc186 100644 --- a/.github/workflows/build.yml +++ b/.github/workflows/build.yml @@ -28,14 +28,9 @@ jobs: - name: Build run: dotnet publish ${{ matrix.project }}/${{ matrix.project }}.csproj -f ${{ matrix.framework }} -r ${{ matrix.runtime }} -c Release -p:DebugType=None -p:DebugSymbols=false - - - name: Archive build - run: | - cd ${{ matrix.project }}/bin/Release/${{ matrix.framework }}/${{ matrix.runtime }}/publish/ - zip -r ${{ github.workspace }}/${{ matrix.project }}_${{ matrix.framework }}_${{ matrix.runtime }}.zip ./ - name: Upload build uses: actions/upload-artifact@v4 with: name: ${{ matrix.project }}_${{ matrix.framework }}_${{ matrix.runtime }} - path: ${{ matrix.project }}_${{ matrix.framework }}_${{ matrix.runtime }}.zip + path: ${{ matrix.project }}/bin/Release/${{ matrix.framework }}/${{ matrix.runtime }}/publish/irdkit.exe From be737f630458539383d49ab6bf6770a620bfa8aa Mon Sep 17 00:00:00 2001 From: Deterous <138427222+Deterous@users.noreply.github.com> Date: Thu, 19 Dec 2024 22:32:11 +0900 Subject: [PATCH 11/12] test --- .github/workflows/build.yml | 8 +++++++- 1 file changed, 7 insertions(+), 1 deletion(-) diff --git a/.github/workflows/build.yml b/.github/workflows/build.yml index 1ffc186..4d38fc1 100644 --- a/.github/workflows/build.yml +++ b/.github/workflows/build.yml @@ -28,9 +28,15 @@ jobs: - name: Build run: dotnet publish ${{ matrix.project }}/${{ matrix.project }}.csproj -f ${{ matrix.framework }} -r ${{ matrix.runtime }} -c Release -p:DebugType=None -p:DebugSymbols=false + + - name: Archive build + run: | + pwd + cd ${{ matrix.project }}/bin/Release/${{ matrix.framework }}/${{ matrix.runtime }}/publish/ + ls - name: Upload build uses: actions/upload-artifact@v4 with: name: ${{ matrix.project }}_${{ matrix.framework }}_${{ matrix.runtime }} - path: ${{ matrix.project }}/bin/Release/${{ matrix.framework }}/${{ matrix.runtime }}/publish/irdkit.exe + path: ${{ matrix.project }}/bin/Release/${{ matrix.framework }}/${{ matrix.runtime }}/publish/* From f9c4580c9c877aadc584ba65f7c10eac1bced0b7 Mon Sep 17 00:00:00 2001 From: Deterous <138427222+Deterous@users.noreply.github.com> Date: Thu, 19 Dec 2024 22:34:16 +0900 Subject: [PATCH 12/12] Finalise GHA --- .github/workflows/build.yml | 6 ------ 1 file changed, 6 deletions(-) diff --git a/.github/workflows/build.yml b/.github/workflows/build.yml index 4d38fc1..d6326c5 100644 --- a/.github/workflows/build.yml +++ b/.github/workflows/build.yml @@ -28,12 +28,6 @@ jobs: - name: Build run: dotnet publish ${{ matrix.project }}/${{ matrix.project }}.csproj -f ${{ matrix.framework }} -r ${{ matrix.runtime }} -c Release -p:DebugType=None -p:DebugSymbols=false - - - name: Archive build - run: | - pwd - cd ${{ matrix.project }}/bin/Release/${{ matrix.framework }}/${{ matrix.runtime }}/publish/ - ls - name: Upload build uses: actions/upload-artifact@v4