From 3ea5c7d183c9d100fbb6e920142659829b151869 Mon Sep 17 00:00:00 2001 From: Aleksandr Chebotov Date: Fri, 11 Sep 2020 14:59:17 +0300 Subject: [PATCH 01/15] Add markdown file's generation to Ubuntu images --- .../SoftwareReport.Android.psm1 | 147 +++++++++ .../SoftwareReport.Browsers.psm1 | 19 ++ .../SoftwareReport.CachedTools.psm1 | 65 ++++ .../SoftwareReport/SoftwareReport.Common.psm1 | 296 ++++++++++++++++++ .../SoftwareReport.Databases.psm1 | 19 ++ .../SoftwareReport.Generator.ps1 | 221 +++++++++++++ .../SoftwareReport.Helpers.psm1 | 52 +++ .../SoftwareReport/SoftwareReport.Java.psm1 | 30 ++ .../SoftwareReport/SoftwareReport.Tools.psm1 | 249 +++++++++++++++ images/linux/ubuntu1604.json | 17 +- images/linux/ubuntu1804.json | 17 +- images/linux/ubuntu2004.json | 17 +- 12 files changed, 1146 insertions(+), 3 deletions(-) create mode 100644 images/linux/scripts/SoftwareReport/SoftwareReport.Android.psm1 create mode 100644 images/linux/scripts/SoftwareReport/SoftwareReport.Browsers.psm1 create mode 100644 images/linux/scripts/SoftwareReport/SoftwareReport.CachedTools.psm1 create mode 100644 images/linux/scripts/SoftwareReport/SoftwareReport.Common.psm1 create mode 100644 images/linux/scripts/SoftwareReport/SoftwareReport.Databases.psm1 create mode 100644 images/linux/scripts/SoftwareReport/SoftwareReport.Generator.ps1 create mode 100644 images/linux/scripts/SoftwareReport/SoftwareReport.Helpers.psm1 create mode 100644 images/linux/scripts/SoftwareReport/SoftwareReport.Java.psm1 create mode 100644 images/linux/scripts/SoftwareReport/SoftwareReport.Tools.psm1 diff --git a/images/linux/scripts/SoftwareReport/SoftwareReport.Android.psm1 b/images/linux/scripts/SoftwareReport/SoftwareReport.Android.psm1 new file mode 100644 index 000000000..7f34143a9 --- /dev/null +++ b/images/linux/scripts/SoftwareReport/SoftwareReport.Android.psm1 @@ -0,0 +1,147 @@ +function Split-TableRowByColumns { + param( + [string] $Row + ) + return $Row.Split("|") | ForEach-Object { $_.trim() } +} + +function Get-AndroidSDKRoot { + return "/usr/local/lib/android/sdk" +} + +function Get-AndroidSDKManagerPath { + $androidSDKDir = Get-AndroidSDKRoot + return Join-Path $androidSDKDir "tools" "bin" "sdkmanager" +} + +function Get-AndroidInstalledPackages { + $androidSDKManagerPath = Get-AndroidSDKManagerPath + $androidSDKManagerList = Invoke-Expression "$androidSDKManagerPath --list --include_obsolete" + $androidInstalledPackages = @() + foreach($packageInfo in $androidSDKManagerList) { + if($packageInfo -Match "Available Packages:") { + break + } + + $androidInstalledPackages += $packageInfo + } + return $androidInstalledPackages +} + + +function Build-AndroidTable { + $packageInfo = Get-AndroidInstalledPackages + return @( + @{ + "Package" = "Android SDK Platform-Tools" + "Version" = Get-AndroidPackageVersions -PackageInfo $packageInfo -MatchedString "Android SDK Platform-Tools" + }, + @{ + "Package" = "Android SDK Tools" + "Version" = Get-AndroidPackageVersions -PackageInfo $packageInfo -MatchedString "Android SDK Tools" + }, + @{ + "Package" = "Android SDK Platforms" + "Version" = Get-AndroidPlatformVersions -PackageInfo $packageInfo + }, + @{ + "Package" = "Android SDK Build-tools" + "Version" = Get-AndroidBuildToolVersions -PackageInfo $packageInfo + }, + @{ + "Package" = "Google APIs" + "Version" = Get-AndroidGoogleAPIsVersions -PackageInfo $packageInfo + }, + @{ + "Package" = "Android Support Repository" + "Version" = Get-AndroidPackageVersions -PackageInfo $packageInfo -MatchedString "Android Support Repository" + }, + @{ + "Package" = "Google Play services" + "Version" = Get-AndroidPackageVersions -PackageInfo $packageInfo -MatchedString "Google Play services" + }, + @{ + "Package" = "Google Repository" + "Version" = Get-AndroidPackageVersions -PackageInfo $packageInfo -MatchedString "Google Repository" + }, + @{ + "Package" = "SDK Patch Applier v4" + "Version" = Get-AndroidPackageVersions -PackageInfo $packageInfo -MatchedString "SDK Patch Applier v4" + }, + @{ + "Package" = "CMake" + "Version" = Get-AndroidPackageVersions -PackageInfo $packageInfo -MatchedString "cmake" + }, + @{ + "Package" = "NDK" + "Version" = Get-AndroidPackageVersions -PackageInfo $packageInfo -MatchedString "ndk-bundle" + } + ) | Where-Object { $_.Version } | ForEach-Object { + [PSCustomObject] @{ + "Package Name" = $_.Package + "Version" = $_.Version + } + } +} + +function Get-AndroidPackageVersions { + param ( + [Parameter(Mandatory)] + [object] $PackageInfo, + [Parameter(Mandatory)] + [object] $MatchedString + ) + + $versions = $packageInfo | Where-Object { $_ -Match $MatchedString } | ForEach-Object { + $packageInfoParts = Split-TableRowByColumns $_ + return $packageInfoParts[1] + } + return ($versions -Join "
") +} + +function Get-AndroidPlatformVersions { + param ( + [Parameter(Mandatory)] + [object] $PackageInfo + ) + + $versions = $packageInfo | Where-Object { $_ -Match "Android SDK Platform " } | ForEach-Object { + $packageInfoParts = Split-TableRowByColumns $_ + $revision = $packageInfoParts[1] + $version = $packageInfoParts[0].split(";")[1] + return "$version, (rev $revision)" + } + [array]::Reverse($versions) + return ($versions -Join "
") +} + +function Get-AndroidBuildToolVersions { + param ( + [Parameter(Mandatory)] + [object] $PackageInfo + ) + + $versions = $packageInfo | Where-Object { $_ -Match "Android SDK Build-Tools" } | ForEach-Object { + $packageInfoParts = Split-TableRowByColumns $_ + return $packageInfoParts[1] + } + $groupVersions = @() + $versions | ForEach-Object { + $majorVersion = $_.Split(".")[0] + $groupVersions += $versions | Where-Object { $_.StartsWith($majorVersion) } | Join-String -Separator " " + } + return ($groupVersions | Sort-Object -Descending -Unique | Join-String -Separator "
") +} + +function Get-AndroidGoogleAPIsVersions { + param ( + [Parameter(Mandatory)] + [object] $PackageInfo + ) + + $versions = $packageInfo | Where-Object { $_ -Match "Google APIs" } | ForEach-Object { + $packageInfoParts = Split-TableRowByColumns $_ + return $packageInfoParts[0].split(";")[1] + } + return ($versions -Join "
") +} \ No newline at end of file diff --git a/images/linux/scripts/SoftwareReport/SoftwareReport.Browsers.psm1 b/images/linux/scripts/SoftwareReport/SoftwareReport.Browsers.psm1 new file mode 100644 index 000000000..96d05ee08 --- /dev/null +++ b/images/linux/scripts/SoftwareReport/SoftwareReport.Browsers.psm1 @@ -0,0 +1,19 @@ +function Get-ChromeVersion { + $googleChromeVersion = google-chrome --version | Take-Part -Part 2 + return "Google Chrome $googleChromeVersion" +} + +function Get-ChromeDriverVersion { + $chromeDriverVersion = chromedriver --version | Take-Part -Part 1 + return "ChromeDriver $chromeDriverVersion" +} + +function Get-FirefoxVersion { + $firefoxVersion = firefox --version + return $firefoxVersion +} + +function Get-GeckodriverVersion { + $geckodriverVersion = geckodriver --version | Select-Object -First 1 | Take-Part -Part 1 + return "Geckodriver $geckodriverVersion" +} \ No newline at end of file diff --git a/images/linux/scripts/SoftwareReport/SoftwareReport.CachedTools.psm1 b/images/linux/scripts/SoftwareReport/SoftwareReport.CachedTools.psm1 new file mode 100644 index 000000000..536b31255 --- /dev/null +++ b/images/linux/scripts/SoftwareReport/SoftwareReport.CachedTools.psm1 @@ -0,0 +1,65 @@ +function Get-ToolcacheRubyVersions { + $toolcachePath = Join-Path $env:AGENT_TOOLSDIRECTORY "Ruby" + return Get-ChildItem $toolcachePath -Name | Sort-Object { [Version]$_ } +} + +function Get-ToolcachePythonVersions { + $toolcachePath = Join-Path $env:AGENT_TOOLSDIRECTORY "Python" + return Get-ChildItem $toolcachePath -Name | Sort-Object { [Version]$_ } +} + +function Get-ToolcachePyPyVersions { + $toolcachePath = Join-Path $env:AGENT_TOOLSDIRECTORY "PyPy" + Get-ChildItem -Path $toolcachePath -Name | Sort-Object { [Version] $_ } | ForEach-Object { + $pypyRootPath = Join-Path $toolcachePath $_ "x64" + [string]$pypyVersionOutput = & "$pypyRootPath/bin/python" -c "import sys;print(sys.version)" + $pypyVersionOutput -match "^([\d\.]+) \(.+\) \[PyPy ([\d\.]+) .+]$" | Out-Null + return "{0} [PyPy {1}]" -f $Matches[1], $Matches[2] + } +} + +function Get-ToolcacheNodeVersions { + $toolcachePath = Join-Path $env:AGENT_TOOLSDIRECTORY "node" + return Get-ChildItem $toolcachePath -Name | Sort-Object { [Version]$_ } +} + +function Get-ToolcacheGoVersions { + $toolcachePath = Join-Path $env:AGENT_TOOLSDIRECTORY "go" + return Get-ChildItem $toolcachePath -Name | Sort-Object { [Version]$_ } +} + +function Get-ToolcacheBoostVersions { + $toolcachePath = Join-Path $env:AGENT_TOOLSDIRECTORY "boost" + if (-not (Test-Path $toolcachePath)) { + return @() + } + return Get-ChildItem $toolcachePath -Name | Sort-Object { [Version]$_ } +} + +function Build-CachedToolsSection { + $output = "" + + $output += New-MDHeader "Ruby" -Level 4 + $output += New-MDList -Lines (Get-ToolcacheRubyVersions) -Style Unordered + + $output += New-MDHeader "Python" -Level 4 + $output += New-MDList -Lines (Get-ToolcachePythonVersions) -Style Unordered + + $output += New-MDHeader "PyPy" -Level 4 + $output += New-MDList -Lines (Get-ToolcachePyPyVersions) -Style Unordered + + $output += New-MDHeader "Node.js" -Level 4 + $output += New-MDList -Lines (Get-ToolcacheNodeVersions) -Style Unordered + + $output += New-MDHeader "Go" -Level 4 + $output += New-MDList -Lines (Get-ToolcacheGoVersions) -Style Unordered + + $boostVersions = Get-ToolcacheBoostVersions + if ($boostVersions.Count -gt 0) { + $output += New-MDHeader "Boost" -Level 4 + $output += New-MDList -Lines $boostVersions -Style Unordered + } + + + return $output +} \ No newline at end of file diff --git a/images/linux/scripts/SoftwareReport/SoftwareReport.Common.psm1 b/images/linux/scripts/SoftwareReport/SoftwareReport.Common.psm1 new file mode 100644 index 000000000..1d96f5550 --- /dev/null +++ b/images/linux/scripts/SoftwareReport/SoftwareReport.Common.psm1 @@ -0,0 +1,296 @@ +Import-Module (Join-Path $PSScriptRoot "SoftwareReport.Helpers.psm1") -DisableNameChecking + +function Get-OSName { + lsb_release -ds +} + +function Get-CPPVersions { + $cppVersions = & apt list --installed | Where-Object { $_ -match "g\+\+-\d+"} | ForEach-Object { + $_ -match "now (?\d+\.\d+\.\d+)-" | Out-Null + $Matches.version + } + return "GNU C++ " + ($cppVersions -Join ", ") +} + +function Get-FortranVersions { + $fortranVersions = & apt list --installed | Where-Object { $_ -match "^gfortran-\d+"} | ForEach-Object { + $_ -match "now (?\d+\.\d+\.\d+)-" | Out-Null + $Matches.version + } + return "GNU Fortran " + ($fortranVersions -Join ", ") +} + +function Get-ClangVersions { + $clangVersions = @() + $clangVersions = & apt list --installed | Where-Object { $_ -match "^clang-\d+"} | ForEach-Object { + $clangCommand = ($_ -Split "/")[0] + Invoke-Expression "$clangCommand --version" | Where-Object { $_ -match "clang version" } | ForEach-Object { + $_ -match "clang version (?\d+\.\d+\.\d+)-" | Out-Null + $Matches.version + } + } + return "Clang " + ($clangVersions -Join ", ") +} + +function Get-ErlangVersion { + $result = Get-CommandResult "erl -version" + $result.Output -match "version (?\d+\.\d+\.\d+)" | Out-Null + $version = $Matches.version + return "Erlang $version" +} + +function Get-MonoVersion { + $monoVersion = $(mono --version) | Out-String | Take-Part -Part 4 + return "Mono $monoVersion" +} + +function Get-NodeVersion { + $nodeVersion = $(node --version).Substring(1) + return "Node $nodeVersion" +} + +function Get-PythonVersion { + $result = Get-CommandResult "python --version" + $version = $result.Output | Take-Part -Part 1 + return "Python $version" +} + +function Get-Python3Version { + $result = Get-CommandResult "python3 --version" + $version = $result.Output | Take-Part -Part 1 + return "Python3 $version" +} + +function Get-PowershellVersion { + $(pwsh --version) +} + +function Get-RubyVersion { + $rubyVersion = $(ruby --version) | Out-String | Take-Part -Part 1 + return "Ruby $rubyVersion" +} + +function Get-SwiftVersion { + $swiftVersion = $(swift --version) | Out-String | Take-Part -Part 2 + return "Swift $swiftVersion" +} + +function Get-JuliaVersion { + $juliaVersion = $(julia --version) | Out-String | Take-Part -Part 2 + return "Julia $juliaVersion" +} + +function Get-HomebrewVersion { + $result = Get-CommandResult "brew -v" + $result.Output -match "Homebrew (?\d+\.\d+\.\d+)" | Out-Null + $version = $Matches.version + return "Homebrew $version" +} + +function Get-GemVersion { + $(gem --version) -match "(?\d+\.\d+\.\d+)" | Out-Null + $gemVersion = $Matches.version + return "Gem $gemVersion" +} + +function Get-MinicondaVersion { + $condaVersion = $(conda --version) + return "Mini$condaVersion" +} + +function Get-HelmVersion { + $(helm version) -match 'Version:"v(?\d+\.\d+\.\d+)"' | Out-Null + $helmVersion = $Matches.version + return "Helm $helmVersion" +} + +function Get-NpmVersion { + $npmVersion = $(npm --version) + return "Npm $npmVersion" +} + +function Get-YarnVersion { + $yarnVersion = $(yarn --version) + return "Yarn $yarnVersion" +} + +function Get-PipVersion { + $result = Get-CommandResult "pip --version" + $result.Output -match "pip (?\d+\.\d+\.\d+)" | Out-Null + $pipVersion = $Matches.version + return "Pip $pipVersion" +} + +function Get-Pip3Version { + $result = Get-CommandResult "pip3 --version" + $result.Output -match "pip (?\d+\.\d+\.\d+)" | Out-Null + $pipVersion = $Matches.version + return "Pip3 $pipVersion" +} + +function Get-VcpkgVersion { + $result = Get-CommandResult "vcpkg version" + $result.Output -match "version (?\d+\.\d+\.\d+)" | Out-Null + $vcpkgVersion = $Matches.version + return "Vcpkg $vcpkgVersion" +} + +function Get-AntVersion { + $result = $(ant -version) | Out-String + $result -match "version (?\d+\.\d+\.\d+)" | Out-Null + $antVersion = $Matches.version + return "Ant $antVersion" +} + +function Get-GradleVersion { + $result = $(gradle -v) | Out-String + $result -match "Gradle (?\d+\.\d+\.\d+)" | Out-Null + $gradleVersion = $Matches.version + return "Gradle $gradleVersion" +} +function Get-MavenVersion { + $result = $(mvn -version) | Out-String + $result -match "Apache Maven (?\d+\.\d+\.\d+)" | Out-Null + $mavenVersion = $Matches.version + return "Maven $mavenVersion" +} +function Get-SbtVersion { + $result = $(sbt -version) | Out-String + $result -match "sbt script version: (?\d+\.\d+\.\d+)" | Out-Null + $sbtVersion = $Matches.version + return "Sbt $sbtVersion" +} + +function Get-PHPVersions { + return $(apt list --installed) | Where-Object { $_ -match "^php\d+\.\d+/"} | ForEach-Object { + $_ -match "now (?\d+\.\d+\.\d+)-" | Out-Null + $Matches.version + } +} + +function Get-ComposerVersion { + $(composer --version) -match "Composer version (?\d+\.\d+\.\d+)\s" | Out-Null + return $Matches.version +} + +function Get-PHPUnitVersion { + $(phpunit --version | Out-String) -match "PHPUnit (?\d+\.\d+\.\d+)\s" | Out-Null + return $Matches.version +} + +function Build-PHPTable { + $php = @{ + "Tool" = "PHP" + "Version" = "$(Get-PHPVersions -Join '
')" + } + $composer = @{ + "Tool" = "Composer" + "Version" = Get-ComposerVersion + } + $phpunit = @{ + "Tool" = "PHPUnit" + "Version" = Get-PHPUnitVersion + } + return @($php, $composer, $phpunit) | ForEach-Object { + [PSCustomObject] @{ + "Tool" = $_.Tool + "Version" = $_.Version + } + } +} + +function Get-GHCVersion { + $(ghc --version) -match "version (?\d+\.\d+\.\d+)" | Out-Null + $ghcVersion = $Matches.version + return "GHC $ghcVersion" +} + +function Get-CabalVersion { + $(cabal --version | Out-String) -match "cabal-install version (?\d+\.\d+\.\d+\.\d+)" | Out-Null + $cabalVersion = $Matches.version + return "Cabal $cabalVersion" +} + +function Get-StackVersion { + $(stack --version | Out-String) -match "Version (?\d+\.\d+\.\d+)" | Out-Null + $stackVersion = $Matches.version + return "Stack $stackVersion" +} + +function Get-RustVersion { + $rustVersion = $(rustc --version) | Take-Part -Part 1 + return "Rust $rustVersion" +} + +function Get-BindgenVersion { + $bindgenVersion = $(bindgen --version) | Take-Part -Part 1 + return "Bindgen $bindgenVersion" +} + +function Get-CargoVersion { + $cargoVersion = $(cargo --version) | Take-Part -Part 1 + return "Cargo $cargoVersion" +} + +function Get-CargoAuditVersion { + $cargoAuditVersion = $(cargo audit --version) | Take-Part -Part 1 + return "Cargo audit $cargoAuditVersion" +} + +function Get-CargoOutdatedVersion { + $cargoOutdatedVersion = $(cargo outdated --version) | Take-Part -Part 1 -Delimiter "v" + return "Cargo outdated $cargoOutdatedVersion" +} + +function Get-CargoClippyVersion { + $cargoClippyVersion = $(cargo-clippy --version) | Take-Part -Part 1 + return "Cargo clippy $cargoClippyVersion" +} + +function Get-CbindgenVersion { + $cbindgenVersion = $(cbindgen --version) | Take-Part -Part 1 + return "Cbindgen $cbindgenVersion" +} + +function Get-RustupVersion { + $rustupVersion = $(rustup --version) | Take-Part -Part 1 + return "Rustup $rustupVersion" +} + +function Get-RustdocVersion { + $rustdocVersion = $(rustdoc --version) | Take-Part -Part 1 + return "Rustdoc $rustdocVersion" +} + +function Get-RustfmtVersion { + $rustfmtVersion = $(rustfmt --version) | Take-Part -Part 1 | Take-Part -Part 0 -Delimiter "-" + return "Rustfmt $rustfmtVersion" +} + +function Get-AzModuleVersions { + $azModuleVersions = Get-ChildItem /usr/share | Where-Object { $_ -match "az_\d+" } | Foreach-Object { + $_.Name.Split("_")[1] + } + + $azModuleVersions = $azModuleVersions -join " " + return $azModuleVersions +} + +function Get-DotNetCoreSdkVersions { + $unsortedDotNetCoreSdkVersion = dotnet --list-sdks list | ForEach-Object { $_ | Take-Part -Part 0 } + $dotNetCoreSdkVersion = $unsortedDotNetCoreSdkVersion -join " " + return $dotNetCoreSdkVersion +} + +function Get-CachedDockerImages { + $toolsetJson = Get-ToolsetContent + $images = $toolsetJson.docker.images + return $images +} + +function Get-AptPackages { + $toolsetJson = Get-ToolsetContent + $apt = $toolsetJson.apt + $pkgs = ($apt.common_packages + $apt.cmd_packages | Sort-Object) -join ", " + return $pkgs +} \ No newline at end of file diff --git a/images/linux/scripts/SoftwareReport/SoftwareReport.Databases.psm1 b/images/linux/scripts/SoftwareReport/SoftwareReport.Databases.psm1 new file mode 100644 index 000000000..6c274184e --- /dev/null +++ b/images/linux/scripts/SoftwareReport/SoftwareReport.Databases.psm1 @@ -0,0 +1,19 @@ +function Get-PostgreSqlVersion { + $postgreSQLVersion = psql --version | Take-Part -Part 2 + return "Postgre SQL $postgreSQLVersion" +} + +function Get-MongoDbVersion { + $mongoDBVersion = mongod --version | Select-Object -First 1 | Take-Part -Part 2 -Delimiter "v" + return "MongoDB $mongoDBVersion" +} + +function Get-SqliteVersion { + $sqliteVersion = sqlite3 --version | Take-Part -Part 0 + return "sqlite3 $sqliteVersion" +} + +function Get-MySqlVersion { + $mySqlVersion = (mysql --version).Split("/usr/bin/")[1] + return "MySQL ($mySqlVersion)" +} \ No newline at end of file diff --git a/images/linux/scripts/SoftwareReport/SoftwareReport.Generator.ps1 b/images/linux/scripts/SoftwareReport/SoftwareReport.Generator.ps1 new file mode 100644 index 000000000..e63f3719a --- /dev/null +++ b/images/linux/scripts/SoftwareReport/SoftwareReport.Generator.ps1 @@ -0,0 +1,221 @@ +param ( + [Parameter(Mandatory)][string] + $OutputDirectory +) + +# Install MarkdownPS module for software report generation +Install-Module MarkdownPS -Force -Scope CurrentUser +Import-Module MarkdownPS +Import-Module (Join-Path $PSScriptRoot "SoftwareReport.CachedTools.psm1") -DisableNameChecking +Import-Module (Join-Path $PSScriptRoot "SoftwareReport.Common.psm1") -DisableNameChecking +Import-Module (Join-Path $PSScriptRoot "SoftwareReport.Helpers.psm1") -DisableNameChecking +Import-Module (Join-Path $PSScriptRoot "SoftwareReport.Tools.psm1") -DisableNameChecking +Import-Module (Join-Path $PSScriptRoot "SoftwareReport.Java.psm1") -DisableNameChecking +Import-Module (Join-Path $PSScriptRoot "SoftwareReport.Databases.psm1") -DisableNameChecking +Import-Module (Join-Path $PSScriptRoot "SoftwareReport.Browsers.psm1") -DisableNameChecking +Import-Module (Join-Path $PSScriptRoot "SoftwareReport.Android.psm1") -DisableNameChecking + +$markdown = "" + +if ($env:ANNOUNCEMENTS) { + $markdown += $env:ANNOUNCEMENTS + $markdown += New-MDNewLine + $markdown += "***" + $markdown += New-MDNewLine +} + +$OSName = Get-OSName +$markdown += New-MDHeader "$OSName" -Level 1 + +$markdown += New-MDList -Style Unordered -Lines @( + "Image Version: $env:ImageVersion" +) + +$markdown += New-MDHeader "Installed Software" -Level 2 +$markdown += New-MDHeader "Language and Runtime" -Level 3 + +$markdown += New-MDList -Style Unordered -Lines @( + (Get-CPPVersions), + (Get-FortranVersions), + (Get-ClangVersions), + (Get-ErlangVersion), + (Get-MonoVersion), + (Get-NodeVersion), + (Get-PythonVersion), + (Get-Python3Version), + (Get-PowershellVersion), + (Get-RubyVersion), + (Get-SwiftVersion), + (Get-JuliaVersion) +) + +$markdown += New-MDHeader "Package Management" -Level 3 +$markdown += New-MDList -Style Unordered -Lines @( + (Get-HomebrewVersion), + (Get-GemVersion), + (Get-MinicondaVersion), + (Get-HelmVersion), + (Get-NpmVersion), + (Get-YarnVersion), + (Get-PipVersion), + (Get-Pip3Version), + (Get-VcpkgVersion) +) + +$markdown += New-MDHeader "Project Management" -Level 3 +$markdown += New-MDList -Style Unordered -Lines @( + (Get-AntVersion), + (Get-GradleVersion), + (Get-MavenVersion), + (Get-SbtVersion) +) + +$markdown += New-MDHeader "Tools" -Level 3 +$toolsList = @( + (Get-7zipVersion), + (Get-AnsibleVersion), + (Get-AzCopy7Version), + (Get-AzCopy10Version), + (Get-BazelVersion), + (Get-BazeliskVersion), + (Get-CMakeVersion), + (Get-CurlVersion), + (Get-DockerComposeVersion), + (Get-DockerMobyVersion), + (Get-DockerBuildxVersion), + (Get-GitVersion), + (Get-GitLFSVersion), + (Get-GitFTPVersion), + (Get-GoogleCloudSDKVersion), + (Get-HavegedVersion), + (Get-HerokuVersion), + (Get-HHVMVersion), + (Get-SVNVersion), + (Get-JqVersion), + (Get-KindVersion), + (Get-KubectlVersion), + (Get-KustomizeVersion), + (Get-LeiningenVersion), + (Get-M4Version), + (Get-HGVersion), + (Get-MinikubeVersion), + (Get-NewmanVersion), + (Get-NvmVersion), + (Get-PackerVersion), + (Get-PhantomJSVersion), + (Get-SwigVersion), + (Get-TerraformVersion), + (Get-UnZipVersion), + (Get-WgetVersion), + (Get-ZipVersion), + (Get-ZstdVersion) +) + +if (-not (Test-IsUbuntu16)) { + $toolsList += @( + (Get-PodManVersion), + (Get-BuildahVersion), + (Get-SkopeoVersion) + ) +} + +$markdown += New-MDList -Style Unordered -Lines ($toolsList | Sort-Object) + +$markdown += New-MDHeader "CLI Tools" -Level 3 +$markdown += New-MDList -Style Unordered -Lines @( + (Get-AlibabaCloudCliVersion), + (Get-AWSCliVersion), + (Get-AWSCliSessionManagerPluginVersion), + (Get-AWSSAMVersion), + (Get-AzureCliVersion), + (Get-AzureDevopsVersion), + (Get-GitHubCliVersion), + (Get-HubCliVersion), + (Get-NetlifyCliVersion), + (Get-OCCliVersion), + (Get-ORASCliVersion), + (Get-VerselCliversion) +) + +$markdown += New-MDHeader "Java" -Level 3 +$markdown += Get-JavaVersions | New-MDTable +$markdown += New-MDNewLine + +$markdown += New-MDHeader "PHP" -Level 3 +$markdown += Build-PHPTable | New-MDTable +$markdown += New-MDNewLine + +$markdown += New-MDHeader "Haskell" -Level 3 +$markdown += New-MDList -Style Unordered -Lines @( + (Get-GHCVersion), + (Get-CabalVersion), + (Get-StackVersion) +) + +$markdown += New-MDHeader "Rust Tools" -Level 3 +$markdown += New-MDList -Style Unordered -Lines @( + (Get-RustVersion), + (Get-RustupVersion), + (Get-RustdocVersion), + (Get-CargoVersion) +) + +$markdown += New-MDHeader "Packages" -Level 4 +$markdown += New-MDList -Style Unordered -Lines @( + (Get-BindgenVersion), + (Get-CargoAuditVersion), + (Get-CargoOutdatedVersion), + (Get-CargoClippyVersion), + (Get-CbindgenVersion), + (Get-RustfmtVersion) +) + +$markdown += New-MDHeader "Browsers and Drivers" -Level 3 +$markdown += New-MDList -Style Unordered -Lines @( + (Get-ChromeVersion), + (Get-ChromeDriverVersion), + (Get-FirefoxVersion), + (Get-GeckodriverVersion) +) + +$markdown += New-MDHeader ".NET Core SDK" -Level 3 +$markdown += New-MDList -Style Unordered -Lines @( + (Get-DotNetCoreSdkVersions) +) + +$markdown += New-MDHeader "Az Module" -Level 3 +$markdown += New-MDList -Style Unordered -Lines @( + (Get-AzModuleVersions) +) + +$markdown += New-MDHeader "Databases" -Level 3 +$markdown += New-MDList -Style Unordered -Lines @( + (Get-PostgreSqlVersion), + (Get-MongoDbVersion), + (Get-SqliteVersion) +) + +$markdown += New-MDHeader "MySQL" -Level 4 +$markdown += New-MDList -Style Unordered -Lines @( + (Get-MySqlVersion), + "MySQL Server (user:root password:root)", + "MS SQL Server Client Tools" +) +$markdown += New-MDCode -Lines @( + "MySQL service is disabled by default. Use the following command as a part of your job to start the service: 'sudo systemctl start mysql.service'" +) + +$markdown += New-MDHeader "Cached Tools" -Level 3 +$markdown += Build-CachedToolsSection + +$markdown += New-MDHeader "Android" -Level 3 +$markdown += Build-AndroidTable | New-MDTable +$markdown += New-MDNewLine + +$markdown += New-MDHeader "Cached Docker images" -Level 3 +$markdown += New-MDList -Style Unordered -Lines @(Get-CachedDockerImages) + +$markdown += New-MDHeader "Installed apt packages" -Level 3 +$markdown += New-MDList -Style Unordered -Lines @(Get-AptPackages) + +$markdown | Out-File -FilePath "${OutputDirectory}/Ubuntu-Readme.md" diff --git a/images/linux/scripts/SoftwareReport/SoftwareReport.Helpers.psm1 b/images/linux/scripts/SoftwareReport/SoftwareReport.Helpers.psm1 new file mode 100644 index 000000000..6f2701c92 --- /dev/null +++ b/images/linux/scripts/SoftwareReport/SoftwareReport.Helpers.psm1 @@ -0,0 +1,52 @@ +function Get-CommandResult { + param ( + [Parameter(Mandatory=$true)] + [string] $Command, + [switch] $Multiline + ) + # Bash trick to suppress and show error output because some commands write to stderr (for example, "python --version") + $stdout = & bash -c "$Command 2>&1" + $exitCode = $LASTEXITCODE + return @{ + Output = If ($Multiline -eq $true) { $stdout } else { [string]$stdout } + ExitCode = $exitCode + } +} + +function Take-Part { + param ( + [Parameter(ValueFromPipeline)] + [string] $toolOutput, + [string] $Delimiter = " ", + [int[]] $Part + ) + $parts = $toolOutput.Split($Delimiter, [System.StringSplitOptions]::RemoveEmptyEntries) + $selectedParts = $parts[$Part] + return [string]::Join($Delimiter, $selectedParts) +} + +function Test-IsUbuntu16 { + return (lsb_release -rs) -eq "16.04" +} + +function Test-IsUbuntu18 { + return (lsb_release -rs) -eq "18.04" +} + +function Test-IsUbuntu20 { + return (lsb_release -rs) -eq "20.04" +} + +function Get-ToolsetContent +{ + $toolset = Join-Path $env:INSTALLER_SCRIPT_FOLDER "toolset.json" + Get-Content $toolset -Raw | ConvertFrom-Json +} + +function New-MDNewLine { + param ( + [int] $Count = 1 + ) + $newLineSymbol = [System.Environment]::NewLine + return $newLineSymbol * $Count +} diff --git a/images/linux/scripts/SoftwareReport/SoftwareReport.Java.psm1 b/images/linux/scripts/SoftwareReport/SoftwareReport.Java.psm1 new file mode 100644 index 000000000..4e54661ab --- /dev/null +++ b/images/linux/scripts/SoftwareReport/SoftwareReport.Java.psm1 @@ -0,0 +1,30 @@ +function Get-JavaFullVersion { + param($JavaRootPath) + + $javaBinPath = Join-Path $javaRootPath "/bin/java" + $javaVersionOutput = (Get-CommandResult "$javaBinPath -version").Output + $matchResult = $javaVersionOutput | Select-String '^openjdk version \"([\d\._]+)\"' + return $matchResult.Matches.Groups[1].Value +} + +function Get-JavaVersions { + $defaultJavaPath = $env:JAVA_HOME + $javaVersions = Get-Item env:JAVA_HOME_*_X64 + $sortRules = @{ + Expression = { [Int32]$_.Name.Split("_")[2] } + Descending = $false + } + + return $javaVersions | Sort-Object $sortRules | ForEach-Object { + $javaPath = $_.Value + $version = Get-JavaFullVersion $javaPath + $vendor = $version.StartsWith("1.7") ? "Zulu" : "AdoptOpenJDK" + $defaultPostfix = ($javaPath -eq $defaultJavaPath) ? " (default)" : "" + + [PSCustomObject] @{ + "Version" = $version + $defaultPostfix + "Vendor" = $vendor + "Environment Variable" = $_.Name + } + } +} \ No newline at end of file diff --git a/images/linux/scripts/SoftwareReport/SoftwareReport.Tools.psm1 b/images/linux/scripts/SoftwareReport/SoftwareReport.Tools.psm1 new file mode 100644 index 000000000..f66f2e4fc --- /dev/null +++ b/images/linux/scripts/SoftwareReport/SoftwareReport.Tools.psm1 @@ -0,0 +1,249 @@ +function Get-7zipVersion { + $7zVersion = 7z i | Select-String "7-Zip" | Take-Part -Part 2 + return "7-Zip $7zVersion" +} + +function Get-AnsibleVersion { + $ansibleVersion = ansible --version | Select-Object -First 1 | Take-Part -Part 1 + return "Ansible $ansibleVersion" +} + +function Get-AzCopy7Version { + $azcopy7Version = azcopy --version | Take-Part -Part 1 | Take-Part -Part 0 -Delimiter "-" + return "AzCopy7 (available by azcopy alias) $azcopy7Version" +} + +function Get-AzCopy10Version { + $azcopy10Version = azcopy10 --version | Take-Part -Part 2 + return "AzCopy10 (available by azcopy10 alias) $azcopy10Version" +} + +function Get-BazelVersion { + $bazelVersion = bazel --version | Select-String "bazel" | Take-Part -Part 1 + return "Bazel $bazelVersion" +} + +function Get-BazeliskVersion { + $bazeliskVersion = bazelisk version 2>&1 | Select-String "Bazelisk version:" | Take-Part -Part 2 | Take-Part -Part 0 -Delimiter "v" + return "Bazelisk $bazeliskVersion" +} + +function Get-PodManVersion { + $podmanVersion = podman --version | Take-Part -Part 2 + return "Podman $podmanVersion" +} + +function Get-BuildahVersion { + $buildahVersion = buildah --version | Take-Part -Part 2 + return "Buildah $buildahVersion" +} + +function Get-SkopeoVersion { + $skopeoVersion = skopeo --version | Take-Part -Part 2 + return "Skopeo $skopeoVersion" +} + +function Get-CMakeVersion { + $cmakeVersion = cmake --version | Select-Object -First 1 | Take-Part -Part 2 + return "CMake $cmakeVersion" +} + +function Get-CurlVersion { + $curlVersion = curl --version | Select-Object -First 1 | Take-Part -Part 0,1 + return $curlVersion +} + +function Get-DockerComposeVersion { + $composeVersion = docker-compose -v | Take-Part -Part 2 | Take-Part -Part 0 -Delimiter "," + return "Docker Compose $composeVersion" +} + +function Get-DockerMobyVersion { + $dockerVersion = docker -v | Take-Part -Part 2 | Take-Part -Part 0 -Delimiter "+" + return "Docker-Moby $dockerVersion" +} + +function Get-DockerBuildxVersion { + $buildxVersion = docker buildx version | Take-Part -Part 1 | Take-Part -Part 0 -Delimiter "+" + return "Docker-Buildx $buildxVersion" +} + +function Get-GitVersion { + $gitVersion = git --version 2>&1 | Take-Part -Part 2 + return "Git $gitVersion" +} + +function Get-GitLFSVersion { + $gitlfsversion = git-lfs --version 2>&1 | Take-Part -Part 0 | Take-Part -Part 1 -Delimiter "/" + return "Git LFS $gitlfsversion" +} + +function Get-GitFTPVersion { + $gitftpVersion = git-ftp --version | Take-Part -Part 2 + return "Git-ftp $gitftpVersion" +} + +function Get-GoogleCloudSDKVersion { + return "$(gcloud --version | Select-Object -First 1)" +} + +function Get-HavegedVersion { + $havegedVersion = dpkg-query --showformat='${Version}' --show haveged | Take-Part -Part 0 -Delimiter "-" + return "Haveged $havegedVersion" +} + +function Get-HerokuVersion { + $herokuVersion = heroku version | Take-Part -Part 0 | Take-Part -Part 1 -Delimiter "/" + return "Heroku $herokuVersion" +} + +function Get-HHVMVersion { + $hhvmVersion = hhvm --version | Select-Object -First 1 | Take-Part -Part 2 + return "HHVM (HipHop VM) $hhvmVersion" +} + +function Get-SVNVersion { + $svnVersion = svn --version | Select-Object -First 1 | Take-Part -Part 2 + return "SVN $svnVersion" +} + +function Get-KustomizeVersion { + $kustomizeVersion = kustomize version --short | Take-Part -Part 0 | Take-Part -Part 1 -Delimiter "v" + return "Kustomize $kustomizeVersion" +} + +function Get-KindVersion { + $kindVersion = kind version | Take-Part -Part 1 | Take-Part -Part 0 -Delimiter "v" + return "Kind $kindVersion" +} + +function Get-KubectlVersion { + $kubectlVersion = kubectl version --client --short | Take-Part -Part 2 | Take-Part -Part 0 -Delimiter "v" + return "Kubectl $kubectlVersion" +} + +function Get-MinikubeVersion { + $minikubeVersion = minikube version --short | Take-Part -Part 2 | Take-Part -Part 0 -Delimiter "v" + return "Minikube $minikubeVersion" +} + +function Get-HGVersion { + $hgVersion = hg --version | Select-Object -First 1 | Take-Part -Part -1 | Take-Part -Part 0 -Delimiter ")" + return "Mercurial $hgVersion" +} + +function Get-M4Version { + $m4Version = m4 --version | Select-Object -First 1 | Take-Part -Part -1 + return "m4 $m4Version" +} + +function Get-LeiningenVersion { + return "$(lein -v | Take-Part -Part 0,1)" +} + +function Get-NewmanVersion { + return "Newman $(newman --version)" +} + +function Get-NvmVersion { + $nvmVersion = bash -c "source $HOME/.nvm/nvm.sh && nvm --version" + return "nvm $nvmVersion" +} + +function Get-PackerVersion { + return "Packer $(packer --version)" +} + +function Get-PhantomJSVersion { + return "PhantomJS $(phantomjs --version)" +} + +function Get-SwigVersion { + $swigVersion = swig -version | Select-String "SWIG Version" | Take-Part -Part 2 + return "Swig $swigVersion" +} + +function Get-TerraformVersion { + return (terraform version | Select-String "^Terraform").Line.Replace('v','') +} + +function Get-UnZipVersion { + $unzipVersion = unzip -v | Select-Object -First 1 | Take-Part -Part 1 + return "unzip $unzipVersion" +} + +function Get-WgetVersion { + $wgetVersion = wget --version | Select-Object -First 1 | Take-Part -Part 2 + return "wget $wgetVersion" +} + +function Get-ZipVersion { + $zipVersion = zip -v | Select-String "This is Zip" | Take-Part -Part 3 + return "zip $zipVersion" +} + +function Get-ZstdVersion { + $zstdVersion = (zstd --version).Split() -match "v\d+" | ForEach-Object {$_.Replace("v","").Replace(",","")} + return "zstd $zstdVersion" +} + +function Get-JqVersion { + $jqVersion = jq --version | Take-Part -Part 1 -Delimiter "-" + return "jq $jqVersion" +} + +function Get-AzureCliVersion { + $azcliVersion = az -v | Select-String "azure-cli" | Take-Part -Part -1 + return "Azure CLI (azure-cli) $azcliVersion" +} + +function Get-AzureDevopsVersion { + $azdevopsVersion = az -v | Select-String "azure-devops" | Take-Part -Part -1 + return "Azure CLI (azure-devops) $azdevopsVersion" +} + +function Get-AlibabaCloudCliVersion { + return "Alibaba Cloud CLI $(aliyun version)" +} + +function Get-AWSCliVersion { + $awsVersion = aws --version 2>&1 | Take-Part -Part 0 | Take-Part -Part 1 -Delimiter "/" + return "AWS CLI $awsVersion" +} + +function Get-AWSCliSessionManagerPluginVersion { + return "AWS CLI Session manager plugin $(session-manager-plugin --version 2>&1)" +} + +function Get-AWSSAMVersion { + return "AWS SAM CLI $(sam --version | Take-Part -Part -1)" +} + +function Get-HubCliVersion { + $hubVersion = hub --version | Select-String "hub version" | Take-Part -Part 2 + return "Hub CLI $hubVersion" +} + +function Get-GitHubCliVersion { + $ghVersion = gh --version | Select-String "gh version" | Take-Part -Part 2 + return "GitHub CLI $ghVersion" +} + +function Get-NetlifyCliVersion { + $netlifyVersion = netlify --version | Take-Part -Part 0 | Take-Part -Part 1 -Delimiter "/" + return "Netlify CLI $netlifyVersion" +} + +function Get-OCCliVersion { + $ocVersion = oc version | Take-Part -Part 2 | Take-Part -Part 0 -Delimiter "-" + return "oc CLI $ocVersion" +} + +function Get-ORASCliVersion { + $orasVersion = oras version | Select-String "^Version:" | Take-Part -Part 1 + return "ORAS CLI $orasVersion" +} + +function Get-VerselCliversion { + return "$(vercel --version 2>&1 | Select-Object -First 1)" +} diff --git a/images/linux/ubuntu1604.json b/images/linux/ubuntu1604.json index 9d8a11ba7..7ef3122a6 100644 --- a/images/linux/ubuntu1604.json +++ b/images/linux/ubuntu1604.json @@ -88,6 +88,11 @@ "source": "{{template_dir}}/scripts/installers", "destination": "{{user `installer_script_folder`}}" }, + { + "type": "file", + "source": "{{ template_dir }}/scripts/SoftwareReport", + "destination": "{{user `image_folder`}}" + }, { "type": "file", "source": "{{template_dir}}/toolsets/toolcache-1604.json", @@ -287,9 +292,19 @@ ], "execute_command": "sudo sh -c '{{ .Vars }} {{ .Path }}'" }, + { + "type": "powershell", + "inline": [ + "pwsh -File '{{user `image_folder`}}/SoftwareReport/SoftwareReport.Generator.ps1' -OutputDirectory '{{user `image_folder`}}'" + ], + "environment_vars":[ + "INSTALLER_SCRIPT_FOLDER={{user `installer_script_folder`}}", + "ANNOUNCEMENTS={{user `announcements`}}" + ] + }, { "type": "file", - "source": "{{user `metadata_file`}}", + "source": "{{user `image_folder`}}/Ubuntu-Readme.md", "destination": "{{template_dir}}/Ubuntu1604-README.md", "direction": "download" }, diff --git a/images/linux/ubuntu1804.json b/images/linux/ubuntu1804.json index aacfe4eea..5f280636d 100644 --- a/images/linux/ubuntu1804.json +++ b/images/linux/ubuntu1804.json @@ -91,6 +91,11 @@ "source": "{{template_dir}}/scripts/installers", "destination": "{{user `installer_script_folder`}}" }, + { + "type": "file", + "source": "{{ template_dir }}/scripts/SoftwareReport", + "destination": "{{user `image_folder`}}" + }, { "type": "file", "source": "{{template_dir}}/toolsets/toolcache-1804.json", @@ -291,9 +296,19 @@ ], "execute_command": "sudo sh -c '{{ .Vars }} {{ .Path }}'" }, + { + "type": "powershell", + "inline": [ + "pwsh -File '{{user `image_folder`}}/SoftwareReport/SoftwareReport.Generator.ps1' -OutputDirectory '{{user `image_folder`}}'" + ], + "environment_vars":[ + "INSTALLER_SCRIPT_FOLDER={{user `installer_script_folder`}}", + "ANNOUNCEMENTS={{user `announcements`}}" + ] + }, { "type": "file", - "source": "{{user `metadata_file`}}", + "source": "{{user `image_folder`}}/Ubuntu-Readme.md", "destination": "{{template_dir}}/Ubuntu1804-README.md", "direction": "download" }, diff --git a/images/linux/ubuntu2004.json b/images/linux/ubuntu2004.json index 17e9143d2..604b863a2 100644 --- a/images/linux/ubuntu2004.json +++ b/images/linux/ubuntu2004.json @@ -93,6 +93,11 @@ "source": "{{template_dir}}/scripts/installers", "destination": "{{user `installer_script_folder`}}" }, + { + "type": "file", + "source": "{{ template_dir }}/scripts/SoftwareReport", + "destination": "{{user `image_folder`}}" + }, { "type": "file", "source": "{{template_dir}}/toolsets/toolcache-2004.json", @@ -293,9 +298,19 @@ ], "execute_command": "sudo sh -c '{{ .Vars }} {{ .Path }}'" }, + { + "type": "powershell", + "inline": [ + "pwsh -File '{{user `image_folder`}}/SoftwareReport/SoftwareReport.Generator.ps1' -OutputDirectory '{{user `image_folder`}}'" + ], + "environment_vars":[ + "INSTALLER_SCRIPT_FOLDER={{user `installer_script_folder`}}", + "ANNOUNCEMENTS={{user `announcements`}}" + ] + }, { "type": "file", - "source": "{{user `metadata_file`}}", + "source": "{{user `image_folder`}}/Ubuntu-Readme.md", "destination": "{{template_dir}}/Ubuntu2004-README.md", "direction": "download" }, From 370986d0f0b09213b34b42c7e51f433e734eea55 Mon Sep 17 00:00:00 2001 From: Aleksandr Chebotov Date: Mon, 14 Sep 2020 10:09:05 +0300 Subject: [PATCH 02/15] rename Take-Part -> Take-OutputPart --- .../SoftwareReport.Browsers.psm1 | 6 +- .../SoftwareReport.CachedTools.psm1 | 5 +- .../SoftwareReport/SoftwareReport.Common.psm1 | 38 ++++----- .../SoftwareReport.Databases.psm1 | 22 ++++- .../SoftwareReport.Generator.ps1 | 10 +-- .../SoftwareReport.Helpers.psm1 | 2 +- .../SoftwareReport/SoftwareReport.Tools.psm1 | 84 +++++++++---------- 7 files changed, 87 insertions(+), 80 deletions(-) diff --git a/images/linux/scripts/SoftwareReport/SoftwareReport.Browsers.psm1 b/images/linux/scripts/SoftwareReport/SoftwareReport.Browsers.psm1 index 96d05ee08..d65eb5536 100644 --- a/images/linux/scripts/SoftwareReport/SoftwareReport.Browsers.psm1 +++ b/images/linux/scripts/SoftwareReport/SoftwareReport.Browsers.psm1 @@ -1,10 +1,10 @@ function Get-ChromeVersion { - $googleChromeVersion = google-chrome --version | Take-Part -Part 2 + $googleChromeVersion = google-chrome --version | Take-OutputPart -Part 2 return "Google Chrome $googleChromeVersion" } function Get-ChromeDriverVersion { - $chromeDriverVersion = chromedriver --version | Take-Part -Part 1 + $chromeDriverVersion = chromedriver --version | Take-OutputPart -Part 1 return "ChromeDriver $chromeDriverVersion" } @@ -14,6 +14,6 @@ function Get-FirefoxVersion { } function Get-GeckodriverVersion { - $geckodriverVersion = geckodriver --version | Select-Object -First 1 | Take-Part -Part 1 + $geckodriverVersion = geckodriver --version | Select-Object -First 1 | Take-OutputPart -Part 1 return "Geckodriver $geckodriverVersion" } \ No newline at end of file diff --git a/images/linux/scripts/SoftwareReport/SoftwareReport.CachedTools.psm1 b/images/linux/scripts/SoftwareReport/SoftwareReport.CachedTools.psm1 index 536b31255..24283ba64 100644 --- a/images/linux/scripts/SoftwareReport/SoftwareReport.CachedTools.psm1 +++ b/images/linux/scripts/SoftwareReport/SoftwareReport.CachedTools.psm1 @@ -36,7 +36,7 @@ function Get-ToolcacheBoostVersions { return Get-ChildItem $toolcachePath -Name | Sort-Object { [Version]$_ } } -function Build-CachedToolsSection { +function Build-CachedToolsSection { $output = "" $output += New-MDHeader "Ruby" -Level 4 @@ -44,7 +44,7 @@ function Build-CachedToolsSection { $output += New-MDHeader "Python" -Level 4 $output += New-MDList -Lines (Get-ToolcachePythonVersions) -Style Unordered - + $output += New-MDHeader "PyPy" -Level 4 $output += New-MDList -Lines (Get-ToolcachePyPyVersions) -Style Unordered @@ -59,7 +59,6 @@ function Build-CachedToolsSection { $output += New-MDHeader "Boost" -Level 4 $output += New-MDList -Lines $boostVersions -Style Unordered } - return $output } \ No newline at end of file diff --git a/images/linux/scripts/SoftwareReport/SoftwareReport.Common.psm1 b/images/linux/scripts/SoftwareReport/SoftwareReport.Common.psm1 index 1d96f5550..5fafca0f1 100644 --- a/images/linux/scripts/SoftwareReport/SoftwareReport.Common.psm1 +++ b/images/linux/scripts/SoftwareReport/SoftwareReport.Common.psm1 @@ -40,7 +40,7 @@ function Get-ErlangVersion { } function Get-MonoVersion { - $monoVersion = $(mono --version) | Out-String | Take-Part -Part 4 + $monoVersion = $(mono --version) | Out-String | Take-OutputPart -Part 4 return "Mono $monoVersion" } @@ -51,13 +51,13 @@ function Get-NodeVersion { function Get-PythonVersion { $result = Get-CommandResult "python --version" - $version = $result.Output | Take-Part -Part 1 + $version = $result.Output | Take-OutputPart -Part 1 return "Python $version" } function Get-Python3Version { $result = Get-CommandResult "python3 --version" - $version = $result.Output | Take-Part -Part 1 + $version = $result.Output | Take-OutputPart -Part 1 return "Python3 $version" } @@ -66,17 +66,17 @@ function Get-PowershellVersion { } function Get-RubyVersion { - $rubyVersion = $(ruby --version) | Out-String | Take-Part -Part 1 + $rubyVersion = $(ruby --version) | Out-String | Take-OutputPart -Part 1 return "Ruby $rubyVersion" } function Get-SwiftVersion { - $swiftVersion = $(swift --version) | Out-String | Take-Part -Part 2 + $swiftVersion = $(swift --version) | Out-String | Take-OutputPart -Part 2 return "Swift $swiftVersion" } function Get-JuliaVersion { - $juliaVersion = $(julia --version) | Out-String | Take-Part -Part 2 + $juliaVersion = $(julia --version) | Out-String | Take-OutputPart -Part 2 return "Julia $juliaVersion" } @@ -195,7 +195,7 @@ function Build-PHPTable { [PSCustomObject] @{ "Tool" = $_.Tool "Version" = $_.Version - } + } } } @@ -218,52 +218,52 @@ function Get-StackVersion { } function Get-RustVersion { - $rustVersion = $(rustc --version) | Take-Part -Part 1 + $rustVersion = $(rustc --version) | Take-OutputPart -Part 1 return "Rust $rustVersion" } function Get-BindgenVersion { - $bindgenVersion = $(bindgen --version) | Take-Part -Part 1 + $bindgenVersion = $(bindgen --version) | Take-OutputPart -Part 1 return "Bindgen $bindgenVersion" } function Get-CargoVersion { - $cargoVersion = $(cargo --version) | Take-Part -Part 1 + $cargoVersion = $(cargo --version) | Take-OutputPart -Part 1 return "Cargo $cargoVersion" } function Get-CargoAuditVersion { - $cargoAuditVersion = $(cargo audit --version) | Take-Part -Part 1 + $cargoAuditVersion = $(cargo audit --version) | Take-OutputPart -Part 1 return "Cargo audit $cargoAuditVersion" } function Get-CargoOutdatedVersion { - $cargoOutdatedVersion = $(cargo outdated --version) | Take-Part -Part 1 -Delimiter "v" + $cargoOutdatedVersion = $(cargo outdated --version) | Take-OutputPart -Part 1 -Delimiter "v" return "Cargo outdated $cargoOutdatedVersion" } function Get-CargoClippyVersion { - $cargoClippyVersion = $(cargo-clippy --version) | Take-Part -Part 1 + $cargoClippyVersion = $(cargo-clippy --version) | Take-OutputPart -Part 1 return "Cargo clippy $cargoClippyVersion" } function Get-CbindgenVersion { - $cbindgenVersion = $(cbindgen --version) | Take-Part -Part 1 + $cbindgenVersion = $(cbindgen --version) | Take-OutputPart -Part 1 return "Cbindgen $cbindgenVersion" } function Get-RustupVersion { - $rustupVersion = $(rustup --version) | Take-Part -Part 1 + $rustupVersion = $(rustup --version) | Take-OutputPart -Part 1 return "Rustup $rustupVersion" } function Get-RustdocVersion { - $rustdocVersion = $(rustdoc --version) | Take-Part -Part 1 + $rustdocVersion = $(rustdoc --version) | Take-OutputPart -Part 1 return "Rustdoc $rustdocVersion" } function Get-RustfmtVersion { - $rustfmtVersion = $(rustfmt --version) | Take-Part -Part 1 | Take-Part -Part 0 -Delimiter "-" + $rustfmtVersion = $(rustfmt --version) | Take-OutputPart -Part 1 | Take-OutputPart -Part 0 -Delimiter "-" return "Rustfmt $rustfmtVersion" } @@ -271,13 +271,13 @@ function Get-AzModuleVersions { $azModuleVersions = Get-ChildItem /usr/share | Where-Object { $_ -match "az_\d+" } | Foreach-Object { $_.Name.Split("_")[1] } - + $azModuleVersions = $azModuleVersions -join " " return $azModuleVersions } function Get-DotNetCoreSdkVersions { - $unsortedDotNetCoreSdkVersion = dotnet --list-sdks list | ForEach-Object { $_ | Take-Part -Part 0 } + $unsortedDotNetCoreSdkVersion = dotnet --list-sdks list | ForEach-Object { $_ | Take-OutputPart -Part 0 } $dotNetCoreSdkVersion = $unsortedDotNetCoreSdkVersion -join " " return $dotNetCoreSdkVersion } diff --git a/images/linux/scripts/SoftwareReport/SoftwareReport.Databases.psm1 b/images/linux/scripts/SoftwareReport/SoftwareReport.Databases.psm1 index 6c274184e..e6c14381e 100644 --- a/images/linux/scripts/SoftwareReport/SoftwareReport.Databases.psm1 +++ b/images/linux/scripts/SoftwareReport/SoftwareReport.Databases.psm1 @@ -1,19 +1,35 @@ function Get-PostgreSqlVersion { - $postgreSQLVersion = psql --version | Take-Part -Part 2 + $postgreSQLVersion = psql --version | Take-OutputPart -Part 2 return "Postgre SQL $postgreSQLVersion" } function Get-MongoDbVersion { - $mongoDBVersion = mongod --version | Select-Object -First 1 | Take-Part -Part 2 -Delimiter "v" + $mongoDBVersion = mongod --version | Select-Object -First 1 | Take-OutputPart -Part 2 -Delimiter "v" return "MongoDB $mongoDBVersion" } function Get-SqliteVersion { - $sqliteVersion = sqlite3 --version | Take-Part -Part 0 + $sqliteVersion = sqlite3 --version | Take-OutputPart -Part 0 return "sqlite3 $sqliteVersion" } function Get-MySqlVersion { $mySqlVersion = (mysql --version).Split("/usr/bin/")[1] return "MySQL ($mySqlVersion)" +} + +function Build-MySQLSection { + $output = "" + + $output += New-MDHeader "MySQL" -Level 4 + $output += New-MDList -Style Unordered -Lines @( + (Get-MySqlVersion), + "MySQL Server (user:root password:root)", + "MS SQL Server Client Tools" + ) + $output += New-MDCode -Lines @( + "MySQL service is disabled by default. Use the following command as a part of your job to start the service: 'sudo systemctl start mysql.service'" + ) + + return $output } \ No newline at end of file diff --git a/images/linux/scripts/SoftwareReport/SoftwareReport.Generator.ps1 b/images/linux/scripts/SoftwareReport/SoftwareReport.Generator.ps1 index e63f3719a..6a252f407 100644 --- a/images/linux/scripts/SoftwareReport/SoftwareReport.Generator.ps1 +++ b/images/linux/scripts/SoftwareReport/SoftwareReport.Generator.ps1 @@ -195,15 +195,7 @@ $markdown += New-MDList -Style Unordered -Lines @( (Get-SqliteVersion) ) -$markdown += New-MDHeader "MySQL" -Level 4 -$markdown += New-MDList -Style Unordered -Lines @( - (Get-MySqlVersion), - "MySQL Server (user:root password:root)", - "MS SQL Server Client Tools" -) -$markdown += New-MDCode -Lines @( - "MySQL service is disabled by default. Use the following command as a part of your job to start the service: 'sudo systemctl start mysql.service'" -) +$markdown += Build-MySQLSection $markdown += New-MDHeader "Cached Tools" -Level 3 $markdown += Build-CachedToolsSection diff --git a/images/linux/scripts/SoftwareReport/SoftwareReport.Helpers.psm1 b/images/linux/scripts/SoftwareReport/SoftwareReport.Helpers.psm1 index 6f2701c92..4bad753bd 100644 --- a/images/linux/scripts/SoftwareReport/SoftwareReport.Helpers.psm1 +++ b/images/linux/scripts/SoftwareReport/SoftwareReport.Helpers.psm1 @@ -13,7 +13,7 @@ function Get-CommandResult { } } -function Take-Part { +function Take-OutputPart { param ( [Parameter(ValueFromPipeline)] [string] $toolOutput, diff --git a/images/linux/scripts/SoftwareReport/SoftwareReport.Tools.psm1 b/images/linux/scripts/SoftwareReport/SoftwareReport.Tools.psm1 index f66f2e4fc..05032cfb6 100644 --- a/images/linux/scripts/SoftwareReport/SoftwareReport.Tools.psm1 +++ b/images/linux/scripts/SoftwareReport/SoftwareReport.Tools.psm1 @@ -1,85 +1,85 @@ function Get-7zipVersion { - $7zVersion = 7z i | Select-String "7-Zip" | Take-Part -Part 2 + $7zVersion = 7z i | Select-String "7-Zip" | Take-OutputPart -Part 2 return "7-Zip $7zVersion" } function Get-AnsibleVersion { - $ansibleVersion = ansible --version | Select-Object -First 1 | Take-Part -Part 1 + $ansibleVersion = ansible --version | Select-Object -First 1 | Take-OutputPart -Part 1 return "Ansible $ansibleVersion" } function Get-AzCopy7Version { - $azcopy7Version = azcopy --version | Take-Part -Part 1 | Take-Part -Part 0 -Delimiter "-" + $azcopy7Version = azcopy --version | Take-OutputPart -Part 1 | Take-OutputPart -Part 0 -Delimiter "-" return "AzCopy7 (available by azcopy alias) $azcopy7Version" } function Get-AzCopy10Version { - $azcopy10Version = azcopy10 --version | Take-Part -Part 2 + $azcopy10Version = azcopy10 --version | Take-OutputPart -Part 2 return "AzCopy10 (available by azcopy10 alias) $azcopy10Version" } function Get-BazelVersion { - $bazelVersion = bazel --version | Select-String "bazel" | Take-Part -Part 1 + $bazelVersion = bazel --version | Select-String "bazel" | Take-OutputPart -Part 1 return "Bazel $bazelVersion" } function Get-BazeliskVersion { - $bazeliskVersion = bazelisk version 2>&1 | Select-String "Bazelisk version:" | Take-Part -Part 2 | Take-Part -Part 0 -Delimiter "v" + $bazeliskVersion = bazelisk version 2>&1 | Select-String "Bazelisk version:" | Take-OutputPart -Part 2 | Take-OutputPart -Part 0 -Delimiter "v" return "Bazelisk $bazeliskVersion" } function Get-PodManVersion { - $podmanVersion = podman --version | Take-Part -Part 2 + $podmanVersion = podman --version | Take-OutputPart -Part 2 return "Podman $podmanVersion" } function Get-BuildahVersion { - $buildahVersion = buildah --version | Take-Part -Part 2 + $buildahVersion = buildah --version | Take-OutputPart -Part 2 return "Buildah $buildahVersion" } function Get-SkopeoVersion { - $skopeoVersion = skopeo --version | Take-Part -Part 2 + $skopeoVersion = skopeo --version | Take-OutputPart -Part 2 return "Skopeo $skopeoVersion" } function Get-CMakeVersion { - $cmakeVersion = cmake --version | Select-Object -First 1 | Take-Part -Part 2 + $cmakeVersion = cmake --version | Select-Object -First 1 | Take-OutputPart -Part 2 return "CMake $cmakeVersion" } function Get-CurlVersion { - $curlVersion = curl --version | Select-Object -First 1 | Take-Part -Part 0,1 + $curlVersion = curl --version | Select-Object -First 1 | Take-OutputPart -Part 0,1 return $curlVersion } function Get-DockerComposeVersion { - $composeVersion = docker-compose -v | Take-Part -Part 2 | Take-Part -Part 0 -Delimiter "," + $composeVersion = docker-compose -v | Take-OutputPart -Part 2 | Take-OutputPart -Part 0 -Delimiter "," return "Docker Compose $composeVersion" } function Get-DockerMobyVersion { - $dockerVersion = docker -v | Take-Part -Part 2 | Take-Part -Part 0 -Delimiter "+" + $dockerVersion = docker -v | Take-OutputPart -Part 2 | Take-OutputPart -Part 0 -Delimiter "+" return "Docker-Moby $dockerVersion" } function Get-DockerBuildxVersion { - $buildxVersion = docker buildx version | Take-Part -Part 1 | Take-Part -Part 0 -Delimiter "+" + $buildxVersion = docker buildx version | Take-OutputPart -Part 1 | Take-OutputPart -Part 0 -Delimiter "+" return "Docker-Buildx $buildxVersion" } function Get-GitVersion { - $gitVersion = git --version 2>&1 | Take-Part -Part 2 + $gitVersion = git --version 2>&1 | Take-OutputPart -Part 2 return "Git $gitVersion" } function Get-GitLFSVersion { - $gitlfsversion = git-lfs --version 2>&1 | Take-Part -Part 0 | Take-Part -Part 1 -Delimiter "/" + $gitlfsversion = git-lfs --version 2>&1 | Take-OutputPart -Part 0 | Take-OutputPart -Part 1 -Delimiter "/" return "Git LFS $gitlfsversion" } function Get-GitFTPVersion { - $gitftpVersion = git-ftp --version | Take-Part -Part 2 + $gitftpVersion = git-ftp --version | Take-OutputPart -Part 2 return "Git-ftp $gitftpVersion" } @@ -88,57 +88,57 @@ function Get-GoogleCloudSDKVersion { } function Get-HavegedVersion { - $havegedVersion = dpkg-query --showformat='${Version}' --show haveged | Take-Part -Part 0 -Delimiter "-" + $havegedVersion = dpkg-query --showformat='${Version}' --show haveged | Take-OutputPart -Part 0 -Delimiter "-" return "Haveged $havegedVersion" } function Get-HerokuVersion { - $herokuVersion = heroku version | Take-Part -Part 0 | Take-Part -Part 1 -Delimiter "/" + $herokuVersion = heroku version | Take-OutputPart -Part 0 | Take-OutputPart -Part 1 -Delimiter "/" return "Heroku $herokuVersion" } function Get-HHVMVersion { - $hhvmVersion = hhvm --version | Select-Object -First 1 | Take-Part -Part 2 + $hhvmVersion = hhvm --version | Select-Object -First 1 | Take-OutputPart -Part 2 return "HHVM (HipHop VM) $hhvmVersion" } function Get-SVNVersion { - $svnVersion = svn --version | Select-Object -First 1 | Take-Part -Part 2 + $svnVersion = svn --version | Select-Object -First 1 | Take-OutputPart -Part 2 return "SVN $svnVersion" } function Get-KustomizeVersion { - $kustomizeVersion = kustomize version --short | Take-Part -Part 0 | Take-Part -Part 1 -Delimiter "v" + $kustomizeVersion = kustomize version --short | Take-OutputPart -Part 0 | Take-OutputPart -Part 1 -Delimiter "v" return "Kustomize $kustomizeVersion" } function Get-KindVersion { - $kindVersion = kind version | Take-Part -Part 1 | Take-Part -Part 0 -Delimiter "v" + $kindVersion = kind version | Take-OutputPart -Part 1 | Take-OutputPart -Part 0 -Delimiter "v" return "Kind $kindVersion" } function Get-KubectlVersion { - $kubectlVersion = kubectl version --client --short | Take-Part -Part 2 | Take-Part -Part 0 -Delimiter "v" + $kubectlVersion = kubectl version --client --short | Take-OutputPart -Part 2 | Take-OutputPart -Part 0 -Delimiter "v" return "Kubectl $kubectlVersion" } function Get-MinikubeVersion { - $minikubeVersion = minikube version --short | Take-Part -Part 2 | Take-Part -Part 0 -Delimiter "v" + $minikubeVersion = minikube version --short | Take-OutputPart -Part 2 | Take-OutputPart -Part 0 -Delimiter "v" return "Minikube $minikubeVersion" } function Get-HGVersion { - $hgVersion = hg --version | Select-Object -First 1 | Take-Part -Part -1 | Take-Part -Part 0 -Delimiter ")" + $hgVersion = hg --version | Select-Object -First 1 | Take-OutputPart -Part -1 | Take-OutputPart -Part 0 -Delimiter ")" return "Mercurial $hgVersion" } function Get-M4Version { - $m4Version = m4 --version | Select-Object -First 1 | Take-Part -Part -1 + $m4Version = m4 --version | Select-Object -First 1 | Take-OutputPart -Part -1 return "m4 $m4Version" } function Get-LeiningenVersion { - return "$(lein -v | Take-Part -Part 0,1)" + return "$(lein -v | Take-OutputPart -Part 0,1)" } function Get-NewmanVersion { @@ -159,7 +159,7 @@ function Get-PhantomJSVersion { } function Get-SwigVersion { - $swigVersion = swig -version | Select-String "SWIG Version" | Take-Part -Part 2 + $swigVersion = swig -version | Select-String "SWIG Version" | Take-OutputPart -Part 2 return "Swig $swigVersion" } @@ -168,17 +168,17 @@ function Get-TerraformVersion { } function Get-UnZipVersion { - $unzipVersion = unzip -v | Select-Object -First 1 | Take-Part -Part 1 + $unzipVersion = unzip -v | Select-Object -First 1 | Take-OutputPart -Part 1 return "unzip $unzipVersion" } function Get-WgetVersion { - $wgetVersion = wget --version | Select-Object -First 1 | Take-Part -Part 2 + $wgetVersion = wget --version | Select-Object -First 1 | Take-OutputPart -Part 2 return "wget $wgetVersion" } function Get-ZipVersion { - $zipVersion = zip -v | Select-String "This is Zip" | Take-Part -Part 3 + $zipVersion = zip -v | Select-String "This is Zip" | Take-OutputPart -Part 3 return "zip $zipVersion" } @@ -188,17 +188,17 @@ function Get-ZstdVersion { } function Get-JqVersion { - $jqVersion = jq --version | Take-Part -Part 1 -Delimiter "-" + $jqVersion = jq --version | Take-OutputPart -Part 1 -Delimiter "-" return "jq $jqVersion" } function Get-AzureCliVersion { - $azcliVersion = az -v | Select-String "azure-cli" | Take-Part -Part -1 + $azcliVersion = az -v | Select-String "azure-cli" | Take-OutputPart -Part -1 return "Azure CLI (azure-cli) $azcliVersion" } function Get-AzureDevopsVersion { - $azdevopsVersion = az -v | Select-String "azure-devops" | Take-Part -Part -1 + $azdevopsVersion = az -v | Select-String "azure-devops" | Take-OutputPart -Part -1 return "Azure CLI (azure-devops) $azdevopsVersion" } @@ -207,7 +207,7 @@ function Get-AlibabaCloudCliVersion { } function Get-AWSCliVersion { - $awsVersion = aws --version 2>&1 | Take-Part -Part 0 | Take-Part -Part 1 -Delimiter "/" + $awsVersion = aws --version 2>&1 | Take-OutputPart -Part 0 | Take-OutputPart -Part 1 -Delimiter "/" return "AWS CLI $awsVersion" } @@ -216,31 +216,31 @@ function Get-AWSCliSessionManagerPluginVersion { } function Get-AWSSAMVersion { - return "AWS SAM CLI $(sam --version | Take-Part -Part -1)" + return "AWS SAM CLI $(sam --version | Take-OutputPart -Part -1)" } function Get-HubCliVersion { - $hubVersion = hub --version | Select-String "hub version" | Take-Part -Part 2 + $hubVersion = hub --version | Select-String "hub version" | Take-OutputPart -Part 2 return "Hub CLI $hubVersion" } function Get-GitHubCliVersion { - $ghVersion = gh --version | Select-String "gh version" | Take-Part -Part 2 + $ghVersion = gh --version | Select-String "gh version" | Take-OutputPart -Part 2 return "GitHub CLI $ghVersion" } function Get-NetlifyCliVersion { - $netlifyVersion = netlify --version | Take-Part -Part 0 | Take-Part -Part 1 -Delimiter "/" + $netlifyVersion = netlify --version | Take-OutputPart -Part 0 | Take-OutputPart -Part 1 -Delimiter "/" return "Netlify CLI $netlifyVersion" } function Get-OCCliVersion { - $ocVersion = oc version | Take-Part -Part 2 | Take-Part -Part 0 -Delimiter "-" + $ocVersion = oc version | Take-OutputPart -Part 2 | Take-OutputPart -Part 0 -Delimiter "-" return "oc CLI $ocVersion" } function Get-ORASCliVersion { - $orasVersion = oras version | Select-String "^Version:" | Take-Part -Part 1 + $orasVersion = oras version | Select-String "^Version:" | Take-OutputPart -Part 1 return "ORAS CLI $orasVersion" } From 3e90bb832a481b3ef1539a1d2b8238f9af78acce Mon Sep 17 00:00:00 2001 From: Aleksandr Chebotov Date: Mon, 14 Sep 2020 11:31:41 +0300 Subject: [PATCH 03/15] fix environment variable --- .../scripts/SoftwareReport/SoftwareReport.Databases.psm1 | 4 ++-- .../scripts/SoftwareReport/SoftwareReport.Generator.ps1 | 4 ++-- images/linux/ubuntu1604.json | 5 +++-- images/linux/ubuntu1804.json | 5 +++-- images/linux/ubuntu2004.json | 5 +++-- 5 files changed, 13 insertions(+), 10 deletions(-) diff --git a/images/linux/scripts/SoftwareReport/SoftwareReport.Databases.psm1 b/images/linux/scripts/SoftwareReport/SoftwareReport.Databases.psm1 index e6c14381e..7c1605ccc 100644 --- a/images/linux/scripts/SoftwareReport/SoftwareReport.Databases.psm1 +++ b/images/linux/scripts/SoftwareReport/SoftwareReport.Databases.psm1 @@ -13,7 +13,7 @@ function Get-SqliteVersion { return "sqlite3 $sqliteVersion" } -function Get-MySqlVersion { +function Get-MySQLVersion { $mySqlVersion = (mysql --version).Split("/usr/bin/")[1] return "MySQL ($mySqlVersion)" } @@ -23,7 +23,7 @@ function Build-MySQLSection { $output += New-MDHeader "MySQL" -Level 4 $output += New-MDList -Style Unordered -Lines @( - (Get-MySqlVersion), + (Get-MySQLVersion ), "MySQL Server (user:root password:root)", "MS SQL Server Client Tools" ) diff --git a/images/linux/scripts/SoftwareReport/SoftwareReport.Generator.ps1 b/images/linux/scripts/SoftwareReport/SoftwareReport.Generator.ps1 index 6a252f407..ac23a6deb 100644 --- a/images/linux/scripts/SoftwareReport/SoftwareReport.Generator.ps1 +++ b/images/linux/scripts/SoftwareReport/SoftwareReport.Generator.ps1 @@ -4,7 +4,7 @@ param ( ) # Install MarkdownPS module for software report generation -Install-Module MarkdownPS -Force -Scope CurrentUser +Install-Module MarkdownPS -Force Import-Module MarkdownPS Import-Module (Join-Path $PSScriptRoot "SoftwareReport.CachedTools.psm1") -DisableNameChecking Import-Module (Join-Path $PSScriptRoot "SoftwareReport.Common.psm1") -DisableNameChecking @@ -28,7 +28,7 @@ $OSName = Get-OSName $markdown += New-MDHeader "$OSName" -Level 1 $markdown += New-MDList -Style Unordered -Lines @( - "Image Version: $env:ImageVersion" + "Image Version: $env:IMAGE_VERSION" ) $markdown += New-MDHeader "Installed Software" -Level 2 diff --git a/images/linux/ubuntu1604.json b/images/linux/ubuntu1604.json index 7ef3122a6..7d180a0a4 100644 --- a/images/linux/ubuntu1604.json +++ b/images/linux/ubuntu1604.json @@ -293,11 +293,12 @@ "execute_command": "sudo sh -c '{{ .Vars }} {{ .Path }}'" }, { - "type": "powershell", + "type": "shell", "inline": [ - "pwsh -File '{{user `image_folder`}}/SoftwareReport/SoftwareReport.Generator.ps1' -OutputDirectory '{{user `image_folder`}}'" + "sudo pwsh -File {{user `image_folder`}}/SoftwareReport/SoftwareReport.Generator.ps1 -OutputDirectory {{user `image_folder`}}" ], "environment_vars":[ + "IMAGE_VERSION={{user `image_version`}}", "INSTALLER_SCRIPT_FOLDER={{user `installer_script_folder`}}", "ANNOUNCEMENTS={{user `announcements`}}" ] diff --git a/images/linux/ubuntu1804.json b/images/linux/ubuntu1804.json index 5f280636d..c5265b9fa 100644 --- a/images/linux/ubuntu1804.json +++ b/images/linux/ubuntu1804.json @@ -297,11 +297,12 @@ "execute_command": "sudo sh -c '{{ .Vars }} {{ .Path }}'" }, { - "type": "powershell", + "type": "shell", "inline": [ - "pwsh -File '{{user `image_folder`}}/SoftwareReport/SoftwareReport.Generator.ps1' -OutputDirectory '{{user `image_folder`}}'" + "sudo pwsh -File {{user `image_folder`}}/SoftwareReport/SoftwareReport.Generator.ps1 -OutputDirectory {{user `image_folder`}}" ], "environment_vars":[ + "IMAGE_VERSION={{user `image_version`}}", "INSTALLER_SCRIPT_FOLDER={{user `installer_script_folder`}}", "ANNOUNCEMENTS={{user `announcements`}}" ] diff --git a/images/linux/ubuntu2004.json b/images/linux/ubuntu2004.json index 604b863a2..eccace5ff 100644 --- a/images/linux/ubuntu2004.json +++ b/images/linux/ubuntu2004.json @@ -299,11 +299,12 @@ "execute_command": "sudo sh -c '{{ .Vars }} {{ .Path }}'" }, { - "type": "powershell", + "type": "shell", "inline": [ - "pwsh -File '{{user `image_folder`}}/SoftwareReport/SoftwareReport.Generator.ps1' -OutputDirectory '{{user `image_folder`}}'" + "sudo pwsh -File {{user `image_folder`}}/SoftwareReport/SoftwareReport.Generator.ps1 -OutputDirectory {{user `image_folder`}}" ], "environment_vars":[ + "IMAGE_VERSION={{user `image_version`}}", "INSTALLER_SCRIPT_FOLDER={{user `installer_script_folder`}}", "ANNOUNCEMENTS={{user `announcements`}}" ] From e7a8e6a597779e21fb24f5032fa2645285f9ec1a Mon Sep 17 00:00:00 2001 From: Aleksandr Chebotov Date: Mon, 14 Sep 2020 16:25:33 +0300 Subject: [PATCH 04/15] install powershell modules --- .../SoftwareReport.Databases.psm1 | 4 +-- .../installers/Install-PowerShellModules.ps1 | 31 +++++++++++++++++++ images/linux/toolsets/toolset-1604.json | 4 +++ images/linux/toolsets/toolset-1804.json | 4 +++ images/linux/toolsets/toolset-2004.json | 4 +++ images/linux/ubuntu1604.json | 12 ++++++- images/linux/ubuntu1804.json | 12 ++++++- images/linux/ubuntu2004.json | 12 ++++++- 8 files changed, 78 insertions(+), 5 deletions(-) create mode 100644 images/linux/scripts/installers/Install-PowerShellModules.ps1 diff --git a/images/linux/scripts/SoftwareReport/SoftwareReport.Databases.psm1 b/images/linux/scripts/SoftwareReport/SoftwareReport.Databases.psm1 index 7c1605ccc..47f04de24 100644 --- a/images/linux/scripts/SoftwareReport/SoftwareReport.Databases.psm1 +++ b/images/linux/scripts/SoftwareReport/SoftwareReport.Databases.psm1 @@ -14,8 +14,8 @@ function Get-SqliteVersion { } function Get-MySQLVersion { - $mySqlVersion = (mysql --version).Split("/usr/bin/")[1] - return "MySQL ($mySqlVersion)" + $mySQLVersion = mysqld --version | Take-OutputPart -Part 2 | Take-OutputPart -Part 0 -Delimiter "-" + return "MySQL ($mySQLVersion)" } function Build-MySQLSection { diff --git a/images/linux/scripts/installers/Install-PowerShellModules.ps1 b/images/linux/scripts/installers/Install-PowerShellModules.ps1 new file mode 100644 index 000000000..ed100e3c4 --- /dev/null +++ b/images/linux/scripts/installers/Install-PowerShellModules.ps1 @@ -0,0 +1,31 @@ +$ErrorActionPreference = "Stop" + +function Get-ToolsetContent +{ + $toolset = Join-Path $env:INSTALLER_SCRIPT_FOLDER "toolset.json" + Get-Content $toolset -Raw | ConvertFrom-Json +} + +# Specifies the installation policy +Set-PSRepository -InstallationPolicy Trusted -Name PSGallery + +# Install PowerShell modules +$modules = (Get-ToolsetContent).powershellModules + +foreach($module in $modules) +{ + $moduleName = $module.name + Write-Host "Installing ${moduleName} module" + + if ($module.versions) + { + foreach ($version in $module.versions) + { + Write-Host " - $version" + Install-Module -Name $moduleName -RequiredVersion $version -Scope AllUsers -SkipPublisherCheck -Force + } + continue + } + + Install-Module -Name $moduleName -Scope AllUsers -SkipPublisherCheck -Force +} diff --git a/images/linux/toolsets/toolset-1604.json b/images/linux/toolsets/toolset-1604.json index 1204f2a86..c8b2b1510 100644 --- a/images/linux/toolsets/toolset-1604.json +++ b/images/linux/toolsets/toolset-1604.json @@ -91,6 +91,10 @@ "platform-tools" ] }, + "powershellModules": [ + {"name": "MarkdownPS"}, + {"name": "Pester"} + ], "azureModules": [ { "name": "az", diff --git a/images/linux/toolsets/toolset-1804.json b/images/linux/toolsets/toolset-1804.json index 2c399c8fc..6311cc1a1 100644 --- a/images/linux/toolsets/toolset-1804.json +++ b/images/linux/toolsets/toolset-1804.json @@ -87,6 +87,10 @@ "platform-tools" ] }, + "powershellModules": [ + {"name": "MarkdownPS"}, + {"name": "Pester"} + ], "azureModules": [ { "name": "az", diff --git a/images/linux/toolsets/toolset-2004.json b/images/linux/toolsets/toolset-2004.json index 1162b713f..5ac230255 100644 --- a/images/linux/toolsets/toolset-2004.json +++ b/images/linux/toolsets/toolset-2004.json @@ -68,6 +68,10 @@ "platform-tools" ] }, + "powershellModules": [ + {"name": "MarkdownPS"}, + {"name": "Pester"} + ], "apt": { "common_packages": [ "dbus", diff --git a/images/linux/ubuntu1604.json b/images/linux/ubuntu1604.json index 7d180a0a4..27cc6b0bd 100644 --- a/images/linux/ubuntu1604.json +++ b/images/linux/ubuntu1604.json @@ -292,10 +292,20 @@ ], "execute_command": "sudo sh -c '{{ .Vars }} {{ .Path }}'" }, + { + "type": "shell", + "scripts":[ + "{{template_dir}}/scripts/installers/Install-PowerShellModules.ps1" + ], + "environment_vars": [ + "INSTALLER_SCRIPT_FOLDER={{user `installer_script_folder`}}" + ], + "execute_command": "sudo sh -c '{{ .Vars }} pwsh -f {{ .Path }}'" + }, { "type": "shell", "inline": [ - "sudo pwsh -File {{user `image_folder`}}/SoftwareReport/SoftwareReport.Generator.ps1 -OutputDirectory {{user `image_folder`}}" + "pwsh -File {{user `image_folder`}}/SoftwareReport/SoftwareReport.Generator.ps1 -OutputDirectory {{user `image_folder`}}" ], "environment_vars":[ "IMAGE_VERSION={{user `image_version`}}", diff --git a/images/linux/ubuntu1804.json b/images/linux/ubuntu1804.json index c5265b9fa..05f4a2691 100644 --- a/images/linux/ubuntu1804.json +++ b/images/linux/ubuntu1804.json @@ -296,10 +296,20 @@ ], "execute_command": "sudo sh -c '{{ .Vars }} {{ .Path }}'" }, + { + "type": "shell", + "scripts":[ + "{{template_dir}}/scripts/installers/Install-PowerShellModules.ps1" + ], + "environment_vars": [ + "INSTALLER_SCRIPT_FOLDER={{user `installer_script_folder`}}" + ], + "execute_command": "sudo sh -c '{{ .Vars }} pwsh -f {{ .Path }}'" + }, { "type": "shell", "inline": [ - "sudo pwsh -File {{user `image_folder`}}/SoftwareReport/SoftwareReport.Generator.ps1 -OutputDirectory {{user `image_folder`}}" + "pwsh -File {{user `image_folder`}}/SoftwareReport/SoftwareReport.Generator.ps1 -OutputDirectory {{user `image_folder`}}" ], "environment_vars":[ "IMAGE_VERSION={{user `image_version`}}", diff --git a/images/linux/ubuntu2004.json b/images/linux/ubuntu2004.json index eccace5ff..4a4ff5c5f 100644 --- a/images/linux/ubuntu2004.json +++ b/images/linux/ubuntu2004.json @@ -298,10 +298,20 @@ ], "execute_command": "sudo sh -c '{{ .Vars }} {{ .Path }}'" }, + { + "type": "shell", + "scripts":[ + "{{template_dir}}/scripts/installers/Install-PowerShellModules.ps1" + ], + "environment_vars": [ + "INSTALLER_SCRIPT_FOLDER={{user `installer_script_folder`}}" + ], + "execute_command": "sudo sh -c '{{ .Vars }} pwsh -f {{ .Path }}'" + }, { "type": "shell", "inline": [ - "sudo pwsh -File {{user `image_folder`}}/SoftwareReport/SoftwareReport.Generator.ps1 -OutputDirectory {{user `image_folder`}}" + "pwsh -File {{user `image_folder`}}/SoftwareReport/SoftwareReport.Generator.ps1 -OutputDirectory {{user `image_folder`}}" ], "environment_vars":[ "IMAGE_VERSION={{user `image_version`}}", From 8d517bf1884b2ae8b6f7b024c0363e8a7f2e8c4d Mon Sep 17 00:00:00 2001 From: Aleksandr Chebotov Date: Mon, 14 Sep 2020 16:27:20 +0300 Subject: [PATCH 05/15] remove () --- .../linux/scripts/SoftwareReport/SoftwareReport.Databases.psm1 | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/images/linux/scripts/SoftwareReport/SoftwareReport.Databases.psm1 b/images/linux/scripts/SoftwareReport/SoftwareReport.Databases.psm1 index 47f04de24..973257b10 100644 --- a/images/linux/scripts/SoftwareReport/SoftwareReport.Databases.psm1 +++ b/images/linux/scripts/SoftwareReport/SoftwareReport.Databases.psm1 @@ -15,7 +15,7 @@ function Get-SqliteVersion { function Get-MySQLVersion { $mySQLVersion = mysqld --version | Take-OutputPart -Part 2 | Take-OutputPart -Part 0 -Delimiter "-" - return "MySQL ($mySQLVersion)" + return "MySQL $mySQLVersion" } function Build-MySQLSection { From bcca2214d94907e77af8276d1dc09b8ec76320e5 Mon Sep 17 00:00:00 2001 From: Aleksandr Chebotov Date: Mon, 14 Sep 2020 16:39:49 +0300 Subject: [PATCH 06/15] remove module MarkdownPS installation --- .../linux/scripts/SoftwareReport/SoftwareReport.Generator.ps1 | 2 -- 1 file changed, 2 deletions(-) diff --git a/images/linux/scripts/SoftwareReport/SoftwareReport.Generator.ps1 b/images/linux/scripts/SoftwareReport/SoftwareReport.Generator.ps1 index ac23a6deb..1cd951f3a 100644 --- a/images/linux/scripts/SoftwareReport/SoftwareReport.Generator.ps1 +++ b/images/linux/scripts/SoftwareReport/SoftwareReport.Generator.ps1 @@ -3,8 +3,6 @@ param ( $OutputDirectory ) -# Install MarkdownPS module for software report generation -Install-Module MarkdownPS -Force Import-Module MarkdownPS Import-Module (Join-Path $PSScriptRoot "SoftwareReport.CachedTools.psm1") -DisableNameChecking Import-Module (Join-Path $PSScriptRoot "SoftwareReport.Common.psm1") -DisableNameChecking From 6ed38287599a3bfbcae4e50f8988c75ece2a0517 Mon Sep 17 00:00:00 2001 From: Aleksandr Chebotov Date: Mon, 14 Sep 2020 21:47:31 +0300 Subject: [PATCH 07/15] fix azcopy and rust --- .../SoftwareReport/SoftwareReport.Common.psm1 | 50 ----------------- .../SoftwareReport.Generator.ps1 | 11 ++-- .../SoftwareReport.Helpers.psm1 | 3 +- .../SoftwareReport/SoftwareReport.Rust.psm1 | 54 +++++++++++++++++++ .../SoftwareReport/SoftwareReport.Tools.psm1 | 18 +++---- images/linux/scripts/installers/azcopy.sh | 1 + 6 files changed, 71 insertions(+), 66 deletions(-) create mode 100644 images/linux/scripts/SoftwareReport/SoftwareReport.Rust.psm1 diff --git a/images/linux/scripts/SoftwareReport/SoftwareReport.Common.psm1 b/images/linux/scripts/SoftwareReport/SoftwareReport.Common.psm1 index 5fafca0f1..64c828424 100644 --- a/images/linux/scripts/SoftwareReport/SoftwareReport.Common.psm1 +++ b/images/linux/scripts/SoftwareReport/SoftwareReport.Common.psm1 @@ -217,56 +217,6 @@ function Get-StackVersion { return "Stack $stackVersion" } -function Get-RustVersion { - $rustVersion = $(rustc --version) | Take-OutputPart -Part 1 - return "Rust $rustVersion" -} - -function Get-BindgenVersion { - $bindgenVersion = $(bindgen --version) | Take-OutputPart -Part 1 - return "Bindgen $bindgenVersion" -} - -function Get-CargoVersion { - $cargoVersion = $(cargo --version) | Take-OutputPart -Part 1 - return "Cargo $cargoVersion" -} - -function Get-CargoAuditVersion { - $cargoAuditVersion = $(cargo audit --version) | Take-OutputPart -Part 1 - return "Cargo audit $cargoAuditVersion" -} - -function Get-CargoOutdatedVersion { - $cargoOutdatedVersion = $(cargo outdated --version) | Take-OutputPart -Part 1 -Delimiter "v" - return "Cargo outdated $cargoOutdatedVersion" -} - -function Get-CargoClippyVersion { - $cargoClippyVersion = $(cargo-clippy --version) | Take-OutputPart -Part 1 - return "Cargo clippy $cargoClippyVersion" -} - -function Get-CbindgenVersion { - $cbindgenVersion = $(cbindgen --version) | Take-OutputPart -Part 1 - return "Cbindgen $cbindgenVersion" -} - -function Get-RustupVersion { - $rustupVersion = $(rustup --version) | Take-OutputPart -Part 1 - return "Rustup $rustupVersion" -} - -function Get-RustdocVersion { - $rustdocVersion = $(rustdoc --version) | Take-OutputPart -Part 1 - return "Rustdoc $rustdocVersion" -} - -function Get-RustfmtVersion { - $rustfmtVersion = $(rustfmt --version) | Take-OutputPart -Part 1 | Take-OutputPart -Part 0 -Delimiter "-" - return "Rustfmt $rustfmtVersion" -} - function Get-AzModuleVersions { $azModuleVersions = Get-ChildItem /usr/share | Where-Object { $_ -match "az_\d+" } | Foreach-Object { $_.Name.Split("_")[1] diff --git a/images/linux/scripts/SoftwareReport/SoftwareReport.Generator.ps1 b/images/linux/scripts/SoftwareReport/SoftwareReport.Generator.ps1 index 1cd951f3a..e0acc6bde 100644 --- a/images/linux/scripts/SoftwareReport/SoftwareReport.Generator.ps1 +++ b/images/linux/scripts/SoftwareReport/SoftwareReport.Generator.ps1 @@ -4,14 +4,15 @@ param ( ) Import-Module MarkdownPS +Import-Module (Join-Path $PSScriptRoot "SoftwareReport.Android.psm1") -DisableNameChecking +Import-Module (Join-Path $PSScriptRoot "SoftwareReport.Browsers.psm1") -DisableNameChecking Import-Module (Join-Path $PSScriptRoot "SoftwareReport.CachedTools.psm1") -DisableNameChecking Import-Module (Join-Path $PSScriptRoot "SoftwareReport.Common.psm1") -DisableNameChecking -Import-Module (Join-Path $PSScriptRoot "SoftwareReport.Helpers.psm1") -DisableNameChecking -Import-Module (Join-Path $PSScriptRoot "SoftwareReport.Tools.psm1") -DisableNameChecking -Import-Module (Join-Path $PSScriptRoot "SoftwareReport.Java.psm1") -DisableNameChecking Import-Module (Join-Path $PSScriptRoot "SoftwareReport.Databases.psm1") -DisableNameChecking -Import-Module (Join-Path $PSScriptRoot "SoftwareReport.Browsers.psm1") -DisableNameChecking -Import-Module (Join-Path $PSScriptRoot "SoftwareReport.Android.psm1") -DisableNameChecking +Import-Module (Join-Path $PSScriptRoot "SoftwareReport.Helpers.psm1") -DisableNameChecking +Import-Module (Join-Path $PSScriptRoot "SoftwareReport.Java.psm1") -DisableNameChecking +Import-Module (Join-Path $PSScriptRoot "SoftwareReport.Rust.psm1") -DisableNameChecking +Import-Module (Join-Path $PSScriptRoot "SoftwareReport.Tools.psm1") -DisableNameChecking $markdown = "" diff --git a/images/linux/scripts/SoftwareReport/SoftwareReport.Helpers.psm1 b/images/linux/scripts/SoftwareReport/SoftwareReport.Helpers.psm1 index 4bad753bd..45ab44948 100644 --- a/images/linux/scripts/SoftwareReport/SoftwareReport.Helpers.psm1 +++ b/images/linux/scripts/SoftwareReport/SoftwareReport.Helpers.psm1 @@ -37,8 +37,7 @@ function Test-IsUbuntu20 { return (lsb_release -rs) -eq "20.04" } -function Get-ToolsetContent -{ +function Get-ToolsetContent { $toolset = Join-Path $env:INSTALLER_SCRIPT_FOLDER "toolset.json" Get-Content $toolset -Raw | ConvertFrom-Json } diff --git a/images/linux/scripts/SoftwareReport/SoftwareReport.Rust.psm1 b/images/linux/scripts/SoftwareReport/SoftwareReport.Rust.psm1 new file mode 100644 index 000000000..640ad2cf8 --- /dev/null +++ b/images/linux/scripts/SoftwareReport/SoftwareReport.Rust.psm1 @@ -0,0 +1,54 @@ +function Initialize-RustEnvironment { + ln -sf "/usr/share/rust/.rustup" $HOME/.rustup + ln -sf "/usr/share/rust/.cargo" $HOME/.cargo +} +function Get-RustVersion { + Initialize-RustEnvironment + $rustVersion = $(rustc --version) | Take-OutputPart -Part 1 + return "Rust $rustVersion" +} + +function Get-BindgenVersion { + $bindgenVersion = $(bindgen --version) | Take-OutputPart -Part 1 + return "Bindgen $bindgenVersion" +} + +function Get-CargoVersion { + $cargoVersion = $(cargo --version) | Take-OutputPart -Part 1 + return "Cargo $cargoVersion" +} + +function Get-CargoAuditVersion { + $cargoAuditVersion = $(cargo audit --version) | Take-OutputPart -Part 1 + return "Cargo audit $cargoAuditVersion" +} + +function Get-CargoOutdatedVersion { + $cargoOutdatedVersion = $(cargo outdated --version) | Take-OutputPart -Part 1 -Delimiter "v" + return "Cargo outdated $cargoOutdatedVersion" +} + +function Get-CargoClippyVersion { + $cargoClippyVersion = $(cargo-clippy --version) | Take-OutputPart -Part 1 + return "Cargo clippy $cargoClippyVersion" +} + +function Get-CbindgenVersion { + $cbindgenVersion = $(cbindgen --version) | Take-OutputPart -Part 1 + return "Cbindgen $cbindgenVersion" +} + +function Get-RustupVersion { + $rustupVersion = $(rustup --version) | Take-OutputPart -Part 1 + return "Rustup $rustupVersion" +} + +function Get-RustdocVersion { + $rustdocVersion = $(rustdoc --version) | Take-OutputPart -Part 1 + return "Rustdoc $rustdocVersion" +} + +function Get-RustfmtVersion { + $rustfmtVersion = $(rustfmt --version) | Take-OutputPart -Part 1 | Take-OutputPart -Part 0 -Delimiter "-" + return "Rustfmt $rustfmtVersion" +} \ No newline at end of file diff --git a/images/linux/scripts/SoftwareReport/SoftwareReport.Tools.psm1 b/images/linux/scripts/SoftwareReport/SoftwareReport.Tools.psm1 index 05032cfb6..a76c17f9b 100644 --- a/images/linux/scripts/SoftwareReport/SoftwareReport.Tools.psm1 +++ b/images/linux/scripts/SoftwareReport/SoftwareReport.Tools.psm1 @@ -4,7 +4,7 @@ function Get-7zipVersion { } function Get-AnsibleVersion { - $ansibleVersion = ansible --version | Select-Object -First 1 | Take-OutputPart -Part 1 + $ansibleVersion = sudo ansible --version | Select-Object -First 1 | Take-OutputPart -Part 1 return "Ansible $ansibleVersion" } @@ -19,12 +19,12 @@ function Get-AzCopy10Version { } function Get-BazelVersion { - $bazelVersion = bazel --version | Select-String "bazel" | Take-OutputPart -Part 1 + $bazelVersion = sudo bazel --version | Select-String "bazel" | Take-OutputPart -Part 1 return "Bazel $bazelVersion" } function Get-BazeliskVersion { - $bazeliskVersion = bazelisk version 2>&1 | Select-String "Bazelisk version:" | Take-OutputPart -Part 2 | Take-OutputPart -Part 0 -Delimiter "v" + $bazeliskVersion = sudo bazelisk version 2>&1 | Select-String "Bazelisk version:" | Take-OutputPart -Part 2 | Take-OutputPart -Part 0 -Delimiter "v" return "Bazelisk $bazeliskVersion" } @@ -84,7 +84,7 @@ function Get-GitFTPVersion { } function Get-GoogleCloudSDKVersion { - return "$(gcloud --version | Select-Object -First 1)" + return "$(sudo gcloud --version | Select-Object -First 1)" } function Get-HavegedVersion { @@ -93,7 +93,7 @@ function Get-HavegedVersion { } function Get-HerokuVersion { - $herokuVersion = heroku version | Take-OutputPart -Part 0 | Take-OutputPart -Part 1 -Delimiter "/" + $herokuVersion = sudo heroku version | Take-OutputPart -Part 0 | Take-OutputPart -Part 1 -Delimiter "/" return "Heroku $herokuVersion" } @@ -146,7 +146,7 @@ function Get-NewmanVersion { } function Get-NvmVersion { - $nvmVersion = bash -c "source $HOME/.nvm/nvm.sh && nvm --version" + $nvmVersion = bash -c "source /etc/skel/.nvm/nvm.sh && nvm --version" return "nvm $nvmVersion" } @@ -193,12 +193,12 @@ function Get-JqVersion { } function Get-AzureCliVersion { - $azcliVersion = az -v | Select-String "azure-cli" | Take-OutputPart -Part -1 + $azcliVersion = sudo az -v | Select-String "azure-cli" | Take-OutputPart -Part -1 return "Azure CLI (azure-cli) $azcliVersion" } function Get-AzureDevopsVersion { - $azdevopsVersion = az -v | Select-String "azure-devops" | Take-OutputPart -Part -1 + $azdevopsVersion = sudo az -v | Select-String "azure-devops" | Take-OutputPart -Part -1 return "Azure CLI (azure-devops) $azdevopsVersion" } @@ -230,7 +230,7 @@ function Get-GitHubCliVersion { } function Get-NetlifyCliVersion { - $netlifyVersion = netlify --version | Take-OutputPart -Part 0 | Take-OutputPart -Part 1 -Delimiter "/" + $netlifyVersion = sudo netlify --version | Take-OutputPart -Part 0 | Take-OutputPart -Part 1 -Delimiter "/" return "Netlify CLI $netlifyVersion" } diff --git a/images/linux/scripts/installers/azcopy.sh b/images/linux/scripts/installers/azcopy.sh index 3efe54d11..9d15d37af 100644 --- a/images/linux/scripts/installers/azcopy.sh +++ b/images/linux/scripts/installers/azcopy.sh @@ -17,6 +17,7 @@ rm azcopy.tar.gz wget -O /tmp/azcopy.tar.gz https://aka.ms/downloadazcopy-v10-linux tar zxvf /tmp/azcopy.tar.gz --strip-components=1 -C /tmp mv /tmp/azcopy /usr/local/bin/azcopy10 +chmod +x /usr/local/bin/azcopy10 # Run tests to determine that the software installed as expected echo "Testing to make sure that script performed as expected, and basic scenarios work" From ef96becdb646ab93999161d763c41c1bd475bba3 Mon Sep 17 00:00:00 2001 From: Aleksandr Chebotov Date: Mon, 14 Sep 2020 22:15:25 +0300 Subject: [PATCH 08/15] fix warnings --- .../SoftwareReport/SoftwareReport.Common.psm1 | 32 +++++++++---------- 1 file changed, 16 insertions(+), 16 deletions(-) diff --git a/images/linux/scripts/SoftwareReport/SoftwareReport.Common.psm1 b/images/linux/scripts/SoftwareReport/SoftwareReport.Common.psm1 index 64c828424..14c6db9c0 100644 --- a/images/linux/scripts/SoftwareReport/SoftwareReport.Common.psm1 +++ b/images/linux/scripts/SoftwareReport/SoftwareReport.Common.psm1 @@ -5,7 +5,7 @@ function Get-OSName { } function Get-CPPVersions { - $cppVersions = & apt list --installed | Where-Object { $_ -match "g\+\+-\d+"} | ForEach-Object { + $cppVersions = apt list --installed 2>&1 | Where-Object { $_ -match "g\+\+-\d+"} | ForEach-Object { $_ -match "now (?\d+\.\d+\.\d+)-" | Out-Null $Matches.version } @@ -13,7 +13,7 @@ function Get-CPPVersions { } function Get-FortranVersions { - $fortranVersions = & apt list --installed | Where-Object { $_ -match "^gfortran-\d+"} | ForEach-Object { + $fortranVersions = apt list --installed 2>&1 | Where-Object { $_ -match "^gfortran-\d+"} | ForEach-Object { $_ -match "now (?\d+\.\d+\.\d+)-" | Out-Null $Matches.version } @@ -22,7 +22,7 @@ function Get-FortranVersions { function Get-ClangVersions { $clangVersions = @() - $clangVersions = & apt list --installed | Where-Object { $_ -match "^clang-\d+"} | ForEach-Object { + $clangVersions = apt list --installed 2>&1 | Where-Object { $_ -match "^clang-\d+"} | ForEach-Object { $clangCommand = ($_ -Split "/")[0] Invoke-Expression "$clangCommand --version" | Where-Object { $_ -match "clang version" } | ForEach-Object { $_ -match "clang version (?\d+\.\d+\.\d+)-" | Out-Null @@ -40,7 +40,7 @@ function Get-ErlangVersion { } function Get-MonoVersion { - $monoVersion = $(mono --version) | Out-String | Take-OutputPart -Part 4 + $monoVersion = mono --version | Out-String | Take-OutputPart -Part 4 return "Mono $monoVersion" } @@ -62,16 +62,16 @@ function Get-Python3Version { } function Get-PowershellVersion { - $(pwsh --version) + return $(pwsh --version) } function Get-RubyVersion { - $rubyVersion = $(ruby --version) | Out-String | Take-OutputPart -Part 1 + $rubyVersion = ruby --version | Out-String | Take-OutputPart -Part 1 return "Ruby $rubyVersion" } function Get-SwiftVersion { - $swiftVersion = $(swift --version) | Out-String | Take-OutputPart -Part 2 + $swiftVersion = swift --version | Out-String | Take-OutputPart -Part 2 return "Swift $swiftVersion" } @@ -88,13 +88,13 @@ function Get-HomebrewVersion { } function Get-GemVersion { - $(gem --version) -match "(?\d+\.\d+\.\d+)" | Out-Null + $(gem --version 2>&1) -match "(?\d+\.\d+\.\d+)" | Out-Null $gemVersion = $Matches.version return "Gem $gemVersion" } function Get-MinicondaVersion { - $condaVersion = $(conda --version) + $condaVersion = conda --version return "Mini$condaVersion" } @@ -105,12 +105,12 @@ function Get-HelmVersion { } function Get-NpmVersion { - $npmVersion = $(npm --version) + $npmVersion = npm --version return "Npm $npmVersion" } function Get-YarnVersion { - $yarnVersion = $(yarn --version) + $yarnVersion = yarn --version return "Yarn $yarnVersion" } @@ -136,33 +136,33 @@ function Get-VcpkgVersion { } function Get-AntVersion { - $result = $(ant -version) | Out-String + $result = ant -version | Out-String $result -match "version (?\d+\.\d+\.\d+)" | Out-Null $antVersion = $Matches.version return "Ant $antVersion" } function Get-GradleVersion { - $result = $(gradle -v) | Out-String + $result = gradle -v | Out-String $result -match "Gradle (?\d+\.\d+\.\d+)" | Out-Null $gradleVersion = $Matches.version return "Gradle $gradleVersion" } function Get-MavenVersion { - $result = $(mvn -version) | Out-String + $result = mvn -version | Out-String $result -match "Apache Maven (?\d+\.\d+\.\d+)" | Out-Null $mavenVersion = $Matches.version return "Maven $mavenVersion" } function Get-SbtVersion { - $result = $(sbt -version) | Out-String + $result = sbt -version 2>&1 | Out-String $result -match "sbt script version: (?\d+\.\d+\.\d+)" | Out-Null $sbtVersion = $Matches.version return "Sbt $sbtVersion" } function Get-PHPVersions { - return $(apt list --installed) | Where-Object { $_ -match "^php\d+\.\d+/"} | ForEach-Object { + return $(apt list --installed 2>&1) | Where-Object { $_ -match "^php\d+\.\d+/"} | ForEach-Object { $_ -match "now (?\d+\.\d+\.\d+)-" | Out-Null $Matches.version } From 5b009f290af6e135c838bc109a742d2649a5d2d6 Mon Sep 17 00:00:00 2001 From: Aleksandr Chebotov Date: Mon, 14 Sep 2020 22:22:58 +0300 Subject: [PATCH 09/15] julia remove trailing line --- images/linux/scripts/SoftwareReport/SoftwareReport.Common.psm1 | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/images/linux/scripts/SoftwareReport/SoftwareReport.Common.psm1 b/images/linux/scripts/SoftwareReport/SoftwareReport.Common.psm1 index 14c6db9c0..f36ab2b20 100644 --- a/images/linux/scripts/SoftwareReport/SoftwareReport.Common.psm1 +++ b/images/linux/scripts/SoftwareReport/SoftwareReport.Common.psm1 @@ -76,7 +76,7 @@ function Get-SwiftVersion { } function Get-JuliaVersion { - $juliaVersion = $(julia --version) | Out-String | Take-OutputPart -Part 2 + $juliaVersion = julia --version | Take-OutputPart -Part 2 return "Julia $juliaVersion" } From 4a07ea61a8d7d558b29ad088e4621561426859b6 Mon Sep 17 00:00:00 2001 From: Aleksandr Chebotov Date: Tue, 15 Sep 2020 09:20:45 +0300 Subject: [PATCH 10/15] fix gem output --- images/linux/scripts/SoftwareReport/SoftwareReport.Common.psm1 | 3 ++- images/linux/scripts/SoftwareReport/SoftwareReport.Rust.psm1 | 1 + 2 files changed, 3 insertions(+), 1 deletion(-) diff --git a/images/linux/scripts/SoftwareReport/SoftwareReport.Common.psm1 b/images/linux/scripts/SoftwareReport/SoftwareReport.Common.psm1 index f36ab2b20..64a9d1c3f 100644 --- a/images/linux/scripts/SoftwareReport/SoftwareReport.Common.psm1 +++ b/images/linux/scripts/SoftwareReport/SoftwareReport.Common.psm1 @@ -88,7 +88,8 @@ function Get-HomebrewVersion { } function Get-GemVersion { - $(gem --version 2>&1) -match "(?\d+\.\d+\.\d+)" | Out-Null + $result = Get-CommandResult "gem --version" + $result.Output -match "(?\d+\.\d+\.\d+)" | Out-Null $gemVersion = $Matches.version return "Gem $gemVersion" } diff --git a/images/linux/scripts/SoftwareReport/SoftwareReport.Rust.psm1 b/images/linux/scripts/SoftwareReport/SoftwareReport.Rust.psm1 index 640ad2cf8..e822a5c38 100644 --- a/images/linux/scripts/SoftwareReport/SoftwareReport.Rust.psm1 +++ b/images/linux/scripts/SoftwareReport/SoftwareReport.Rust.psm1 @@ -2,6 +2,7 @@ function Initialize-RustEnvironment { ln -sf "/usr/share/rust/.rustup" $HOME/.rustup ln -sf "/usr/share/rust/.cargo" $HOME/.cargo } + function Get-RustVersion { Initialize-RustEnvironment $rustVersion = $(rustc --version) | Take-OutputPart -Part 1 From 46fdad5e60e1895f97b10436f35e1ab7202d2efe Mon Sep 17 00:00:00 2001 From: Aleksandr Chebotov Date: Wed, 16 Sep 2020 10:42:16 +0300 Subject: [PATCH 11/15] fix android and docker sections --- .../SoftwareReport/SoftwareReport.Android.psm1 | 12 ++++++------ .../SoftwareReport/SoftwareReport.Generator.ps1 | 2 +- .../scripts/SoftwareReport/SoftwareReport.Tools.psm1 | 4 ++-- 3 files changed, 9 insertions(+), 9 deletions(-) diff --git a/images/linux/scripts/SoftwareReport/SoftwareReport.Android.psm1 b/images/linux/scripts/SoftwareReport/SoftwareReport.Android.psm1 index 7f34143a9..a3504171c 100644 --- a/images/linux/scripts/SoftwareReport/SoftwareReport.Android.psm1 +++ b/images/linux/scripts/SoftwareReport/SoftwareReport.Android.psm1 @@ -52,6 +52,10 @@ function Build-AndroidTable { "Package" = "Google APIs" "Version" = Get-AndroidGoogleAPIsVersions -PackageInfo $packageInfo }, + @{ + "Package" = "NDK" + "Version" = Get-AndroidPackageVersions -PackageInfo $packageInfo -MatchedString "ndk-bundle" + }, @{ "Package" = "Android Support Repository" "Version" = Get-AndroidPackageVersions -PackageInfo $packageInfo -MatchedString "Android Support Repository" @@ -71,16 +75,12 @@ function Build-AndroidTable { @{ "Package" = "CMake" "Version" = Get-AndroidPackageVersions -PackageInfo $packageInfo -MatchedString "cmake" - }, - @{ - "Package" = "NDK" - "Version" = Get-AndroidPackageVersions -PackageInfo $packageInfo -MatchedString "ndk-bundle" } ) | Where-Object { $_.Version } | ForEach-Object { [PSCustomObject] @{ "Package Name" = $_.Package "Version" = $_.Version - } + } } } @@ -109,7 +109,7 @@ function Get-AndroidPlatformVersions { $packageInfoParts = Split-TableRowByColumns $_ $revision = $packageInfoParts[1] $version = $packageInfoParts[0].split(";")[1] - return "$version, (rev $revision)" + return "$version (rev $revision)" } [array]::Reverse($versions) return ($versions -Join "
") diff --git a/images/linux/scripts/SoftwareReport/SoftwareReport.Generator.ps1 b/images/linux/scripts/SoftwareReport/SoftwareReport.Generator.ps1 index e0acc6bde..73a8d63e7 100644 --- a/images/linux/scripts/SoftwareReport/SoftwareReport.Generator.ps1 +++ b/images/linux/scripts/SoftwareReport/SoftwareReport.Generator.ps1 @@ -79,8 +79,8 @@ $toolsList = @( (Get-BazeliskVersion), (Get-CMakeVersion), (Get-CurlVersion), - (Get-DockerComposeVersion), (Get-DockerMobyVersion), + (Get-DockerComposeVersion), (Get-DockerBuildxVersion), (Get-GitVersion), (Get-GitLFSVersion), diff --git a/images/linux/scripts/SoftwareReport/SoftwareReport.Tools.psm1 b/images/linux/scripts/SoftwareReport/SoftwareReport.Tools.psm1 index a76c17f9b..dcb121f61 100644 --- a/images/linux/scripts/SoftwareReport/SoftwareReport.Tools.psm1 +++ b/images/linux/scripts/SoftwareReport/SoftwareReport.Tools.psm1 @@ -10,12 +10,12 @@ function Get-AnsibleVersion { function Get-AzCopy7Version { $azcopy7Version = azcopy --version | Take-OutputPart -Part 1 | Take-OutputPart -Part 0 -Delimiter "-" - return "AzCopy7 (available by azcopy alias) $azcopy7Version" + return "AzCopy7 $azcopy7Version (available by ``azcopy`` alias)" } function Get-AzCopy10Version { $azcopy10Version = azcopy10 --version | Take-OutputPart -Part 2 - return "AzCopy10 (available by azcopy10 alias) $azcopy10Version" + return "AzCopy10 $azcopy10Version (available by ``azcopy10`` alias)" } function Get-BazelVersion { From 2d3a3d4f3d51db151893250736dbfd6cb25a8c0c Mon Sep 17 00:00:00 2001 From: Maxim Lobanov Date: Wed, 16 Sep 2020 11:43:50 +0300 Subject: [PATCH 12/15] update documentation --- .github/pull_request_template.md | 2 ++ CONTRIBUTING.md | 3 ++- README.md | 3 ++- 3 files changed, 6 insertions(+), 2 deletions(-) diff --git a/.github/pull_request_template.md b/.github/pull_request_template.md index 54085c9b9..d0997a0c2 100644 --- a/.github/pull_request_template.md +++ b/.github/pull_request_template.md @@ -3,6 +3,8 @@ New tool, Bug fixing, or Improvement? Please include a summary of the change and which issue is fixed. Also include relevant motivation and context. **For new tools, please provide total size and installation time.** + + #### Related issue: ## Check list diff --git a/CONTRIBUTING.md b/CONTRIBUTING.md index af608840b..e35a3c829 100644 --- a/CONTRIBUTING.md +++ b/CONTRIBUTING.md @@ -51,7 +51,8 @@ Add `Invoke-PesterTests -TestFile [-TestName ]` at - Use `DocumentInstalledItem ""` helper for building documentation. ### macOS -We are in the process of preparing our macOS source to live in this repo so we can take contributions from the community. Until then, we appreciate your patience and ask you continue to make tool requests by filing issues. +MacOS source lives in this repository and available for everyone. However, MacOS image-generation CI doesn't support external contributions yet so we are not ready to accept pull-requests for now. +We are in the process of preparing MacOS CI to accept contributions. Until then, we appreciate your patience and ask you continue to make tool requests by filing issues. ## Resources diff --git a/README.md b/README.md index dc30f2668..1df8ea4ed 100644 --- a/README.md +++ b/README.md @@ -19,7 +19,8 @@ The "ubuntu-latest" YAML workflow label still uses the Ubuntu 18.04 virtual envi ***Looking for other Linux distributions?*** We do not plan to offer other Linux distributions. We recommend using Docker if you'd like to build using other distributions with the hosted virtual environments. Alternatively, you can leverage [self-hosted runners] and fully customize your environment to your needs. -***Where is the macOS source?*** We are in the process of preparing our macOS source to live in this repo so we can take contributions from the community. Until then, we appreciate your patience and ask you continue to make tool requests by filing issues. +***How to contribute to macOS source?*** MacOS source lives in this repository and available for everyone. However, MacOS image-generation CI doesn't support external contributions yet so we are not ready to accept pull-requests for now. +We are in the process of preparing MacOS CI to accept contributions. Until then, we appreciate your patience and ask you continue to make tool requests by filing issues. ## Software Guidelines In general, these are the guidelines we consider when deciding what to pre-install: From 15b5f5fe6759e428d837399596c5966403f22cc1 Mon Sep 17 00:00:00 2001 From: Maxim Lobanov Date: Wed, 16 Sep 2020 13:25:16 +0300 Subject: [PATCH 13/15] MacOS -> macOS --- CONTRIBUTING.md | 2 +- README.md | 2 +- 2 files changed, 2 insertions(+), 2 deletions(-) diff --git a/CONTRIBUTING.md b/CONTRIBUTING.md index e35a3c829..021fbc2fa 100644 --- a/CONTRIBUTING.md +++ b/CONTRIBUTING.md @@ -51,7 +51,7 @@ Add `Invoke-PesterTests -TestFile [-TestName ]` at - Use `DocumentInstalledItem ""` helper for building documentation. ### macOS -MacOS source lives in this repository and available for everyone. However, MacOS image-generation CI doesn't support external contributions yet so we are not ready to accept pull-requests for now. +macOS source lives in this repository and available for everyone. However, MacOS image-generation CI doesn't support external contributions yet so we are not ready to accept pull-requests for now. We are in the process of preparing MacOS CI to accept contributions. Until then, we appreciate your patience and ask you continue to make tool requests by filing issues. ## Resources diff --git a/README.md b/README.md index 1df8ea4ed..934fcb446 100644 --- a/README.md +++ b/README.md @@ -19,7 +19,7 @@ The "ubuntu-latest" YAML workflow label still uses the Ubuntu 18.04 virtual envi ***Looking for other Linux distributions?*** We do not plan to offer other Linux distributions. We recommend using Docker if you'd like to build using other distributions with the hosted virtual environments. Alternatively, you can leverage [self-hosted runners] and fully customize your environment to your needs. -***How to contribute to macOS source?*** MacOS source lives in this repository and available for everyone. However, MacOS image-generation CI doesn't support external contributions yet so we are not ready to accept pull-requests for now. +***How to contribute to macOS source?*** macOS source lives in this repository and available for everyone. However, MacOS image-generation CI doesn't support external contributions yet so we are not ready to accept pull-requests for now. We are in the process of preparing MacOS CI to accept contributions. Until then, we appreciate your patience and ask you continue to make tool requests by filing issues. ## Software Guidelines From 6e62e32b9713809bfa0a7f13a373d45a734ebd19 Mon Sep 17 00:00:00 2001 From: Maxim Lobanov Date: Wed, 16 Sep 2020 13:41:49 +0300 Subject: [PATCH 14/15] Update CONTRIBUTING.md --- CONTRIBUTING.md | 6 +++--- 1 file changed, 3 insertions(+), 3 deletions(-) diff --git a/CONTRIBUTING.md b/CONTRIBUTING.md index 021fbc2fa..927ae8724 100644 --- a/CONTRIBUTING.md +++ b/CONTRIBUTING.md @@ -31,7 +31,7 @@ Here are a few things you can do that will increase the likelihood of your pull ## How to add new tool ### General rules - For every new tool add validation scripts and update software report script to make sure that it is included to documentation -- If the tool is available in other platforms (MacOS, Windows, Linux), make sure you include it in as many as possible. +- If the tool is available in other platforms (macOS, Windows, Linux), make sure you include it in as many as possible. - If installing a few versions of the tool, consider putting the list of versions in the corresponding `toolset.json` file. It will help other customers to configure their builds flexibly. See [toolset-windows-2016.json](images/win/toolsets/toolset-2019.json) as example. - Use consistent naming across all files - Validation scripts should be simple and shouldn't change image content @@ -51,8 +51,8 @@ Add `Invoke-PesterTests -TestFile [-TestName ]` at - Use `DocumentInstalledItem ""` helper for building documentation. ### macOS -macOS source lives in this repository and available for everyone. However, MacOS image-generation CI doesn't support external contributions yet so we are not ready to accept pull-requests for now. -We are in the process of preparing MacOS CI to accept contributions. Until then, we appreciate your patience and ask you continue to make tool requests by filing issues. +macOS source lives in this repository and available for everyone. However, macOS image-generation CI doesn't support external contributions yet so we are not ready to accept pull-requests for now. +We are in the process of preparing macOS CI to accept contributions. Until then, we appreciate your patience and ask you continue to make tool requests by filing issues. ## Resources From 219bfe0d1f60f456e5e992d7224a34a5a4d97d3b Mon Sep 17 00:00:00 2001 From: Maxim Lobanov Date: Wed, 16 Sep 2020 16:37:30 +0300 Subject: [PATCH 15/15] fix comments --- .github/pull_request_template.md | 2 +- CONTRIBUTING.md | 2 +- README.md | 2 +- 3 files changed, 3 insertions(+), 3 deletions(-) diff --git a/.github/pull_request_template.md b/.github/pull_request_template.md index d0997a0c2..d815d34fd 100644 --- a/.github/pull_request_template.md +++ b/.github/pull_request_template.md @@ -3,7 +3,7 @@ New tool, Bug fixing, or Improvement? Please include a summary of the change and which issue is fixed. Also include relevant motivation and context. **For new tools, please provide total size and installation time.** - + #### Related issue: diff --git a/CONTRIBUTING.md b/CONTRIBUTING.md index 927ae8724..f0d8d4ec7 100644 --- a/CONTRIBUTING.md +++ b/CONTRIBUTING.md @@ -51,7 +51,7 @@ Add `Invoke-PesterTests -TestFile [-TestName ]` at - Use `DocumentInstalledItem ""` helper for building documentation. ### macOS -macOS source lives in this repository and available for everyone. However, macOS image-generation CI doesn't support external contributions yet so we are not ready to accept pull-requests for now. +macOS source lives in this repository and available for everyone. However, macOS image-generation CI doesn't support external contributions yet so we are not able to accept pull-requests for now. We are in the process of preparing macOS CI to accept contributions. Until then, we appreciate your patience and ask you continue to make tool requests by filing issues. ## Resources diff --git a/README.md b/README.md index 934fcb446..b3c596491 100644 --- a/README.md +++ b/README.md @@ -19,7 +19,7 @@ The "ubuntu-latest" YAML workflow label still uses the Ubuntu 18.04 virtual envi ***Looking for other Linux distributions?*** We do not plan to offer other Linux distributions. We recommend using Docker if you'd like to build using other distributions with the hosted virtual environments. Alternatively, you can leverage [self-hosted runners] and fully customize your environment to your needs. -***How to contribute to macOS source?*** macOS source lives in this repository and available for everyone. However, MacOS image-generation CI doesn't support external contributions yet so we are not ready to accept pull-requests for now. +***How to contribute to macOS source?*** macOS source lives in this repository and available for everyone. However, MacOS image-generation CI doesn't support external contributions yet so we are not able to accept pull-requests for now. We are in the process of preparing MacOS CI to accept contributions. Until then, we appreciate your patience and ask you continue to make tool requests by filing issues. ## Software Guidelines