diff --git a/.github/workflows/upsync-linux.yaml b/.github/workflows/upsync-linux.yaml new file mode 100644 index 00000000..92b5e29f --- /dev/null +++ b/.github/workflows/upsync-linux.yaml @@ -0,0 +1,45 @@ +name: Build Upsync Linux + +on: + push: + branches: + - master + pull_request: + branches: + - master + 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..09da8fc8 --- /dev/null +++ b/.github/workflows/upsync-windows.yaml @@ -0,0 +1,39 @@ +name: Build Upsync Windows + +on: + push: + branches: + - master + pull_request: + branches: + - master + 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/CabinetUtility.cs b/src/microsoft-update-partition/CabinetUtility.cs index ad518634..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}\"") + var startInfo = new ProcessStartInfo { + FileName = "cabextract", + Arguments = $"--pipe \"{cabTempFile}\"", UseShellExecute = false, // The decompressed text is Unicode StandardOutputEncoding = Encoding.Unicode, @@ -108,12 +111,20 @@ 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); using var recompressor = new GZipStream(inMemoryStream, CompressionLevel.Fastest, true); - recompressor.Write(Encoding.UTF8.GetBytes(text)); + decompressor.CopyTo(recompressor); } catch (Exception) @@ -126,6 +137,11 @@ static byte[] RecompressUnicodeDataLinux(byte[] compressedData) File.Delete(cabTempFile); } + if (File.Exists(xmlTempFile)) + { + File.Delete(xmlTempFile); + } + if (inMemoryStream != null) { return inMemoryStream.ToArray(); 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/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)) { 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