Created
April 20, 2022 06:34
-
-
Save mwallner/9cb37687f7caf5e5f9d5c8f768e098aa to your computer and use it in GitHub Desktop.
simple script to check if a given choco package and all transitive dependencies are installed
This file contains hidden or 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
[cmdletbinding()] | |
param( | |
$packageName | |
) | |
$ErrorActionPreference = 'Stop' | |
function Test-TransitiveDependencies { | |
[cmdletbinding()] | |
param($allPackages, $pkgID) | |
$pCheck = $allPackages | Where-Object { $_.package.metadata.id -eq $pkgID } | |
if (-Not $pCheck) { | |
throw "required package '$pkgId' not present!" | |
} | |
else { | |
Write-Verbose "required package $pkgId is present." | |
} | |
if ($pCheck.package.metadata.dependencies) { | |
foreach ($dep in $pCheck.package.metadata.dependencies.dependency) { | |
Write-Verbose "$pkgId -> requries '$($dep.id)'" | |
Test-TransitiveDependencies -allPackages $allPackages -pkgID $dep.id | |
} | |
} | |
} | |
$allPackages = (Get-ChildItem -Recurse $env:ChocolateyInstall\lib\ -Filter '*.nuspec') | Foreach-Object { | |
[xml](Get-Content $_.FullName) | |
} | |
$pRoot = $allPackages | Where-Object { $_.package.metadata.id -eq $packageName } | |
Test-TransitiveDependencies $allPackages $pRoot.package.metadata.id | |
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment
note: only checks for ids, no version check is done in this initial version