From cbb1e9bd5fc58aee92749fe7187af63a7870bcb7 Mon Sep 17 00:00:00 2001 From: tprudhomme Date: Mon, 10 Feb 2025 17:46:50 +0100 Subject: [PATCH 1/5] fix cabextract usage --- src/microsoft-update-partition/CabinetUtility.cs | 5 +++-- 1 file changed, 3 insertions(+), 2 deletions(-) diff --git a/src/microsoft-update-partition/CabinetUtility.cs b/src/microsoft-update-partition/CabinetUtility.cs index ad518634..c43829a7 100644 --- a/src/microsoft-update-partition/CabinetUtility.cs +++ b/src/microsoft-update-partition/CabinetUtility.cs @@ -98,7 +98,7 @@ static byte[] RecompressUnicodeDataLinux(byte[] compressedData) { File.WriteAllBytes(cabTempFile, compressedData); - var startInfo = new ProcessStartInfo("cabextract", $"--pipe \"{cabTempFile}\"") + var startInfo = new ProcessStartInfo("cabextract", $"--pipe \"{cabTempFile}\" > \"{xmlTempFile}\"") { UseShellExecute = false, // The decompressed text is Unicode @@ -112,8 +112,9 @@ static byte[] RecompressUnicodeDataLinux(byte[] compressedData) expandProcess.WaitForExit(); // Recompress the XML with GZIP as UTF8 + using var decompressor = File.OpenRead(xmlTempFile); using var recompressor = new GZipStream(inMemoryStream, CompressionLevel.Fastest, true); - recompressor.Write(Encoding.UTF8.GetBytes(text)); + decompressor.CopyTo(recompressor); } catch (Exception) From c04ca86dfcf165049835779d9d09b0557d6177c0 Mon Sep 17 00:00:00 2001 From: osvegn Date: Tue, 11 Feb 2025 10:41:35 +0100 Subject: [PATCH 2/5] fix redirect on linux --- .../CabinetUtility.cs | 23 +++++++++++++++---- 1 file changed, 19 insertions(+), 4 deletions(-) diff --git a/src/microsoft-update-partition/CabinetUtility.cs b/src/microsoft-update-partition/CabinetUtility.cs index c43829a7..4bbde823 100644 --- a/src/microsoft-update-partition/CabinetUtility.cs +++ b/src/microsoft-update-partition/CabinetUtility.cs @@ -92,14 +92,17 @@ static byte[] RecompressUnicodeDataLinux(byte[] compressedData) // We use temporary files to write the in-memory cabinet, // Then run cabextract on it with --pipe output var cabTempFile = Path.GetTempFileName(); - + var xmlTempFile = Path.GetTempFileName(); + var inMemoryStream = new MemoryStream(); try { File.WriteAllBytes(cabTempFile, compressedData); - var startInfo = new ProcessStartInfo("cabextract", $"--pipe \"{cabTempFile}\" > \"{xmlTempFile}\"") + var startInfo = new ProcessStartInfo { + FileName = "cabextract", + Arguments = $"--pipe \"{cabTempFile}\"", UseShellExecute = false, // The decompressed text is Unicode StandardOutputEncoding = Encoding.Unicode, @@ -108,8 +111,15 @@ static byte[] RecompressUnicodeDataLinux(byte[] compressedData) var expandProcess = Process.Start(startInfo); // Read the decompressed data from the pipe - var text = expandProcess.StandardOutput.ReadToEnd(); - expandProcess.WaitForExit(); + if (expandProcess != null) + { + using (StreamWriter writer = new StreamWriter(xmlTempFile)) + { + expandProcess.StandardOutput.BaseStream.CopyTo(writer.BaseStream); + } + + expandProcess.WaitForExit(); + } // Recompress the XML with GZIP as UTF8 using var decompressor = File.OpenRead(xmlTempFile); @@ -127,6 +137,11 @@ static byte[] RecompressUnicodeDataLinux(byte[] compressedData) File.Delete(cabTempFile); } + if (File.Exists(xmlTempFile)) + { + File.Delete(xmlTempFile); + } + if (inMemoryStream != null) { return inMemoryStream.ToArray(); From c7b88fea3ea83ec8eaf5a6270c46c4cb5c3e8f6c Mon Sep 17 00:00:00 2001 From: Simon Fonteneau Date: Thu, 13 Feb 2025 23:29:18 +0100 Subject: [PATCH 3/5] Add Github action and switch net6.0 to net9.0 --- .github/workflows/upsync-linux.yaml | 45 +++++++++++++++++++ .github/workflows/upsync-windows.yaml | 39 ++++++++++++++++ .../microsoft-update-endpoints.csproj | 2 +- .../microsoft-update-partition.csproj | 2 +- .../microsoft-update-upstream-source.csproj | 2 +- .../microsoft-update-webservices.csproj | 2 +- src/samples/samples.csproj | 2 +- src/tools/upsync/upsync.csproj | 2 +- 8 files changed, 90 insertions(+), 6 deletions(-) create mode 100644 .github/workflows/upsync-linux.yaml create mode 100644 .github/workflows/upsync-windows.yaml diff --git a/.github/workflows/upsync-linux.yaml b/.github/workflows/upsync-linux.yaml new file mode 100644 index 00000000..6437f668 --- /dev/null +++ b/.github/workflows/upsync-linux.yaml @@ -0,0 +1,45 @@ +name: Build Upsync Linux + +on: + push: + branches: + - main + pull_request: + branches: + - main + workflow_dispatch: + +jobs: + build: + runs-on: ubuntu-latest + + steps: + - name: Checkout repository + uses: actions/checkout@v4 + + - name: Setup .NET 9 + uses: actions/setup-dotnet@v3 + with: + dotnet-version: '9.0.x' + + - name: Publish Upsync + run: | + dotnet publish -p:PublishSingleFile=true --self-contained -c Release src/tools/upsync/upsync.csproj + + - name: Copy MicRooCerAut2011_2011_03_22 + run: | + echo "-----BEGIN CERTIFICATE-----" > out/upsync/Release/net9.0/linux-x64/publish/MicRooCerAut2011_2011_03_22.crt && curl -s https://www.microsoft.com/pki/certs/MicRooCerAut2011_2011_03_22.crt | openssl base64 >> out/upsync/Release/net9.0/linux-x64/publish/MicRooCerAut2011_2011_03_22.crt && echo "-----END CERTIFICATE-----" >> out/upsync/Release/net9.0/linux-x64/publish/MicRooCerAut2011_2011_03_22.crt + + - name: Create requirement.sh + run: | + echo "sudo apt-get install -y cabextract && cp MicRooCerAut2011_2011_03_22.crt /usr/local/share/ca-certificates/MicRooCerAut2011_2011_03_22.crt && sudo update-ca-certificates" > out/upsync/Release/net9.0/linux-x64/publish/requirement.sh + + - name: Create ZIP of the artifact + run: | + zip -jr out/upsync-linux.zip out/upsync/Release/net9.0/linux-x64/publish/* + + - name: Upload build logs to release + uses: softprops/action-gh-release@v1 + with: + tag_name: linux-${{ github.sha }} + files: out/upsync-linux.zip \ No newline at end of file diff --git a/.github/workflows/upsync-windows.yaml b/.github/workflows/upsync-windows.yaml new file mode 100644 index 00000000..2002c59a --- /dev/null +++ b/.github/workflows/upsync-windows.yaml @@ -0,0 +1,39 @@ +name: Build Upsync Windows + +on: + push: + branches: + - main + pull_request: + branches: + - main + workflow_dispatch: + +jobs: + build: + runs-on: windows-latest + + steps: + - name: Checkout repository + uses: actions/checkout@v4 + + - name: Setup .NET 9 + uses: actions/setup-dotnet@v3 + with: + dotnet-version: '9.0.x' + + - name: Publish Upsync + run: | + dotnet publish -p:PublishSingleFile=true --self-contained -c Release src/tools/upsync/upsync.csproj + + + - name: Create ZIP of the artifact (Windows) + run: | + powershell Compress-Archive -Path out/upsync/Release/net9.0/win-x64/publish/* -DestinationPath out/upsync-windows.zip + + - name: Upload artifact to GitHub Release + uses: softprops/action-gh-release@v1 + with: + tag_name: windows-${{ github.sha }} + files: out/upsync-windows.zip + \ No newline at end of file diff --git a/src/microsoft-update-endpoints/microsoft-update-endpoints.csproj b/src/microsoft-update-endpoints/microsoft-update-endpoints.csproj index fa991ca3..84d4430f 100644 --- a/src/microsoft-update-endpoints/microsoft-update-endpoints.csproj +++ b/src/microsoft-update-endpoints/microsoft-update-endpoints.csproj @@ -1,7 +1,7 @@  - net6.0 + net9.0 Microsoft.PackageGraph.MicrosoftUpdate.Endpoints package-graph-endpoints-microsoft-update Microsoft.PackageGraph.MicrosoftUpdate.Endpoints diff --git a/src/microsoft-update-partition/microsoft-update-partition.csproj b/src/microsoft-update-partition/microsoft-update-partition.csproj index 121ddca3..8d633f95 100644 --- a/src/microsoft-update-partition/microsoft-update-partition.csproj +++ b/src/microsoft-update-partition/microsoft-update-partition.csproj @@ -1,7 +1,7 @@  - net6.0 + net9.0 Microsoft.PackageGraph.MicrosoftUpdate Microsoft.PackageGraph.MicrosoftUpdate Cristian Petruta diff --git a/src/microsoft-update-upstream-package-source/microsoft-update-upstream-source.csproj b/src/microsoft-update-upstream-package-source/microsoft-update-upstream-source.csproj index 15891ef9..38e8c55a 100644 --- a/src/microsoft-update-upstream-package-source/microsoft-update-upstream-source.csproj +++ b/src/microsoft-update-upstream-package-source/microsoft-update-upstream-source.csproj @@ -1,7 +1,7 @@  - net6.0 + net9.0 Microsoft.PackageGraph.MicrosoftUpdate.Source false package-graph-microsoftupdate-source diff --git a/src/microsoft-update-webservices/microsoft-update-webservices.csproj b/src/microsoft-update-webservices/microsoft-update-webservices.csproj index 649a2ca9..781b31f5 100644 --- a/src/microsoft-update-webservices/microsoft-update-webservices.csproj +++ b/src/microsoft-update-webservices/microsoft-update-webservices.csproj @@ -1,7 +1,7 @@  - net6.0 + net9.0 microsoft-update-webservices Microsoft.UpdateServices.WebServices Microsoft.PackageGraph.MicrosoftUpdate.WebServices diff --git a/src/samples/samples.csproj b/src/samples/samples.csproj index 9726b471..a56eb013 100644 --- a/src/samples/samples.csproj +++ b/src/samples/samples.csproj @@ -2,7 +2,7 @@ Exe - net6.0 + net9.0 enable enable ..\..\out\samples diff --git a/src/tools/upsync/upsync.csproj b/src/tools/upsync/upsync.csproj index d03c220d..26a67944 100644 --- a/src/tools/upsync/upsync.csproj +++ b/src/tools/upsync/upsync.csproj @@ -2,7 +2,7 @@ Exe - net6.0 + net9.0 Microsoft.PackageGraph.Utilitites.Upsync upsync upsync From f22d91754878440ff9d3cacca9cd4290a68235b2 Mon Sep 17 00:00:00 2001 From: osvegn Date: Mon, 17 Feb 2025 12:20:02 +0100 Subject: [PATCH 4/5] GetAuthorizationCookie increase timeout --- .../Client/ClientAuthenticator.cs | 7 ++++++- 1 file changed, 6 insertions(+), 1 deletion(-) diff --git a/src/microsoft-update-upstream-package-source/Client/ClientAuthenticator.cs b/src/microsoft-update-upstream-package-source/Client/ClientAuthenticator.cs index abb3bd24..97591dab 100644 --- a/src/microsoft-update-upstream-package-source/Client/ClientAuthenticator.cs +++ b/src/microsoft-update-upstream-package-source/Client/ClientAuthenticator.cs @@ -159,7 +159,12 @@ private async Task GetAuthenticationInfo() { GetAuthConfigResponse authConfigResponse; - var httpBinding = new System.ServiceModel.BasicHttpBinding(); + var httpBinding = new System.ServiceModel.BasicHttpBinding() + { + ReceiveTimeout = new TimeSpan(0, 3, 0), + SendTimeout = new TimeSpan(0, 3, 0), + OpenTimeout = new TimeSpan(0, 3, 0) + }; var upstreamEndpoint = new System.ServiceModel.EndpointAddress(UpstreamEndpoint.ServerSyncURI); if (upstreamEndpoint.Uri.Scheme.Equals("https", StringComparison.OrdinalIgnoreCase)) { From 90a1332002caa1594fb61c03c66d5f3b5bef8368 Mon Sep 17 00:00:00 2001 From: osvegn Date: Mon, 17 Feb 2025 12:21:57 +0100 Subject: [PATCH 5/5] Fix github workflow trigger branch to master --- .github/workflows/upsync-linux.yaml | 4 ++-- .github/workflows/upsync-windows.yaml | 4 ++-- 2 files changed, 4 insertions(+), 4 deletions(-) diff --git a/.github/workflows/upsync-linux.yaml b/.github/workflows/upsync-linux.yaml index 6437f668..92b5e29f 100644 --- a/.github/workflows/upsync-linux.yaml +++ b/.github/workflows/upsync-linux.yaml @@ -3,10 +3,10 @@ name: Build Upsync Linux on: push: branches: - - main + - master pull_request: branches: - - main + - master workflow_dispatch: jobs: diff --git a/.github/workflows/upsync-windows.yaml b/.github/workflows/upsync-windows.yaml index 2002c59a..09da8fc8 100644 --- a/.github/workflows/upsync-windows.yaml +++ b/.github/workflows/upsync-windows.yaml @@ -3,10 +3,10 @@ name: Build Upsync Windows on: push: branches: - - main + - master pull_request: branches: - - main + - master workflow_dispatch: jobs: