forked from chocolatey/choco
-
Notifications
You must be signed in to change notification settings - Fork 0
Commit
This commit does not belong to any branch on this repository, and may belong to a fork outside of the repository.
(chocolateyGH-1670) Add noshims options for install and upgrade
The --noshims and --noshimsglobal options allow the user to stop shims being created for either the package, or the package and its dependencies. In addition to this new behaviour, the implementation handles the creation and removal of shims more robustly, so that shims from other packages (or the same package) cannot be unintentionally overwritten or removed. The new ShimRegistry class keeps track of the currently installed shims and their corresponding packages. It does this by examining all the exe files in the shim directory (note that old-style .bat and unixy shims are not supported) and extracting the target file from the binary. If this target path contains the lib folder, then the package name can be obtained. ShimRegistry is updated for each package, just before the Powershell scripts are run, using `ShimGenerationService::take_snapshot`. When ShimGenerationService installs the package, ShimRegistry provides its existing shim files (ie. those that were not modified or removed since the last update) so that they can be deleted prior to installing any new ones. To stop shims being added from Install-BinFile, a new environment variable `chocolateyNoShims` is used when running the Powershell scripts. If a package sets a shim this way, but then forgets to call Uninstall-BinFile when uninstalling, the shim will be removed anyway if its target is in the package folder.
- Loading branch information
1 parent
564a652
commit fb2a2f0
Showing
53 changed files
with
1,669 additions
and
32 deletions.
There are no files selected for viewing
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
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
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
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
17 changes: 17 additions & 0 deletions
17
src/chocolatey.tests.integration/context/shims/shimbasepackage/1.0.0/shimbasepackage.nuspec
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
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> |
1 change: 1 addition & 0 deletions
1
...colatey.tests.integration/context/shims/shimbasepackage/1.0.0/tools/chocolateyInstall.ps1
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
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1 @@ | ||
Write-Output "$env:PackageName $env:PackageVersion Installed" |
1 change: 1 addition & 0 deletions
1
...latey.tests.integration/context/shims/shimbasepackage/1.0.0/tools/chocolateyUninstall.ps1
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
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1 @@ | ||
Write-Output "$env:PackageName $env:PackageVersion Uninstalled" |
1 change: 1 addition & 0 deletions
1
...ocolatey.tests.integration/context/shims/shimbasepackage/1.0.0/tools/shimbasepackage1.exe
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
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1 @@ | ||
1.0.0 |
20 changes: 20 additions & 0 deletions
20
...ocolatey.tests.integration/context/shims/shimhasdependency/1.0.0/shimhasdependency.nuspec
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
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> |
1 change: 1 addition & 0 deletions
1
...latey.tests.integration/context/shims/shimhasdependency/1.0.0/tools/chocolateyInstall.ps1
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
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1 @@ | ||
Write-Output "$env:PackageName $env:PackageVersion Installed" |
1 change: 1 addition & 0 deletions
1
...tey.tests.integration/context/shims/shimhasdependency/1.0.0/tools/chocolateyUninstall.ps1
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
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1 @@ | ||
Write-Output "$env:PackageName $env:PackageVersion Uninstalled" |
1 change: 1 addition & 0 deletions
1
...atey.tests.integration/context/shims/shimhasdependency/1.0.0/tools/shimhasdependency1.exe
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
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1 @@ | ||
1.0.0 |
17 changes: 17 additions & 0 deletions
17
src/chocolatey.tests.integration/context/shims/shimoverwrite/1.0.0/shimoverwrite.nuspec
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
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> |
1 change: 1 addition & 0 deletions
1
...hocolatey.tests.integration/context/shims/shimoverwrite/1.0.0/tools/chocolateyInstall.ps1
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
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1 @@ | ||
Write-Output "$env:PackageName $env:PackageVersion Installed" |
1 change: 1 addition & 0 deletions
1
...colatey.tests.integration/context/shims/shimoverwrite/1.0.0/tools/chocolateyUninstall.ps1
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
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1 @@ | ||
Write-Output "$env:PackageName $env:PackageVersion Uninstalled" |
1 change: 1 addition & 0 deletions
1
...atey.tests.integration/context/shims/shimoverwrite/1.0.0/tools/install/shimoverwrite1.exe
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
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1 @@ | ||
1.0.0 |
1 change: 1 addition & 0 deletions
1
src/chocolatey.tests.integration/context/shims/shimoverwrite/1.0.0/tools/shimoverwrite1.exe
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
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1 @@ | ||
1.0.0 |
20 changes: 20 additions & 0 deletions
20
...olatey.tests.integration/context/shims/shimoverwriteother/1.0.0/shimoverwriteother.nuspec
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
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> |
1 change: 1 addition & 0 deletions
1
...atey.tests.integration/context/shims/shimoverwriteother/1.0.0/tools/chocolateyInstall.ps1
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
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1 @@ | ||
Write-Output "$env:PackageName $env:PackageVersion Installed" |
1 change: 1 addition & 0 deletions
1
...ey.tests.integration/context/shims/shimoverwriteother/1.0.0/tools/chocolateyUninstall.ps1
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
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1 @@ | ||
Write-Output "$env:PackageName $env:PackageVersion Uninstalled" |
1 change: 1 addition & 0 deletions
1
...latey.tests.integration/context/shims/shimoverwriteother/1.0.0/tools/shimbasepackage1.exe
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
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1 @@ | ||
1.0.0 |
17 changes: 17 additions & 0 deletions
17
src/chocolatey.tests.integration/context/shims/shimupgrade/1.0.0/shimupgrade.nuspec
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
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> |
1 change: 1 addition & 0 deletions
1
src/chocolatey.tests.integration/context/shims/shimupgrade/1.0.0/tools/chocolateyInstall.ps1
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
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1 @@ | ||
Write-Output "$env:PackageName $env:PackageVersion Installed" |
1 change: 1 addition & 0 deletions
1
...hocolatey.tests.integration/context/shims/shimupgrade/1.0.0/tools/chocolateyUninstall.ps1
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
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1 @@ | ||
Write-Output "$env:PackageName $env:PackageVersion Uninstalled" |
1 change: 1 addition & 0 deletions
1
src/chocolatey.tests.integration/context/shims/shimupgrade/1.0.0/tools/shimupgrade1.exe
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
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1 @@ | ||
1.0.0 |
17 changes: 17 additions & 0 deletions
17
src/chocolatey.tests.integration/context/shims/shimupgrade/2.0.0/shimupgrade.nuspec
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
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>2.0.0</version> | ||
<title>shimupgrade</title> | ||
<authors>__REPLACE_AUTHORS_OF_SOFTWARE__</authors> | ||
<owners>__REPLACE_YOUR_NAME__</owners> | ||
<requireLicenseAcceptance>false</requireLicenseAcceptance> | ||
<description>This version throws an error when installing</description> | ||
<summary>__REPLACE__</summary> | ||
<tags>shimupgrade</tags> | ||
</metadata> | ||
<files> | ||
<file src="tools\**" target="tools" /> | ||
</files> | ||
</package> |
7 changes: 7 additions & 0 deletions
7
src/chocolatey.tests.integration/context/shims/shimupgrade/2.0.0/tools/chocolateyInstall.ps1
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
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,7 @@ | ||
try { | ||
Write-Output "This is $packageName v$packageVersion being installed to `n '$packageFolder'." | ||
Write-Error "Oh no! An error" | ||
throw "We had an error captain!" | ||
} catch { | ||
throw $_.Exception | ||
} |
1 change: 1 addition & 0 deletions
1
...hocolatey.tests.integration/context/shims/shimupgrade/2.0.0/tools/chocolateyUninstall.ps1
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
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1 @@ | ||
Write-Output "$env:PackageName $env:PackageVersion Uninstalled" |
1 change: 1 addition & 0 deletions
1
src/chocolatey.tests.integration/context/shims/shimupgrade/2.0.0/tools/shimupgrade2.exe
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
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1 @@ | ||
2.0.0 |
Oops, something went wrong.