-
Notifications
You must be signed in to change notification settings - Fork 915
(#1670) Add noshims options for install and upgrade #2003
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
base: master
Are you sure you want to change the base?
Changes from all commits
File filter
Filter by extension
Conversations
Jump to
Diff view
Diff view
There are no files selected for viewing
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -1,6 +1,6 @@ | ||
## Chocolatey Usage Scenarios | ||
|
||
### ChocolateyInstallCommand [ 35 Scenario(s), 293 Observation(s) ] | ||
### ChocolateyInstallCommand [ 42 Scenario(s), 312 Observation(s) ] | ||
|
||
#### when force installing a package that depends on an unavailable newer version of an installed dependency forcing dependencies | ||
|
||
|
@@ -247,6 +247,20 @@ | |
* should not install a package in the lib directory | ||
* should put a package in the lib bad directory | ||
|
||
#### when installing a package that tries to overwrite another shim | ||
|
||
* should have a shim | ||
* should have a shim with target in other package tools folder | ||
* should have an error message | ||
* should have shim target | ||
|
||
#### when installing a package that tries to overwrite its own shim | ||
|
||
* should create a shim | ||
* should have a shim with target in tools folder | ||
* should have an error message | ||
* should have shim targets | ||
|
||
#### when installing a package with a dependent package that also depends on a less constrained but still valid dependency of the same package | ||
|
||
* [PENDING] should contain a message that everything installed successfully | ||
|
@@ -282,6 +296,18 @@ | |
* should not install a package in the lib directory | ||
* should not install the dependency in the lib directory | ||
|
||
#### when installing a package with dependencies and noshims | ||
|
||
* should create a shim for the dependency | ||
* should have shim targets | ||
* should not create a shim for the package | ||
|
||
#### when installing a package with dependencies and noshimsglobal | ||
|
||
* should have shim targets | ||
* should not create a shim for the dependency | ||
* should not create a shim for the package | ||
|
||
#### when installing a package with dependencies happy | ||
|
||
* should contain a message that everything installed successfully | ||
|
@@ -326,11 +352,25 @@ | |
* [PENDING] should not install the conflicting package in the lib directory | ||
* [PENDING] should not upgrade the exact version dependency | ||
|
||
#### when installing a package with install bin file | ||
|
||
* should not see the shim as an existing shim and remove it | ||
|
||
#### when installing a package with install bin file and noshims | ||
|
||
* should have shim target | ||
* should not create a shim | ||
|
||
#### when installing a package with no sources enabled | ||
|
||
* should have no sources enabled result | ||
* should not install any packages | ||
|
||
#### when installing a package with noshims | ||
|
||
* should have shim target | ||
* should not create a shim for the package | ||
|
||
#### when installing a side by side package | ||
|
||
* config should match package result name | ||
|
@@ -541,7 +581,7 @@ | |
|
||
* should contain success message | ||
|
||
### ChocolateyUninstallCommand [ 13 Scenario(s), 93 Observation(s) ] | ||
### ChocolateyUninstallCommand [ 14 Scenario(s), 95 Observation(s) ] | ||
|
||
#### when force uninstalling a package | ||
|
||
|
@@ -617,6 +657,11 @@ | |
* should not remove package from the lib directory | ||
* should still have the package file in the directory | ||
|
||
#### when uninstalling a package that forgets to call uninstall bin file | ||
|
||
* should have had a shim | ||
* should have removed the shim | ||
|
||
#### when uninstalling a package with a read and delete share locked file | ||
|
||
* should contain a message that it uninstalled successfully | ||
|
@@ -675,7 +720,7 @@ | |
|
||
* should throw an error that it is not allowed | ||
|
||
### ChocolateyUpgradeCommand [ 36 Scenario(s), 295 Observation(s) ] | ||
### ChocolateyUpgradeCommand [ 40 Scenario(s), 307 Observation(s) ] | ||
|
||
#### when force upgrading a package | ||
|
||
|
@@ -920,6 +965,11 @@ | |
* should have no sources enabled result | ||
* should not have any packages upgraded | ||
|
||
#### when upgrading a package with noshims | ||
|
||
* should have shim target | ||
* should not create a shim | ||
|
||
#### when upgrading a package with readonly files | ||
|
||
* should contain a warning message that it upgraded successfully | ||
|
@@ -933,6 +983,25 @@ | |
* should upgrade the package | ||
* should upgrade where install location reports | ||
|
||
#### when upgrading a package with shims | ||
There was a problem hiding this comment. Choose a reason for hiding this commentThe reason will be displayed to describe this comment to others. Learn more. What about when upgrading a package that has existing shims with no shims in the upgrade? What's the expected behavior for that use case? There was a problem hiding this comment. Choose a reason for hiding this commentThe reason will be displayed to describe this comment to others. Learn more. The default behaviour in install and upgrade scenarios is to remove all shims for the package first, then install any shims if not prohibited by --noshims or --noshimsglobal. So the existing shims will be removed and the new shims will not be installed. |
||
|
||
* should create a shim | ||
* should have had original shim | ||
* should have shim target | ||
* should not have original shim | ||
|
||
#### when upgrading a package with shims that errors | ||
|
||
* should have original shim | ||
* should not create a shim | ||
|
||
#### when upgrading a package with shims with noshims | ||
|
||
* should have had original shim | ||
* should have shim target | ||
* should not create a shim | ||
* should not have original shim | ||
|
||
#### when upgrading a package with unavailable dependencies | ||
|
||
* should contain a message that it was unable to upgrade anything | ||
|
Original file line number | Diff line number | Diff line change |
---|---|---|
|
@@ -86,6 +86,13 @@ param( | |
|
||
Write-FunctionCallLogMessage -Invocation $MyInvocation -Parameters $PSBoundParameters | ||
|
||
if ($env:ChocolateyNoShims) { | ||
Write-Debug "File shimming disabled for `'$($env:ChocolateyPackageName)`'." | ||
Write-Debug "Removing any existing shim for `'$name`'." | ||
Uninstall-BinFile $name $path | ||
return | ||
} | ||
There was a problem hiding this comment. Choose a reason for hiding this commentThe reason will be displayed to describe this comment to others. Learn more. Following my last comment, I see you have code to remove shims if no shims is called. Might be good to add a scenario for that use case There was a problem hiding this comment. Choose a reason for hiding this commentThe reason will be displayed to describe this comment to others. Learn more. Not quite sure what you want here, so I have added an extra upgrade scenario in b496390 This tests an upgrade to a package that has a shim, with the --noshims flag. Is this the sort of thing you wanted? |
||
|
||
$nugetPath = [System.IO.Path]::GetFullPath((Join-Path "$helpersPath" '..\')) | ||
$nugetExePath = Join-Path "$nugetPath" 'bin' | ||
$packageBatchFileName = Join-Path $nugetExePath "$name.bat" | ||
|
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,17 @@ | ||
<?xml version="1.0"?> | ||
<package xmlns="http://schemas.microsoft.com/packaging/2010/07/nuspec.xsd"> | ||
<metadata> | ||
<id>shimbasepackage</id> | ||
<version>1.0.0</version> | ||
<title>shimbasepackage</title> | ||
<authors>__REPLACE_AUTHORS_OF_SOFTWARE__</authors> | ||
<owners>__REPLACE_YOUR_NAME__</owners> | ||
<requireLicenseAcceptance>false</requireLicenseAcceptance> | ||
<description>__REPLACE__</description> | ||
<summary>__REPLACE__</summary> | ||
<tags>shimbasepackage</tags> | ||
</metadata> | ||
<files> | ||
<file src="tools\**" target="tools" /> | ||
</files> | ||
</package> |
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1 @@ | ||
Write-Output "$env:PackageName $env:PackageVersion Installed" |
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1 @@ | ||
Write-Output "$env:PackageName $env:PackageVersion Uninstalled" |
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1 @@ | ||
1.0.0 |
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,20 @@ | ||
<?xml version="1.0"?> | ||
<package xmlns="http://schemas.microsoft.com/packaging/2010/07/nuspec.xsd"> | ||
<metadata> | ||
<id>shimhasdependency</id> | ||
<version>1.0.0</version> | ||
<title>shimhasdependency</title> | ||
<authors>__REPLACE_AUTHORS_OF_SOFTWARE__</authors> | ||
<owners>__REPLACE_YOUR_NAME__</owners> | ||
<requireLicenseAcceptance>false</requireLicenseAcceptance> | ||
<description>__REPLACE__</description> | ||
<summary>__REPLACE__</summary> | ||
<tags>shimhasdependency</tags> | ||
<dependencies> | ||
<dependency id="shimbasepackage" version="1.0.0" /> | ||
</dependencies> | ||
</metadata> | ||
<files> | ||
<file src="tools\**" target="tools" /> | ||
</files> | ||
</package> |
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1 @@ | ||
Write-Output "$env:PackageName $env:PackageVersion Installed" |
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1 @@ | ||
Write-Output "$env:PackageName $env:PackageVersion Uninstalled" |
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1 @@ | ||
1.0.0 |
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,17 @@ | ||
<?xml version="1.0"?> | ||
<package xmlns="http://schemas.microsoft.com/packaging/2010/07/nuspec.xsd"> | ||
<metadata> | ||
<id>shimoverwrite</id> | ||
<version>1.0.0</version> | ||
<title>shimoverwrite</title> | ||
<authors>__REPLACE_AUTHORS_OF_SOFTWARE__</authors> | ||
<owners>__REPLACE_YOUR_NAME__</owners> | ||
<requireLicenseAcceptance>false</requireLicenseAcceptance> | ||
<description>__REPLACE__</description> | ||
<summary>__REPLACE__</summary> | ||
<tags>overwrite-own</tags> | ||
</metadata> | ||
<files> | ||
<file src="tools\**" target="tools" /> | ||
</files> | ||
</package> |
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1 @@ | ||
Write-Output "$env:PackageName $env:PackageVersion Installed" |
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1 @@ | ||
Write-Output "$env:PackageName $env:PackageVersion Uninstalled" |
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1 @@ | ||
1.0.0 |
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1 @@ | ||
1.0.0 |
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,20 @@ | ||
<?xml version="1.0"?> | ||
<package xmlns="http://schemas.microsoft.com/packaging/2010/07/nuspec.xsd"> | ||
<metadata> | ||
<id>shimoverwriteother</id> | ||
<version>1.0.0</version> | ||
<title>shimoverwriteother</title> | ||
<authors>__REPLACE_AUTHORS_OF_SOFTWARE__</authors> | ||
<owners>__REPLACE_YOUR_NAME__</owners> | ||
<requireLicenseAcceptance>false</requireLicenseAcceptance> | ||
<description>__REPLACE__</description> | ||
<summary>__REPLACE__</summary> | ||
<tags>shimoverwriteother</tags> | ||
<dependencies> | ||
<dependency id="shimbasepackage" version="1.0.0" /> | ||
</dependencies> | ||
</metadata> | ||
<files> | ||
<file src="tools\**" target="tools" /> | ||
</files> | ||
</package> |
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1 @@ | ||
Write-Output "$env:PackageName $env:PackageVersion Installed" |
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1 @@ | ||
Write-Output "$env:PackageName $env:PackageVersion Uninstalled" |
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1 @@ | ||
1.0.0 |
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,17 @@ | ||
<?xml version="1.0"?> | ||
<package xmlns="http://schemas.microsoft.com/packaging/2010/07/nuspec.xsd"> | ||
<metadata> | ||
<id>shimupgrade</id> | ||
<version>1.0.0</version> | ||
<title>shimupgrade</title> | ||
<authors>__REPLACE_AUTHORS_OF_SOFTWARE__</authors> | ||
<owners>__REPLACE_YOUR_NAME__</owners> | ||
<requireLicenseAcceptance>false</requireLicenseAcceptance> | ||
<description>__REPLACE__</description> | ||
<summary>__REPLACE__</summary> | ||
<tags>shimupgrade</tags> | ||
</metadata> | ||
<files> | ||
<file src="tools\**" target="tools" /> | ||
</files> | ||
</package> |
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1 @@ | ||
Write-Output "$env:PackageName $env:PackageVersion Installed" |
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
Awesome, thanks for doing this!
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
Of course, this only applies to packages that install into
..\chocolatey\lib\<package-name>
, so shims targetting binaries somewhere else would not get removed.If Shimgen accepted the package name as a parameter and stored this in the shim's FileVersionInfo data (together with the target binary, as suggested elsewhere), then this limitation disappears.