From 82c2f7be4614c388f389c2d050c03aff60338ac9 Mon Sep 17 00:00:00 2001 From: Jordan Borean Date: Thu, 5 Nov 2020 21:41:09 +1000 Subject: [PATCH 1/2] Added Fedora 33 and backup of installation --- CHANGELOG.md | 5 +++++ PSWSMan/PSWSMan.psm1 | 1 + azure-pipelines.yml | 2 ++ distribution_meta/fedora33.json | 30 ++++++++++++++++++++++++++++++ libmi.tests.ps1 | 12 +++++++++++- 5 files changed, 49 insertions(+), 1 deletion(-) create mode 100644 distribution_meta/fedora33.json diff --git a/CHANGELOG.md b/CHANGELOG.md index 7b7b0426b..3c3477bc3 100644 --- a/CHANGELOG.md +++ b/CHANGELOG.md @@ -3,6 +3,11 @@ This is the changelog for this fork of OMI. It documents the changes in each of the tagged releases +## 2.0.1 - TBD + ++ Added `fedora33` distribution ++ Make a backup of the original library files in the PowerShell dir before installing the forked copies + ## 2.0.0 - 2020-10-17 ### Breaking Changes diff --git a/PSWSMan/PSWSMan.psm1 b/PSWSMan/PSWSMan.psm1 index c08395790..0a05caf1e 100644 --- a/PSWSMan/PSWSMan.psm1 +++ b/PSWSMan/PSWSMan.psm1 @@ -423,6 +423,7 @@ Function Install-WSMan { if ($change) { Write-Verbose -Message "Installing $($_.Name) to '$pwshDir'" + Copy-Item -LiteralPath $destPath -Destination "$($destPath).bak" -Force Copy-Item -LiteralPath $_.Fullname -Destination $destPath $notify = $true } diff --git a/azure-pipelines.yml b/azure-pipelines.yml index de4dbf339..f97674129 100644 --- a/azure-pipelines.yml +++ b/azure-pipelines.yml @@ -30,6 +30,8 @@ stages: distribution: fedora31 Fedora32: distribution: fedora32 + Fedora33: + distribution: fedora33 Ubuntu16.04: distribution: ubuntu16.04 Ubuntu18.04: diff --git a/distribution_meta/fedora33.json b/distribution_meta/fedora33.json new file mode 100644 index 000000000..3d964e6a6 --- /dev/null +++ b/distribution_meta/fedora33.json @@ -0,0 +1,30 @@ +{ + "container_image": "fedora:33", + "package_manager": "dnf", + "microsoft_repo": "https://packages.microsoft.com/config/rhel/7/prod.repo", + "build_deps": [ + "cmake", + "bind-utils", + "gcc", + "gcc-c++", + "git", + "krb5-devel", + "make", + "openssl", + "openssl-devel", + "pam-devel", + "redhat-lsb-core", + "rpm-build", + "rpm-devel", + "which" + ], + "test_deps": [ + "gssntlmssp", + "krb5-devel", + "krb5-workstation", + "powershell", + "which" + ], + "cert_staging_dir": "/etc/pki/ca-trust/source/anchors", + "cert_staging_cmd": "update-ca-trust extract" +} diff --git a/libmi.tests.ps1 b/libmi.tests.ps1 index 2c75f8cfa..6cbcce93c 100755 --- a/libmi.tests.ps1 +++ b/libmi.tests.ps1 @@ -132,13 +132,23 @@ Describe "PSWSMan tests" { $ev.Count | Should -Be 1 $ev[0].Exception.Message | Should -BeLike "Unsupported distribution 'invalid'. Supported distributions: *" } + + It "Created backups of after installation" -TestCases @( + @{ Name = 'libmi' }, + @{ Name = 'libpsrpclient' } + ) { + $pwshDir = Split-Path -Path ([PSObject].Assembly.Location) -Parent + $libExtension = if ($Global:Distribution -eq 'macOS') { 'dylib' } else { 'so' } + $libName = "$($Name).$($libExtension).bak" + + Test-Path -LiteralPath (Join-Path -Path $pwshDir -ChildPath $libName) -PathType Leaf | Should -Be $true + } } Describe "Checking the compiled library's integrity" { It "Exposes the custom public version function" { $versions = Get-WSManVersion - foreach ($key in $versions.PSObject.Properties.Name) { # All versions we produce should have a major version that's 1 or more # The minor versions can be anything so we can't really check those From 9f925caaf0d60138589c3c67028e60dbdd8b2a32 Mon Sep 17 00:00:00 2001 From: Jordan Borean Date: Tue, 10 Nov 2020 14:20:50 +1000 Subject: [PATCH 2/2] Add conditional backup of original libs --- PSWSMan/PSWSMan.psm1 | 7 ++++++- 1 file changed, 6 insertions(+), 1 deletion(-) diff --git a/PSWSMan/PSWSMan.psm1 b/PSWSMan/PSWSMan.psm1 index 0a05caf1e..922857e0a 100644 --- a/PSWSMan/PSWSMan.psm1 +++ b/PSWSMan/PSWSMan.psm1 @@ -423,7 +423,12 @@ Function Install-WSMan { if ($change) { Write-Verbose -Message "Installing $($_.Name) to '$pwshDir'" - Copy-Item -LiteralPath $destPath -Destination "$($destPath).bak" -Force + + if (Test-Path -LiteralPath $destPath) { + Write-Verbose -Message "Creating backup of $($_.Name) to $($_.Name).bak" + Copy-Item -LiteralPath $destPath -Destination "$($destPath).bak" -Force + } + Copy-Item -LiteralPath $_.Fullname -Destination $destPath $notify = $true }