[Ubuntu] Fix Erlang version in software report

SoftwareReport collects wrong version for Erlang, it reports Eshell
version rather than Erlang itself.
reference: https://stackoverflow.com/questions/9560815/how-to-get-erlangs-release-version-number-from-a-shell
2nd answer

`erl` doesn't have `-v` flag, only `-version`
`erlc` `-v` flag is for verbose output
`rebar3` reports it's version with flag `-v`
Change `erl -v` to `erl -version` as it gets stuck in certain scenarios
like using Docker as packer builder.
reference: http://erlang.org/doc/man/erl.html
This commit is contained in:
hackercat
2021-03-31 11:38:11 +02:00
committed by GitHub
parent 726ef281c7
commit be806579bb
2 changed files with 6 additions and 5 deletions

View File

@@ -34,8 +34,9 @@ function Get-ClangVersions {
} }
function Get-ErlangVersion { function Get-ErlangVersion {
$version = (erl -eval 'erlang:display(erlang:system_info(version)), halt().' -noshell).Trim('"') $erlangVersion = (erl -eval '{ok, Version} = file:read_file(filename:join([code:root_dir(), "releases", erlang:system_info(otp_release), ''OTP_VERSION''])), io:fwrite(Version), halt().' -noshell)
return "Erlang $version" $shellVersion = (erl -eval 'erlang:display(erlang:system_info(version)), halt().' -noshell).Trim('"')
return "Erlang $erlangVersion (Eshell $shellVersion)"
} }
function Get-MonoVersion { function Get-MonoVersion {

View File

@@ -110,15 +110,15 @@ Describe "Cmake" {
} }
Describe "erlang" { Describe "erlang" {
$testCases = @("erl", "erlc", "rebar3") | ForEach-Object { @{ErlangCommand = $_} } $testCases = @("erl -version", "erlc -v", "rebar3 -v") | ForEach-Object { @{ErlangCommand = $_} }
It "erlang <ErlangCommand>" -TestCases $testCases { It "erlang <ErlangCommand>" -TestCases $testCases {
param ( param (
[string] $ErlangCommand [string] $ErlangCommand
) )
"$ErlangCommand -v" | Should -ReturnZeroExitCode "$ErlangCommand" | Should -ReturnZeroExitCode
} }
} }
Describe "gcc" { Describe "gcc" {