|
1 | 1 | <# |
2 | 2 | .SYNOPSIS |
3 | | - Installs a Chocolatey package a repository. |
| 3 | + Installs a package from a Chocolatey repository. |
4 | 4 |
|
5 | 5 | .DESCRIPTION |
6 | | - Installs a package from a Chocolatey repository like Chocolatey.org. |
| 6 | + Installs a package from a Chocolatey repository like the Chocolatey community repository. |
7 | 7 |
|
8 | 8 | Relevant Dependency metadata: |
9 | 9 | Name: The name of the package |
10 | 10 | Version: Used to identify existing installs meeting this criteria. Defaults to 'latest' |
11 | 11 | Source: Source Uri. Defaults to https://community.chocolatey.org/api/v2/ |
12 | 12 |
|
| 13 | + .PARAMETER Dependency |
| 14 | + Dependency to process |
| 15 | +
|
13 | 16 | .PARAMETER Force |
14 | 17 | If specified and the package is already installed, force the install again. |
15 | 18 |
|
| 19 | + .PARAMETER ChocoInstallScriptUrl |
| 20 | + Url to the script used to bootstrap Chocolatey when choco.exe is not found. |
| 21 | + Defaults to https://community.chocolatey.org/install.ps1 |
| 22 | +
|
16 | 23 | .PARAMETER PSDependAction |
17 | 24 | Test, or Install the package. Defaults to Install |
18 | 25 |
|
|
27 | 34 | } |
28 | 35 | } |
29 | 36 |
|
30 | | - # Install version 2.0.2 of git via Chocolatey.org |
| 37 | + # Install version 2.0.2 of git from the Chocolatey community repository |
31 | 38 |
|
32 | 39 | .EXAMPLE |
33 | 40 | @{ |
|
54 | 61 | 'putty' = 'latest' |
55 | 62 | } |
56 | 63 |
|
57 | | - # Installs the list of Chocolatey packages from Chocolatey.org using the Global PSDependOptions to limit repetition. |
| 64 | + # Installs the list of Chocolatey packages from the Chocolatey community repository using the Global PSDependOptions to limit repetition. |
58 | 65 |
|
59 | 66 | #> |
60 | 67 | [CmdletBinding()] |
@@ -304,9 +311,23 @@ else { |
304 | 311 | # If the version in the remote repository is less than or equal to the version installed, then we have the latest already |
305 | 312 | [System.Version]$parsedRepositoryVersion = $null |
306 | 313 | [System.Version]$parsedExistingVersion = $null |
307 | | -$haveLatest = [System.Version]::TryParse($repositoryVersion, [ref]$parsedRepositoryVersion) -and |
308 | | - [System.Version]::TryParse($existingVersion, [ref]$parsedExistingVersion) -and |
| 314 | +[System.Management.Automation.SemanticVersion]$parsedRepositorySemanticVersion = $null |
| 315 | +[System.Management.Automation.SemanticVersion]$parsedExistingSemanticVersion = $null |
| 316 | +$haveLatest = if ( |
| 317 | + [System.Management.Automation.SemanticVersion]::TryParse([string]$repositoryVersion, [ref]$parsedRepositorySemanticVersion) -and |
| 318 | + [System.Management.Automation.SemanticVersion]::TryParse([string]$existingVersion, [ref]$parsedExistingSemanticVersion) |
| 319 | +) { |
| 320 | + $parsedRepositorySemanticVersion -le $parsedExistingSemanticVersion |
| 321 | +} |
| 322 | +elseif ( |
| 323 | + [System.Version]::TryParse([string]$repositoryVersion, [ref]$parsedRepositoryVersion) -and |
| 324 | + [System.Version]::TryParse([string]$existingVersion, [ref]$parsedExistingVersion) |
| 325 | +) { |
309 | 326 | $parsedRepositoryVersion -le $parsedExistingVersion |
| 327 | +} |
| 328 | +else { |
| 329 | + $false |
| 330 | +} |
310 | 331 | if ($Version -eq 'latest' -and $haveLatest) { |
311 | 332 | Write-Verbose "You have the latest version of [$Name], with installed version [$existingVersion] and Source version [$repositoryVersion]" |
312 | 333 | if ($PSDependAction -contains 'Test') { |
|
0 commit comments