-
Notifications
You must be signed in to change notification settings - Fork 904
New issue
Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.
By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.
Already on GitHub? Sign in to your account
(#1479) Add ability to use remembered arguments during uninstall #2648
Open
TheCakeIsNaOH
wants to merge
7
commits into
chocolatey:develop
Choose a base branch
from
TheCakeIsNaOH:uninstall-remembered-arguments
base: develop
Could not load branches
Branch not found: {{ refName }}
Loading
Could not load tags
Nothing to show
Loading
Are you sure you want to change the base?
Some commits from the old base branch may be removed from the timeline,
and old review comments may become outdated.
Open
(#1479) Add ability to use remembered arguments during uninstall #2648
TheCakeIsNaOH
wants to merge
7
commits into
chocolatey:develop
from
TheCakeIsNaOH:uninstall-remembered-arguments
Conversation
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
TheCakeIsNaOH
force-pushed
the
uninstall-remembered-arguments
branch
2 times, most recently
from
March 11, 2022 01:54
cef63cd
to
a86fbe8
Compare
TheCakeIsNaOH
force-pushed
the
uninstall-remembered-arguments
branch
from
March 21, 2022 16:31
a86fbe8
to
4cf4fbe
Compare
TheCakeIsNaOH
force-pushed
the
uninstall-remembered-arguments
branch
from
June 27, 2022 14:57
4cf4fbe
to
627bedb
Compare
TheCakeIsNaOH
force-pushed
the
uninstall-remembered-arguments
branch
from
September 25, 2022 01:01
627bedb
to
8116f2b
Compare
This is draft until #3003 is merged/closed, as the implementation of this depends on what happens with that PR. |
TheCakeIsNaOH
force-pushed
the
uninstall-remembered-arguments
branch
from
January 10, 2024 01:16
8116f2b
to
8919ee3
Compare
Rebased on #3003 |
TheCakeIsNaOH
force-pushed
the
uninstall-remembered-arguments
branch
from
January 10, 2024 01:27
8919ee3
to
3823ea0
Compare
This helps ensure that package IDs are handled in a case insensitive manner.
This allows overriding of remembered package parameters, install arguments, cache location and execution timeout during upgrade. So a user can pass in different package parameters or arguments without having to completely reinstall the package or turn off remembered arguments. Switch arguments cannot be checked, because the lack of a switch normally would mean that they are just relying on the remembered args to remember it, so there is no way to determine if an override of the remembered args is appropriate.
…ration This adds a new method, GetPackageConfigFromRememberedArguments which is similar to SetConfigFromRememberedArguments, but operates using a different method. First, a OptionSet is set up, so only the config that is passed in is modified, instead of the config that the global options parser was set with with. Second, it returns the modified configuration instead of the original configuration, because it is the local configuration being modified. Third, it has a more general name and changes log messages to be more general, so it later can more easily be reused for uninstall and export. This change fixes remembered arguments when Chocolatey is used as a library, like in ChocolateyGUI, where the config that is passed to the install_run method is not necessarily the same config object that was used to set up the global argument parser. The downside of using a new commandline parser is that it opens up the possibility of drift between the upgrade/global arguments and this added parser. However, this is not an issue because the format of the saved arguments is known, and any added arguments there would not work without being added here as well, which would be picked up during development.
This brings out the functionality from the set_package_config_for_upgrade method to a more generic name, and adds in another parameter to prepare for setting remembered args for uninstall as well as upgrade. It also updates the logging and comments to make them generic for both upgrades and uninstalls. An alias/forwarding method is added for backwards compatibility.
Similar to the UseRememberedArgumentsForUpgrade feature, this will be used to toggle if the remembered arguments are used during uninstall.
This adds the ability for the remembered argument to be reused for uninstalls. It can be controlled via the userememberedargs and ignorerememberedargs arguments, or via the previously added feature.
TheCakeIsNaOH
force-pushed
the
uninstall-remembered-arguments
branch
from
April 28, 2024 02:59
3823ea0
to
75298e2
Compare
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment
Add this suggestion to a batch that can be applied as a single commit.
This suggestion is invalid because no changes were made to the code.
Suggestions cannot be applied while the pull request is closed.
Suggestions cannot be applied while viewing a subset of changes.
Only one suggestion per line can be applied in a batch.
Add this suggestion to a batch that can be applied as a single commit.
Applying suggestions on deleted lines is not supported.
You must change the existing code in this line in order to create a valid suggestion.
Outdated suggestions cannot be applied.
This suggestion has been applied or marked resolved.
Suggestions cannot be applied from pending reviews.
Suggestions cannot be applied on multi-line comments.
Suggestions cannot be applied while the pull request is queued to merge.
Suggestion cannot be applied right now. Please check back later.
Description Of Changes
This adds the ability for remembered arguments to be used during uninstall.
Similarly to using remembered argument for upgrades, a feature has been added,
UseRememberedArgumentsForUninstalls
, and--ignore-remembered-arguments
/--use-remembered-arguments
argument have been added to the uninstall command.The
set_package_config_for_upgrade
has been renamed and some other changes were made to update it to prepare it to be used for setting the config for both upgrade and uninstall. The implementation of the feature uses the same method the upgrade command does. Remembered install arguments (--install-arguments=
) are ignored, so they do not overwrite--uninstall-arguments=
, as both use the same internal config value.To prevent an issue like #1443, a reset config action has also been added to
uninstall_run
, just like the one added toupgrade_run
in #2484.Motivation and Context
When creating a package that will copy file(s) to a location that is specified via a package parameter, or adding a location to the
$env:path
, there is not an easy way to save that location, so it can be removed during uninstall. It is possible to save it via a text file or similar, but there is not a standardized way to do so.Having argument, including package parameters be remembered during uninstall allows for an easy fix to this situation. The uninstall script can get those parameters, and therefore get the location(s) that need to be removed. This also applies to any other behavior set via a parameter that need to be undone during the uninstall script.
Any
--install-arguments=
are not remembered during uninstall because they can conflict with uninstall arguments, as the available set of install and uninstall arguments are different in most cases.Testing
Build choco, run the integration tests, and (if required), copy the
context
directory from the integration test to the directory you are testing from.Validate that during the uninstall output, the
chocolateyUninstall.ps1
is called with/PKGPARAM
included.Validate that during the uninstall output, the
chocolateyUninstall.ps1
is called with/PKGPARAM
NOT included.--ia
are not used:Validate that during the uninstall output, the
chocolateyUninstall.ps1
is called withinstallArg
NOT included.Validate that during the uninstall output, the
chocolateyUninstall.ps1
is called with/PKGPARAM
included.Validate that the installpackage uninstall script is called with
/PKGPARAM
but the upgradepackage uninstall script is called without it.Change Types Made
Related Issue
Fixes #1479
Based on/Depends on #3003
Change Checklist