From a67471c863093d3481f53fba1222317b0bd7adbc Mon Sep 17 00:00:00 2001 From: twangboy Date: Wed, 23 Aug 2023 14:14:57 -0600 Subject: [PATCH 1/5] Don't remove extras dir on uninstall --- pkg/windows/build.ps1 | 2 +- pkg/windows/build_python.ps1 | 2 +- .../nsis/installer/Salt-Minion-Setup.nsi | 36 +++++++++++-------- 3 files changed, 23 insertions(+), 17 deletions(-) diff --git a/pkg/windows/build.ps1 b/pkg/windows/build.ps1 index ac273a6c163d..54aca98cedef 100644 --- a/pkg/windows/build.ps1 +++ b/pkg/windows/build.ps1 @@ -43,7 +43,7 @@ param( [Parameter(Mandatory=$false)] [Alias("r")] - [String] $RelenvVersion = "0.12.3", + [String] $RelenvVersion = "0.13.4", [Parameter(Mandatory=$false)] [Alias("b")] diff --git a/pkg/windows/build_python.ps1 b/pkg/windows/build_python.ps1 index 90a2b053a924..84373df916c4 100644 --- a/pkg/windows/build_python.ps1 +++ b/pkg/windows/build_python.ps1 @@ -22,7 +22,7 @@ param( [Parameter(Mandatory=$false)] [Alias("r")] - [String] $RelenvVersion = "0.12.3", + [String] $RelenvVersion = "0.13.4", [Parameter(Mandatory=$false)] [ValidateSet("x64", "x86", "amd64")] diff --git a/pkg/windows/nsis/installer/Salt-Minion-Setup.nsi b/pkg/windows/nsis/installer/Salt-Minion-Setup.nsi index 2377a2194677..2a957056f514 100644 --- a/pkg/windows/nsis/installer/Salt-Minion-Setup.nsi +++ b/pkg/windows/nsis/installer/Salt-Minion-Setup.nsi @@ -1109,9 +1109,10 @@ Function ${un}uninstallSalt ${EndIf} # Remove files - Delete "$INSTDIR\uninst.exe" - Delete "$INSTDIR\ssm.exe" + Delete "$INSTDIR\multi-minion*" Delete "$INSTDIR\salt*" + Delete "$INSTDIR\ssm.exe" + Delete "$INSTDIR\uninst.exe" Delete "$INSTDIR\vcredist.exe" RMDir /r "$INSTDIR\DLLs" RMDir /r "$INSTDIR\Include" @@ -1189,6 +1190,20 @@ Function ${un}uninstallSalt ${Else} + # Prompt for the removal of the Installation Directory which contains + # the extras directory and the Root Directory which contains the config + # and pki directories. These directories will not be removed during + # an upgrade. + ${IfNot} $DeleteRootDir == 1 + MessageBox MB_YESNO|MB_DEFBUTTON2|MB_USERICON \ + "Would you like to completely remove the entire Salt \ + Installation? This includes the following:$\n\ + - Extra Pip Packages ($INSTDIR\extras-3.##)$\n\ + - Minion Config ($RootDir\conf)$\n\ + - Minion PKIs ($RootDir\conf\pki)"\ + /SD IDNO IDNO finished + ${EndIf} + # New Method Installation # This makes the $APPDATA variable point to the ProgramData folder instead # of the current user's roaming AppData folder @@ -1214,8 +1229,8 @@ Function ${un}uninstallSalt # Only delete Salt Project directory if it's in Program Files # Otherwise, we can't guess where the user may have installed salt ${GetParent} $INSTDIR $0 # Get parent directory (Salt Project) - ${If} $0 == "$ProgramFiles\Salt Project" # Make sure it's not ProgramFiles - ${OrIf} $0 == "$ProgramFiles64\Salt Project" # Make sure it's not Program Files (x86) + ${If} $0 == "$ProgramFiles\Salt Project" # Make sure it's ProgramFiles + ${OrIf} $0 == "$ProgramFiles64\Salt Project" # Make sure it's Program Files (x86) SetOutPath "$SysDrive" # Can't remove CWD RMDir /r $0 ${EndIf} @@ -1228,15 +1243,6 @@ Function ${un}uninstallSalt # Expand any environment variables ExpandEnvStrings $RootDir $RootDir - # Prompt for the removal of the Root Directory which contains the config - # and pki directories - ${IfNot} $DeleteRootDir == 1 - MessageBox MB_YESNO|MB_DEFBUTTON2|MB_USERICON \ - "Would you like to completely remove the Root Directory \ - ($RootDir) and all of its contents?" \ - /SD IDNO IDNO finished - ${EndIf} - # Remove the Salt Project directory in ProgramData # The Salt Project directory will only ever be in ProgramData # It is not user selectable @@ -1837,8 +1843,8 @@ Function un.parseUninstallerCommandLineSwitches $\n$\t$\tare the same (C:\salt)\ $\n\ $\n/delete-root-dir$\tDelete the root directory that contains the config\ - $\n$\t$\tand pki directories. Default is to not delete the root\ - $\n$\t$\tdirectory\ + $\n$\t$\tand pki directories. Also removes the installation directory\ + $\n$\t$\tincluding the extras directory. Default is to not delete\ $\n\ $\n$\t$\tThis applies to new method installations where the\ $\n$\t$\troot directory is in ProgramData and the installation\ From 70858c29fd2be91dd1858c242b5af99a93a5311c Mon Sep 17 00:00:00 2001 From: twangboy Date: Wed, 23 Aug 2023 14:21:58 -0600 Subject: [PATCH 2/5] Add changelog --- changelog/64957.fixed.md | 3 +++ 1 file changed, 3 insertions(+) create mode 100644 changelog/64957.fixed.md diff --git a/changelog/64957.fixed.md b/changelog/64957.fixed.md new file mode 100644 index 000000000000..5a5522efa8e5 --- /dev/null +++ b/changelog/64957.fixed.md @@ -0,0 +1,3 @@ +Fixed uninstaller to not remove the `salt` directory by default. This allows +the `extras-3.##` folder to persist so salt-pip dependencies are not wiped out +during an upgrade. From f9cb43f1aa553fbbf9dfecc3e98cb1e4886f1279 Mon Sep 17 00:00:00 2001 From: twangboy Date: Wed, 23 Aug 2023 14:14:57 -0600 Subject: [PATCH 3/5] Don't remove extras dir on uninstall --- pkg/windows/build.ps1 | 2 +- pkg/windows/build_python.ps1 | 2 +- .../nsis/installer/Salt-Minion-Setup.nsi | 36 +++++++++++-------- 3 files changed, 23 insertions(+), 17 deletions(-) diff --git a/pkg/windows/build.ps1 b/pkg/windows/build.ps1 index ac273a6c163d..54aca98cedef 100644 --- a/pkg/windows/build.ps1 +++ b/pkg/windows/build.ps1 @@ -43,7 +43,7 @@ param( [Parameter(Mandatory=$false)] [Alias("r")] - [String] $RelenvVersion = "0.12.3", + [String] $RelenvVersion = "0.13.4", [Parameter(Mandatory=$false)] [Alias("b")] diff --git a/pkg/windows/build_python.ps1 b/pkg/windows/build_python.ps1 index 90a2b053a924..84373df916c4 100644 --- a/pkg/windows/build_python.ps1 +++ b/pkg/windows/build_python.ps1 @@ -22,7 +22,7 @@ param( [Parameter(Mandatory=$false)] [Alias("r")] - [String] $RelenvVersion = "0.12.3", + [String] $RelenvVersion = "0.13.4", [Parameter(Mandatory=$false)] [ValidateSet("x64", "x86", "amd64")] diff --git a/pkg/windows/nsis/installer/Salt-Minion-Setup.nsi b/pkg/windows/nsis/installer/Salt-Minion-Setup.nsi index 2377a2194677..2a957056f514 100644 --- a/pkg/windows/nsis/installer/Salt-Minion-Setup.nsi +++ b/pkg/windows/nsis/installer/Salt-Minion-Setup.nsi @@ -1109,9 +1109,10 @@ Function ${un}uninstallSalt ${EndIf} # Remove files - Delete "$INSTDIR\uninst.exe" - Delete "$INSTDIR\ssm.exe" + Delete "$INSTDIR\multi-minion*" Delete "$INSTDIR\salt*" + Delete "$INSTDIR\ssm.exe" + Delete "$INSTDIR\uninst.exe" Delete "$INSTDIR\vcredist.exe" RMDir /r "$INSTDIR\DLLs" RMDir /r "$INSTDIR\Include" @@ -1189,6 +1190,20 @@ Function ${un}uninstallSalt ${Else} + # Prompt for the removal of the Installation Directory which contains + # the extras directory and the Root Directory which contains the config + # and pki directories. These directories will not be removed during + # an upgrade. + ${IfNot} $DeleteRootDir == 1 + MessageBox MB_YESNO|MB_DEFBUTTON2|MB_USERICON \ + "Would you like to completely remove the entire Salt \ + Installation? This includes the following:$\n\ + - Extra Pip Packages ($INSTDIR\extras-3.##)$\n\ + - Minion Config ($RootDir\conf)$\n\ + - Minion PKIs ($RootDir\conf\pki)"\ + /SD IDNO IDNO finished + ${EndIf} + # New Method Installation # This makes the $APPDATA variable point to the ProgramData folder instead # of the current user's roaming AppData folder @@ -1214,8 +1229,8 @@ Function ${un}uninstallSalt # Only delete Salt Project directory if it's in Program Files # Otherwise, we can't guess where the user may have installed salt ${GetParent} $INSTDIR $0 # Get parent directory (Salt Project) - ${If} $0 == "$ProgramFiles\Salt Project" # Make sure it's not ProgramFiles - ${OrIf} $0 == "$ProgramFiles64\Salt Project" # Make sure it's not Program Files (x86) + ${If} $0 == "$ProgramFiles\Salt Project" # Make sure it's ProgramFiles + ${OrIf} $0 == "$ProgramFiles64\Salt Project" # Make sure it's Program Files (x86) SetOutPath "$SysDrive" # Can't remove CWD RMDir /r $0 ${EndIf} @@ -1228,15 +1243,6 @@ Function ${un}uninstallSalt # Expand any environment variables ExpandEnvStrings $RootDir $RootDir - # Prompt for the removal of the Root Directory which contains the config - # and pki directories - ${IfNot} $DeleteRootDir == 1 - MessageBox MB_YESNO|MB_DEFBUTTON2|MB_USERICON \ - "Would you like to completely remove the Root Directory \ - ($RootDir) and all of its contents?" \ - /SD IDNO IDNO finished - ${EndIf} - # Remove the Salt Project directory in ProgramData # The Salt Project directory will only ever be in ProgramData # It is not user selectable @@ -1837,8 +1843,8 @@ Function un.parseUninstallerCommandLineSwitches $\n$\t$\tare the same (C:\salt)\ $\n\ $\n/delete-root-dir$\tDelete the root directory that contains the config\ - $\n$\t$\tand pki directories. Default is to not delete the root\ - $\n$\t$\tdirectory\ + $\n$\t$\tand pki directories. Also removes the installation directory\ + $\n$\t$\tincluding the extras directory. Default is to not delete\ $\n\ $\n$\t$\tThis applies to new method installations where the\ $\n$\t$\troot directory is in ProgramData and the installation\ From d0757342b160da606065807959c2f688acd5f949 Mon Sep 17 00:00:00 2001 From: twangboy Date: Wed, 23 Aug 2023 14:21:58 -0600 Subject: [PATCH 4/5] Add changelog --- changelog/64957.fixed.md | 3 +++ 1 file changed, 3 insertions(+) create mode 100644 changelog/64957.fixed.md diff --git a/changelog/64957.fixed.md b/changelog/64957.fixed.md new file mode 100644 index 000000000000..5a5522efa8e5 --- /dev/null +++ b/changelog/64957.fixed.md @@ -0,0 +1,3 @@ +Fixed uninstaller to not remove the `salt` directory by default. This allows +the `extras-3.##` folder to persist so salt-pip dependencies are not wiped out +during an upgrade. From b1c5a3aea40b70e2211e7c6cc631e29930e28716 Mon Sep 17 00:00:00 2001 From: twangboy Date: Tue, 29 Aug 2023 16:47:30 -0600 Subject: [PATCH 5/5] Get default python and relenv versions from CICD --- pkg/windows/build.ps1 | 36 +++++++++++++++++++++++--- pkg/windows/build_python.ps1 | 49 ++++++++++++++++++++++++++++-------- 2 files changed, 72 insertions(+), 13 deletions(-) diff --git a/pkg/windows/build.ps1 b/pkg/windows/build.ps1 index 54aca98cedef..ecd188327869 100644 --- a/pkg/windows/build.ps1 +++ b/pkg/windows/build.ps1 @@ -39,11 +39,14 @@ param( [Parameter(Mandatory=$false)] [ValidatePattern("^\d{1,2}.\d{1,2}.\d{1,2}$")] [Alias("p")] - [String] $PythonVersion = "3.10.12", + # The version of Python to build/fetch. This is tied to the version of + # Relenv + [String] $PythonVersion, [Parameter(Mandatory=$false)] [Alias("r")] - [String] $RelenvVersion = "0.13.4", + # The version of Relenv to install + [String] $RelenvVersion, [Parameter(Mandatory=$false)] [Alias("b")] @@ -57,7 +60,7 @@ param( [Switch] $CICD, [Parameter(Mandatory=$false)] - # Don't install. It should already be installed + # Don't install/build python. It should already be installed [Switch] $SkipInstall ) @@ -98,6 +101,33 @@ if ( [String]::IsNullOrEmpty($Version) ) { } } +#------------------------------------------------------------------------------- +# Verify Python and Relenv Versions +#------------------------------------------------------------------------------- + +$yaml = Get-Content -Path "$PROJECT_DIR\cicd\shared-gh-workflows-context.yml" +$dict_versions = @{} +$yaml | ForEach-Object { + $val1, $val2 = $_ -split ": " + $dict_versions[$val1] = $val2.Trim("""") +} + +if ( [String]::IsNullOrEmpty($PythonVersion) ) { + $PythonVersion = $dict_versions["python_version"] + if ( [String]::IsNullOrEmpty($PythonVersion) ) { + Write-Host "Failed to load Python Version" + exit 1 + } +} + +if ( [String]::IsNullOrEmpty($RelenvVersion) ) { + $RelenvVersion = $dict_versions["relenv_version"] + if ( [String]::IsNullOrEmpty($RelenvVersion) ) { + Write-Host "Failed to load Relenv Version" + exit 1 + } +} + #------------------------------------------------------------------------------- # Start the Script #------------------------------------------------------------------------------- diff --git a/pkg/windows/build_python.ps1 b/pkg/windows/build_python.ps1 index 84373df916c4..28aee58fbd2a 100644 --- a/pkg/windows/build_python.ps1 +++ b/pkg/windows/build_python.ps1 @@ -18,11 +18,14 @@ param( [Parameter(Mandatory=$false)] [ValidatePattern("^\d{1,2}.\d{1,2}.\d{1,2}$")] [Alias("v")] - [String] $Version = "3.10.12", + # The version of python to build/fetch. This is tied to the version of + # Relenv + [String] $Version, [Parameter(Mandatory=$false)] [Alias("r")] - [String] $RelenvVersion = "0.13.4", + # The version of Relenv to install + [String] $RelenvVersion, [Parameter(Mandatory=$false)] [ValidateSet("x64", "x86", "amd64")] @@ -68,6 +71,33 @@ function Write-Result($result, $ForegroundColor="Green") { Write-Host -ForegroundColor $ForegroundColor ("{0,$position}$result" -f "") }} +#------------------------------------------------------------------------------- +# Verify Python and Relenv Versions +#------------------------------------------------------------------------------- + +$yaml = Get-Content -Path "$PROJECT_DIR\cicd\shared-gh-workflows-context.yml" +$dict_versions = @{} +$yaml | ForEach-Object { + $val1, $val2 = $_ -split ": " + $dict_versions[$val1] = $val2.Trim("""") +} + +if ( [String]::IsNullOrEmpty($Version) ) { + $Version = $dict_versions["python_version"] + if ( [String]::IsNullOrEmpty($Version) ) { + Write-Host "Failed to load Python Version" + exit 1 + } +} + +if ( [String]::IsNullOrEmpty($RelenvVersion) ) { + $RelenvVersion = $dict_versions["relenv_version"] + if ( [String]::IsNullOrEmpty($RelenvVersion) ) { + Write-Host "Failed to load Relenv Version" + exit 1 + } +} + #------------------------------------------------------------------------------- # Start the Script #------------------------------------------------------------------------------- @@ -145,7 +175,6 @@ if ( $env:VIRTUAL_ENV ) { #------------------------------------------------------------------------------- $SCRIPT_DIR = (Get-ChildItem "$($myInvocation.MyCommand.Definition)").DirectoryName $BUILD_DIR = "$SCRIPT_DIR\buildenv" -$SCRIPTS_DIR = "$BUILD_DIR\Scripts" $RELENV_DIR = "${env:LOCALAPPDATA}\relenv" $SYS_PY_BIN = (python -c "import sys; print(sys.executable)") $BLD_PY_BIN = "$BUILD_DIR\Scripts\python.exe" @@ -238,16 +267,16 @@ $env:RELENV_FETCH_VERSION=$RelenvVersion #------------------------------------------------------------------------------- if ( $Build ) { Write-Host "Building Python with Relenv (long-running): " -NoNewLine - $output = relenv build --clean --arch $ARCH + $output = relenv build --clean --python $Version --arch $ARCH } else { Write-Host "Fetching Python with Relenv: " -NoNewLine relenv fetch --python $Version --arch $ARCH | Out-Null -} -if ( Test-Path -Path "$RELENV_DIR\build\$Version-$ARCH-win.tar.xz") { - Write-Result "Success" -ForegroundColor Green -} else { - Write-Result "Failed" -ForegroundColor Red - exit 1 + if ( Test-Path -Path "$RELENV_DIR\build\$Version-$ARCH-win.tar.xz") { + Write-Result "Success" -ForegroundColor Green + } else { + Write-Result "Failed" -ForegroundColor Red + exit 1 + } } #-------------------------------------------------------------------------------