From be806579bb3c8fc4fd187f8c1d3c4234e7adb15f Mon Sep 17 00:00:00 2001 From: hackercat Date: Wed, 31 Mar 2021 11:38:11 +0200 Subject: [PATCH] [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 --- .../linux/scripts/SoftwareReport/SoftwareReport.Common.psm1 | 5 +++-- images/linux/scripts/tests/Tools.Tests.ps1 | 6 +++--- 2 files changed, 6 insertions(+), 5 deletions(-) diff --git a/images/linux/scripts/SoftwareReport/SoftwareReport.Common.psm1 b/images/linux/scripts/SoftwareReport/SoftwareReport.Common.psm1 index fabcc4989..89a07dcff 100644 --- a/images/linux/scripts/SoftwareReport/SoftwareReport.Common.psm1 +++ b/images/linux/scripts/SoftwareReport/SoftwareReport.Common.psm1 @@ -34,8 +34,9 @@ function Get-ClangVersions { } function Get-ErlangVersion { - $version = (erl -eval 'erlang:display(erlang:system_info(version)), halt().' -noshell).Trim('"') - return "Erlang $version" + $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) + $shellVersion = (erl -eval 'erlang:display(erlang:system_info(version)), halt().' -noshell).Trim('"') + return "Erlang $erlangVersion (Eshell $shellVersion)" } function Get-MonoVersion { diff --git a/images/linux/scripts/tests/Tools.Tests.ps1 b/images/linux/scripts/tests/Tools.Tests.ps1 index d35c7f634..8ec4deb31 100644 --- a/images/linux/scripts/tests/Tools.Tests.ps1 +++ b/images/linux/scripts/tests/Tools.Tests.ps1 @@ -110,15 +110,15 @@ Describe "Cmake" { } Describe "erlang" { - $testCases = @("erl", "erlc", "rebar3") | ForEach-Object { @{ErlangCommand = $_} } + $testCases = @("erl -version", "erlc -v", "rebar3 -v") | ForEach-Object { @{ErlangCommand = $_} } It "erlang " -TestCases $testCases { param ( [string] $ErlangCommand ) - "$ErlangCommand -v" | Should -ReturnZeroExitCode - } + "$ErlangCommand" | Should -ReturnZeroExitCode + } } Describe "gcc" {