diff --git a/images/linux/scripts/SoftwareReport/SoftwareReport.Common.psm1 b/images/linux/scripts/SoftwareReport/SoftwareReport.Common.psm1 index 0698f42d4..ab680f739 100644 --- a/images/linux/scripts/SoftwareReport/SoftwareReport.Common.psm1 +++ b/images/linux/scripts/SoftwareReport/SoftwareReport.Common.psm1 @@ -284,3 +284,18 @@ function Get-PipxVersion { $pipxVersion = $Matches.Version return "Pipx $pipxVersion" } + +function Get-GraalVMVersion { + $version = & "$env:GRAALVM_11_ROOT\bin\java" --version | Select-String -Pattern "GraalVM" | Take-OutputPart -Part 5,6 + return $version +} + +function Build-GraalVMTable { + $version = Get-GraalVMVersion + $envVariables = "GRAALVM_11_ROOT" + + return [PSCustomObject] @{ + "Version" = $version + "Environment variables" = $envVariables + } +} diff --git a/images/linux/scripts/SoftwareReport/SoftwareReport.Generator.ps1 b/images/linux/scripts/SoftwareReport/SoftwareReport.Generator.ps1 index 2d3a5bff1..ba8cff53f 100644 --- a/images/linux/scripts/SoftwareReport/SoftwareReport.Generator.ps1 +++ b/images/linux/scripts/SoftwareReport/SoftwareReport.Generator.ps1 @@ -157,6 +157,12 @@ $markdown += New-MDHeader "Java" -Level 3 $markdown += Get-JavaVersions | New-MDTable $markdown += New-MDNewLine +if (Test-IsUbuntu20) { + $markdown += New-MDHeader "GraalVM" -Level 3 + $markdown += Build-GraalVMTable | New-MDTable + $markdown += New-MDNewLine +} + $markdown += New-MDHeader "PHP" -Level 3 $markdown += Build-PHPTable | New-MDTable $markdown += New-MDNewLine diff --git a/images/linux/scripts/installers/graalvm.sh b/images/linux/scripts/installers/graalvm.sh new file mode 100644 index 000000000..6d32344a8 --- /dev/null +++ b/images/linux/scripts/installers/graalvm.sh @@ -0,0 +1,21 @@ +#!/bin/bash -e + +source $HELPER_SCRIPTS/install.sh +source $HELPER_SCRIPTS/etc-environment.sh + +# Install GraalVM +GRAALVM_ROOT=/usr/local/graalvm +export GRAALVM_11_ROOT=$GRAALVM_ROOT/graalvm-ce-java11* + +url=$(curl -s https://api.github.com/repos/graalvm/graalvm-ce-builds/releases/latest | jq -r '.assets[].browser_download_url | select(contains("graalvm-ce-java11-linux-amd64"))') +download_with_retries "$url" "/tmp" "graalvm-archive.tar.gz" +mkdir $GRAALVM_ROOT +tar -xzf "/tmp/graalvm-archive.tar.gz" -C $GRAALVM_ROOT + +# Set environment variable for GraalVM root +setEtcEnvironmentVariable "GRAALVM_11_ROOT" $GRAALVM_11_ROOT + +# Install Native Image +$GRAALVM_11_ROOT/bin/gu install native-image + +invoke_tests "Tools" "GraalVM" \ No newline at end of file diff --git a/images/linux/scripts/tests/Tools.Tests.ps1 b/images/linux/scripts/tests/Tools.Tests.ps1 index 4dbd36df7..922d59fd8 100644 --- a/images/linux/scripts/tests/Tools.Tests.ps1 +++ b/images/linux/scripts/tests/Tools.Tests.ps1 @@ -299,6 +299,16 @@ Describe "Phantomjs" { } } +Describe "GraalVM" -Skip:(-not (Test-IsUbuntu20)) { + It "graalvm" { + '$GRAALVM_11_ROOT/bin/java -version' | Should -ReturnZeroExitCode + } + + It "native-image" { + '$GRAALVM_11_ROOT/bin/native-image --version' | Should -ReturnZeroExitCode + } +} + Describe "Containers" -Skip:(Test-IsUbuntu16) { $testCases = @("podman", "buildah", "skopeo") | ForEach-Object { @{ContainerCommand = $_} } @@ -339,4 +349,4 @@ Describe "Python" { "$PythonCommand --version" | Should -ReturnZeroExitCode } -} \ No newline at end of file +} diff --git a/images/linux/ubuntu2004.json b/images/linux/ubuntu2004.json index 8bcee7565..677d35a60 100644 --- a/images/linux/ubuntu2004.json +++ b/images/linux/ubuntu2004.json @@ -230,7 +230,8 @@ "{{template_dir}}/scripts/installers/netlify.sh", "{{template_dir}}/scripts/installers/android.sh", "{{template_dir}}/scripts/installers/pypy.sh", - "{{template_dir}}/scripts/installers/python.sh" + "{{template_dir}}/scripts/installers/python.sh", + "{{template_dir}}/scripts/installers/graalvm.sh" ], "environment_vars": [ "HELPER_SCRIPTS={{user `helper_script_folder`}}",