feat: Return apt packages with their installed versions (#2939)

This commit is contained in:
hackercat
2021-03-26 06:28:15 +01:00
committed by GitHub
parent 6168b56552
commit abbad83bb1
2 changed files with 15 additions and 5 deletions

View File

@@ -295,10 +295,20 @@ function Get-CachedDockerImagesTableData {
} }
function Get-AptPackages { function Get-AptPackages {
$toolsetJson = Get-ToolsetContent $apt = (Get-ToolsetContent).Apt
$apt = $toolsetJson.apt $output = @()
$pkgs = ($apt.common_packages + $apt.cmd_packages | Sort-Object) -join ", " ForEach ($pkg in ($apt.common_packages + $apt.cmd_packages)) {
return $pkgs $version = $(dpkg-query -W -f '${Version}' $pkg)
if ($Null -eq $version) {
$version = $(dpkg-query -W -f '${Version}' "$pkg*")
}
$output += [PSCustomObject] @{
Name = $pkg
Version = $version
}
}
return ($output | Sort-Object Name)
} }
function Get-PipxVersion { function Get-PipxVersion {

View File

@@ -286,6 +286,6 @@ $markdown += Get-CachedDockerImagesTableData | New-MDTable
$markdown += New-MDNewLine $markdown += New-MDNewLine
$markdown += New-MDHeader "Installed apt packages" -Level 3 $markdown += New-MDHeader "Installed apt packages" -Level 3
$markdown += New-MDList -Style Unordered -Lines @(Get-AptPackages) $markdown += Get-AptPackages | New-MDTable
$markdown | Out-File -FilePath "${OutputDirectory}/Ubuntu-Readme.md" $markdown | Out-File -FilePath "${OutputDirectory}/Ubuntu-Readme.md"